@@ -16,17 +16,13 @@ const props = withDefaults(defineProps<SplitPanelProps>(), {
1616 sizeUnit: ' %' ,
1717 direction: ' ltr' ,
1818 collapsible: false ,
19- transitionDuration: ' 0 ' ,
19+ transitionDuration: 0 ,
2020 transitionTimingFunctionCollapse: ' cubic-bezier(0.4, 0, 0.6, 1)' ,
2121 transitionTimingFunctionExpand: ' cubic-bezier(0, 0, 0.2, 1)' ,
2222 snapPoints : () => [],
2323 snapThreshold: 12 ,
2424});
2525
26- const emits = defineEmits <{
27- transitionend: [event : TransitionEvent ];
28- }>();
29-
3026/** Size of the primary panel in either percentages or pixels as defined by the sizeUnit property */
3127const size = defineModel <number >(' size' , { default: 50 });
3228
@@ -100,7 +96,17 @@ useResize(sizePercentage, {
10096 primary : () => props .primary ,
10197});
10298
103- const { onTransitionEnd, collapseTransitionState, toggle, expand, collapse } = useCollapse (collapsed , sizePercentage , emits );
99+ const {
100+ collapseTransitionState,
101+ toggle,
102+ expand,
103+ collapse,
104+ transitionDurationCss,
105+ } = useCollapse (
106+ collapsed ,
107+ sizePercentage ,
108+ { transitionDuration : () => props .transitionDuration },
109+ );
104110
105111defineExpose ({ collapse , expand , toggle });
106112 </script >
@@ -111,11 +117,9 @@ defineExpose({ collapse, expand, toggle });
111117 class =" sp-root"
112118 :class =" [
113119 `sp-${orientation}`,
114- `sp-${collapseTransitionState}`,
115- { 'sp-collapsed': collapsed, 'sp-dragging': isDragging },
120+ { 'sp-collapsed': collapsed, 'sp-dragging': isDragging, [`sp-${collapseTransitionState}`]: collapseTransitionState },
116121 ]"
117122 data-testid =" root"
118- @transitionend =" onTransitionEnd"
119123 >
120124 <div class =" sp-start" :class =" ui?.start" data-testid =" start" >
121125 <slot name =" start" />
@@ -148,18 +152,34 @@ defineExpose({ collapse, expand, toggle });
148152.sp-root {
149153 display : grid ;
150154
155+ &.sp-collapsing {
156+ transition-duration : v-bind(transitionDurationCss);
157+ transition-timing-function : v-bind(transitionTimingFunctionCollapse);
158+ }
159+
160+ &.sp-expanding {
161+ transition-duration : v-bind(transitionDurationCss);
162+ transition-timing-function : v-bind(transitionTimingFunctionExpand);
163+ }
164+
151165 &.sp-horizontal {
152- transition-property : grid-template-columns;
153166 grid-template-columns : v-bind(gridTemplate);
154167
168+ &.sp-collapsing , &.sp-expanding {
169+ transition-property : grid-template-columns;
170+ }
171+
155172 &.sp-dragging {
156173 cursor : ew-resize ;
157174 }
158175 }
159176
160177 &.sp-vertical {
161178 grid-template-rows : v-bind(gridTemplate);
162- transition-property : grid-template-rows;
179+
180+ &.sp-collapsing , &.sp-expanding {
181+ transition-property : grid-template-rows;
182+ }
163183
164184 &.sp-dragging {
165185 cursor : ns-resize ;
@@ -169,16 +189,6 @@ defineExpose({ collapse, expand, toggle });
169189 &.sp-dragging {
170190 user-select : none ;
171191 }
172-
173- &.sp-collapsing {
174- transition-duration : v-bind(transitionDuration);
175- transition-timing-function : v-bind(transitionTimingFunctionCollapse);
176- }
177-
178- &.sp-expanding {
179- transition-duration : v-bind(transitionDuration);
180- transition-timing-function : v-bind(transitionTimingFunctionExpand);
181- }
182192}
183193
184194.sp-start , .sp-end {
0 commit comments