@@ -63,6 +63,7 @@ export default {
6363 return {
6464 maxHandlePos: 0 ,
6565 dragging: false ,
66+ pointerId: null ,
6667 initialHandlePos: 0 ,
6768 initialMousePosY: 0 ,
6869 yOffset: 0 ,
@@ -96,27 +97,31 @@ export default {
9697 },
9798
9899 beforeUnmount () {
99- this .resizeObserver .disconnect ();
100+ this .resizeObserver ? .disconnect ();
100101 },
101102
102103 methods: {
103104 updateMaxHandlePos () {
105+ if (! this .$refs .handleContainer ) return ;
104106 this .maxHandlePos =
105107 this .$refs .handleContainer .clientHeight - this .handleHeight ;
106108 },
107109
108110 onDragStart (ev ) {
111+ const container = this .$refs .handleContainer ;
112+ if (! container) return ;
109113 ev .preventDefault ();
110114
111115 this .dragging = true ;
116+ this .pointerId = ev .pointerId ;
112117 this .initialMousePosY = ev .pageY ;
113118
114119 if (ev .target === this .$refs .handle ) {
115120 const handleStyles = window .getComputedStyle (this .$refs .handle );
116121 this .initialHandlePos = getYOffsetFromTransform (handleStyles .transform );
117122 } else {
118123 // move handle to mouse pos
119- const { y } = this . $refs . handleContainer .getBoundingClientRect ();
124+ const { y } = container .getBoundingClientRect ();
120125 this .initialHandlePos = Math .max (
121126 0 ,
122127 Math .min (this .maxHandlePos , ev .pageY - y - this .handleHeight / 2 )
@@ -127,11 +132,12 @@ export default {
127132
128133 this .yOffset = 0 ;
129134
130- this . $refs . handleContainer .setPointerCapture (ev .pointerId );
135+ container .setPointerCapture (ev .pointerId );
131136 },
132137
133138 onDragMove (ev ) {
134- if (! this .$refs .handleContainer .hasPointerCapture (ev .pointerId )) return ;
139+ const container = this .$refs .handleContainer ;
140+ if (! container? .hasPointerCapture (ev .pointerId )) return ;
135141 ev .preventDefault ();
136142
137143 this .yOffset = ev .pageY - this .initialMousePosY ;
@@ -140,11 +146,18 @@ export default {
140146 },
141147
142148 onDragEnd (ev ) {
143- if (! this .$refs .handleContainer .hasPointerCapture (ev .pointerId )) return ;
144- ev .preventDefault ();
145- this .$refs .handleContainer .releasePointerCapture (ev .pointerId );
149+ const container = this .$refs .handleContainer ;
150+ if (ev .pointerId !== this .pointerId ) return ;
151+ const captured = container? .hasPointerCapture (ev .pointerId );
152+ if (captured) {
153+ ev .preventDefault ();
154+ container .releasePointerCapture (ev .pointerId );
155+ }
146156
147157 this .dragging = false ;
158+ this .pointerId = null ;
159+ if (! captured) return ;
160+
148161 const slice = this .getNearestSlice (this .handlePosition );
149162 this .$emit (' update:modelValue' , slice);
150163 },
0 commit comments