fix(music-player): fix floating icon position shift on hover

Problem:
- Icon bergeser ke bawah saat hover
- transform: 'scale(1.1)' mengganti transform: 'translateY(-80%)'
- CSS transform property di-replace, bukan di-mix

Solution:
- Gabungkan kedua transform dalam satu string
- Hover: 'translateY(-80%) scale(1.1)' - maintain posisi + scale
- Leave: 'translateY(-80%)' - kembali ke posisi semula

Changes:
- onMouseEnter: transform = 'translateY(-80%) scale(1.1)'
- onMouseLeave: transform = 'translateY(-80%)'
- Added 'ease' timing function for smoother transition

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-03-05 14:53:38 +08:00
parent ee39b88b00
commit 4821934224
3 changed files with 25 additions and 19 deletions

View File

@@ -3,6 +3,7 @@ import {
ActionIcon,
Avatar,
Box,
Button,
Flex,
Group,
Paper,
@@ -85,29 +86,32 @@ export default function FixedPlayerBar() {
return (
<>
{/* Floating Music Icon - Shows when player is minimized */}
<Paper
pos="fixed"
bottom={20}
right={20}
p="md"
shadow="xl"
radius="xl"
bg="blue"
<Button
color="#0B4F78"
variant="filled"
size="md"
mt="md"
style={{
zIndex: 1001,
position: 'fixed',
top: '50%', // Menempatkan titik atas ikon di tengah layar
left: '0px',
transform: 'translateY(-50%)', // Menggeser ikon ke atas sebesar setengah tingginya sendiri agar benar-benar di tengah
borderBottomRightRadius: '20px',
borderTopRightRadius: '20px',
cursor: 'pointer',
transition: 'transform 0.2s',
transition: 'transform 0.2s ease',
zIndex: 1
}}
onClick={handleRestorePlayer}
onMouseEnter={(e) => {
e.currentTarget.style.transform = 'scale(1.1)';
e.currentTarget.style.transform = 'translateY(-50%) scale(1.1)';
}}
onMouseLeave={(e) => {
e.currentTarget.style.transform = 'scale(1)';
e.currentTarget.style.transform = 'translateY(-50%)';
}}
>
<IconMusic size={28} color="white" />
</Paper>
</Button>
{/* Spacer to prevent content from being hidden behind player */}
<Box h={20} />

View File

@@ -1,6 +1,6 @@
'use client';
import { Button } from '@mantine/core';
import { IconMusic, IconMusicOff } from '@tabler/icons-react';
import { IconDisabled, IconDisabledOff } from '@tabler/icons-react';
import { useEffect, useRef, useState } from 'react';
const NewsReaderLanding = () => {
@@ -95,15 +95,17 @@ const NewsReaderLanding = () => {
mt="md"
style={{
position: 'fixed',
bottom: '350px',
top: '50%', // Menempatkan titik atas ikon di tengah layar
left: '0px',
transform: 'translateY(80%)', // Menggeser ikon ke atas sebesar setengah tingginya sendiri agar benar-benar di tengah
borderBottomRightRadius: '20px',
borderTopRightRadius: '20px',
transition: 'all 0.3s ease',
cursor: 'pointer',
transition: 'transform 0.2s',
zIndex: 1
}}
>
{isPointerMode ? <IconMusicOff /> : <IconMusic />}
{isPointerMode ? <IconDisabledOff /> : <IconDisabled />}
</Button>
);
};

View File

@@ -113,7 +113,7 @@ export default function GrafikRealisasi({ apbdesData }: any) {
<Summary title="📊 Pembiayaan" data={pembiayaan} />
</Stack>
{/* Summary Total Keseluruhan */}
{/* Summary Total Keseluruhan
<Box p="md" bg="gray.0">
<>
<Group justify="space-between" mb="xs">
@@ -132,7 +132,7 @@ export default function GrafikRealisasi({ apbdesData }: any) {
color={persenSemua >= 100 ? 'teal' : persenSemua >= 80 ? 'blue' : 'red'}
/>
</>
</Box>
</Box> */}
</Paper>
);
}