Skip to content

Commit c8600d9

Browse files
fix!: revise transition to be number in ms (#45)
Co-authored-by: Copilot <[email protected]>
1 parent 04f45cd commit c8600d9

File tree

7 files changed

+96
-108
lines changed

7 files changed

+96
-108
lines changed

docs/components/example/ExampleTransitions.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { SplitPanel } from '@directus/vue-split-panel';
1111
:size="350"
1212
:max-size="500"
1313
:collapse-threshold="50"
14-
transition-duration="150ms"
14+
:transition-duration="150"
1515
>
1616
<template #start>
1717
<div class="h-16 bg-orange-100 dark:bg-orange-900 flex items-center justify-center">Panel A</div>

docs/content/1.getting-started/2.usage.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ import { SplitPanel } from '@directus/vue-split-panel';
9797
How far to drag beyond the minSize to collapse/expand the primary panel.
9898
::
9999

100-
::field{name="transitionDuration" type="string"}
101-
Duration of the collapse/expand transition. Accepts a CSS duration value.
102-
Defaults to `"0"`
100+
::field{name="transitionDuration" type="number"}
101+
Duration of the collapse/expand transition in ms.
102+
Defaults to `0`
103103
::
104104

105105
::field{name="transitionTimingFunctionExpand" type="string"}
@@ -127,13 +127,6 @@ import { SplitPanel } from '@directus/vue-split-panel';
127127
::
128128
::
129129

130-
### Emits
131-
::field-group
132-
::field{name="transitionend" type="(event: TransitionEvent) => void"}
133-
The event triggered when the transition end.
134-
::
135-
::
136-
137130
## Examples
138131

139132
### % / Pixels
@@ -434,7 +427,7 @@ import { SplitPanel } from '@directus/vue-split-panel';
434427
:size="350"
435428
:max-size="500"
436429
:collapse-threshold="50"
437-
transition-duration="150ms"
430+
:transition-duration="150"
438431
>
439432
<template #start>
440433
<div class="h-16 bg-orange-100 dark:bg-orange-900 flex items-center justify-center">Panel A</div>

packages/vue-split-panel/playground/src/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const collapsed = ref(false);
1616
:min-size="250"
1717
:max-size="400"
1818
size-unit="px"
19+
:transition-duration="200"
1920
:ui="{
2021
divider: 'my-custom-class',
2122
}"

packages/vue-split-panel/src/SplitPanel.vue

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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 */
3127
const 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
105111
defineExpose({ 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

Comments
 (0)