11// src/components/Dock/DockStyle/DockStyle.jsx
22
3- // make sure the CSS variables are loaded
4- import '../../configs/CSSConfigs/animations.css ';
3+ // flattened cubic-bezier easing used everywhere
4+ const FLATTENED_EASING = 'cubic-bezier(0.4, 0.0, 0.2, 1.0) ';
55
66/**
77 * Safely include both modern and legacy iOS bottom safe-area insets.
@@ -12,41 +12,43 @@ const SAFE_BOTTOM_CONSTANT = 'constant(safe-area-inset-bottom)';
1212const withSafeBottom = ( marginPx ) =>
1313 `calc(${ marginPx } px + ${ SAFE_BOTTOM_CONSTANT } + ${ SAFE_BOTTOM_ENV } )` ;
1414
15- // slide-only transition, no opacity here
15+ /**
16+ * Returns the outer container style, including only positioning—
17+ * all animations now come exclusively from useDock's INITIAL_TRANSITION.
18+ */
1619export const getOuterContainerStyle = (
1720 DOCK_POSITION ,
1821 DOCK_MARGIN ,
1922 isDockVisible
2023) => {
2124 const style = {
22- // 🔑 fixed to viewport so Safari toolbar doesn’t cover it
2325 position : 'fixed' ,
2426 zIndex : 200 ,
25- transition : 'transform 0.3s var(--easing-flattened)' ,
27+ // no transition here—use only useDock’s INITIAL_TRANSITION
2628 } ;
2729
2830 if ( DOCK_POSITION === 'bottom' ) {
29- style . bottom = withSafeBottom ( DOCK_MARGIN ) ;
30- style . left = '50%' ;
31+ style . bottom = withSafeBottom ( DOCK_MARGIN ) ;
32+ style . left = '50%' ;
3133 style . transform = isDockVisible
3234 ? 'translateX(-50%)'
3335 : 'translateX(-50%) translateY(calc(150% + 10px))' ;
3436 } else if ( DOCK_POSITION === 'left' ) {
35- style . left = `${ DOCK_MARGIN } px` ;
36- style . top = '50%' ;
37+ style . left = `${ DOCK_MARGIN } px` ;
38+ style . top = '50%' ;
3739 style . transform = isDockVisible
3840 ? 'translateY(-50%)'
3941 : 'translateX(calc(-150% - 10px)) translateY(-50%)' ;
4042 } else if ( DOCK_POSITION === 'right' ) {
41- style . right = `${ DOCK_MARGIN } px` ;
42- style . top = '50%' ;
43+ style . right = `${ DOCK_MARGIN } px` ;
44+ style . top = '50%' ;
4345 style . transform = isDockVisible
4446 ? 'translateY(-50%)'
4547 : 'translateX(calc(150% + 10px)) translateY(-50%)' ;
4648 } else {
47- // fallback: bottom
48- style . bottom = withSafeBottom ( DOCK_MARGIN ) ;
49- style . left = '50%' ;
49+ // fallback to bottom
50+ style . bottom = withSafeBottom ( DOCK_MARGIN ) ;
51+ style . left = '50%' ;
5052 style . transform = isDockVisible
5153 ? 'translateX(-50%)'
5254 : 'translateX(-50%) translateY(calc(150% + 10px))' ;
@@ -55,61 +57,44 @@ export const getOuterContainerStyle = (
5557 return style ;
5658} ;
5759
60+ /**
61+ * Returns the icons container style. We add a width transition here
62+ * so horizontal docks animate their width smoothly.
63+ */
5864export const getIconsContainerStyle = (
5965 isVerticalDock ,
6066 DOCK_POSITION ,
6167 ICON_SIZE ,
6268 containerDimension
6369) => {
6470 if ( isVerticalDock ) {
65- switch ( DOCK_POSITION ) {
66- case 'left' :
67- return {
68- position : 'relative' ,
69- display : 'flex' ,
70- flexDirection : 'column' ,
71- justifyContent : 'center' ,
72- alignItems : 'flex-start' ,
73- width : `${ ICON_SIZE } px` ,
74- height : `${ containerDimension } px` ,
75- transition :
76- 'width 0.3s var(--easing-flattened), height 0.3s var(--easing-flattened)' ,
77- } ;
78- case 'right' :
79- return {
80- position : 'relative' ,
81- display : 'flex' ,
82- flexDirection : 'column' ,
83- justifyContent : 'center' ,
84- alignItems : 'flex-end' ,
85- width : `${ ICON_SIZE } px` ,
86- height : `${ containerDimension } px` ,
87- transition :
88- 'width 0.3s var(--easing-flattened), height 0.3s var(--easing-flattened)' ,
89- } ;
90- default :
91- return {
92- position : 'relative' ,
93- display : 'flex' ,
94- flexDirection : 'column' ,
95- justifyContent : 'center' ,
96- alignItems : 'center' ,
97- width : `${ ICON_SIZE } px` ,
98- height : `${ containerDimension } px` ,
99- transition :
100- 'width 0.3s var(--easing-flattened), height 0.3s var(--easing-flattened)' ,
101- } ;
71+ // vertical docks still resize height instantly, but width is fixed
72+ const base = {
73+ position : 'relative' ,
74+ display : 'flex' ,
75+ flexDirection : 'column' ,
76+ justifyContent : 'center' ,
77+ width : `${ ICON_SIZE } px` ,
78+ height : `${ containerDimension } px` ,
79+ // no width transition needed in vertical mode
80+ } ;
81+ if ( DOCK_POSITION === 'left' ) {
82+ return { ...base , alignItems : 'flex-start' } ;
83+ } else if ( DOCK_POSITION === 'right' ) {
84+ return { ...base , alignItems : 'flex-end' } ;
85+ } else {
86+ return { ...base , alignItems : 'center' } ;
10287 }
10388 } else {
89+ // horizontal dock: width changes as containerDimension updates
10490 return {
10591 position : 'relative' ,
10692 display : 'flex' ,
10793 justifyContent : 'center' ,
10894 alignItems : 'flex-end' ,
10995 width : `${ containerDimension } px` ,
11096 height : `${ ICON_SIZE } px` ,
111- transition :
112- 'width 0.3s var(--easing-flattened), height 0.3s var(--easing-flattened)' ,
97+ transition : `width 0.3s ${ FLATTENED_EASING } ` ,
11398 } ;
11499 }
115100} ;
@@ -190,7 +175,7 @@ export const getIconContainerStyle = ({
190175 width : `${ ICON_SIZE } px` ,
191176 height : `${ ICON_SIZE } px` ,
192177 transition : shouldTransition
193- ? `${ INITIAL_TRANSITION } , opacity 0.3s var(--easing-flattened) `
178+ ? `${ INITIAL_TRANSITION } , opacity 0.3s ${ FLATTENED_EASING } `
194179 : NO_TRANSITION ,
195180 transform : `scale(${ scale } )` ,
196181 cursor : 'pointer' ,
0 commit comments