1
1
import addEventListenerWrap from '../../vc-util/Dom/addEventListener' ;
2
2
import type { EventHandler } from '../../_util/EventInterface' ;
3
3
import raf from '../../_util/raf' ;
4
- import {
5
- defineComponent ,
6
- onUnmounted ,
7
- nextTick ,
8
- watch ,
9
- computed ,
10
- ref ,
11
- watchEffect ,
12
- getCurrentInstance ,
13
- onMounted ,
14
- } from 'vue' ;
4
+ import { defineComponent , onUnmounted , computed , ref , watchEffect , getCurrentInstance } from 'vue' ;
15
5
import type { PropType } from 'vue' ;
16
6
import devWarning from '../../vc-util/devWarning' ;
17
7
import type { ColumnType } from '../interface' ;
@@ -81,13 +71,7 @@ export default defineComponent({
81
71
: Infinity ;
82
72
} ) ;
83
73
const instance = getCurrentInstance ( ) ;
84
- // eslint-disable-next-line vue/no-setup-props-destructure
85
- let baseWidth = props . width ;
86
- onMounted ( ( ) => {
87
- nextTick ( ( ) => {
88
- baseWidth = instance . vnode . el ?. parentNode ?. getBoundingClientRect ( ) . width ;
89
- } ) ;
90
- } ) ;
74
+ let baseWidth = 0 ;
91
75
const dragging = ref ( false ) ;
92
76
let rafId : number ;
93
77
const updateWidth = ( e : HandleEvent ) => {
@@ -117,15 +101,12 @@ export default defineComponent({
117
101
const handleStop = ( e : HandleEvent ) => {
118
102
dragging . value = false ;
119
103
updateWidth ( e ) ;
120
- nextTick ( ( ) => {
121
- baseWidth = instance . vnode . el ?. parentNode ?. getBoundingClientRect ( ) . width ;
122
- } ) ;
123
104
removeEvents ( ) ;
124
105
} ;
125
106
const handleStart = ( e : HandleEvent , eventsFor : any ) => {
126
107
dragging . value = true ;
127
108
removeEvents ( ) ;
128
-
109
+ baseWidth = instance . vnode . el . parentNode . getBoundingClientRect ( ) . width ;
129
110
if ( e instanceof MouseEvent && e . which !== 1 ) {
130
111
return ;
131
112
}
@@ -150,16 +131,6 @@ export default defineComponent({
150
131
e . preventDefault ( ) ;
151
132
} ;
152
133
153
- watch (
154
- ( ) => props . width ,
155
- ( ) => {
156
- if ( ! dragging . value ) {
157
- baseWidth = props . width ;
158
- }
159
- } ,
160
- { immediate : true } ,
161
- ) ;
162
-
163
134
return ( ) => {
164
135
const { prefixCls } = props ;
165
136
const touchEvents = {
0 commit comments