@vxe-ui/core 4.4.35 → 4.4.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/all.esm.js CHANGED
@@ -1,8 +1,8 @@
1
- import { h, reactive, computed, inject, provide, createCommentVNode } from 'vue';
1
+ import { h, reactive, ref, computed, inject, provide, createCommentVNode } from 'vue';
2
2
  import XEUtils from 'xe-utils';
3
3
  import DomZIndex from 'dom-zindex';
4
4
 
5
- const coreVersion = "4.4.35";
5
+ const coreVersion = "4.4.36";
6
6
  const VxeCore = {
7
7
  coreVersion,
8
8
  uiVersion: '',
@@ -402,7 +402,7 @@ function createLog(type, name) {
402
402
  return msg;
403
403
  };
404
404
  }
405
- const version = "4.4.35";
405
+ const version = "4.4.36";
406
406
  const log = {
407
407
  create: createLog,
408
408
  warn: createLog('warn', `v${version}`),
@@ -1181,8 +1181,13 @@ const popperUtils = {
1181
1181
 
1182
1182
  const hooks = new Store();
1183
1183
 
1184
+ const { getThumbOffsetSize, getThumbSize, getScrollFromClick, getScrollFromDrag } = scrollbarUtils;
1185
+ /**
1186
+ * 组件尺寸上下文
1187
+ * @param props
1188
+ * @returns
1189
+ */
1184
1190
  function useSize(props) {
1185
- // 组件尺寸上下文
1186
1191
  const xeSizeInfo = inject('xeSizeInfo', null);
1187
1192
  const computeSize = computed(() => {
1188
1193
  const { size } = props;
@@ -1191,8 +1196,25 @@ function useSize(props) {
1191
1196
  provide('xeSizeInfo', computeSize);
1192
1197
  return { computeSize };
1193
1198
  }
1199
+ /**
1200
+ * 权限码处理
1201
+ * @param props
1202
+ * @returns
1203
+ */
1204
+ function usePermission(props) {
1205
+ const computePermissionInfo = computed(() => {
1206
+ return handleCheckInfo(props.permissionCode, props.permissionMethod);
1207
+ });
1208
+ return {
1209
+ computePermissionInfo
1210
+ };
1211
+ }
1212
+ /**
1213
+ * 虚拟滚动条是否启用
1214
+ * @param props
1215
+ * @returns
1216
+ */
1194
1217
  function useVScrollbar(props) {
1195
- // 组件虚拟滚动条
1196
1218
  const xeScrollbarInfo = inject('xeScrollbarInfo', null);
1197
1219
  const computeIsVScrollbar = computed(() => {
1198
1220
  const { useScrollbar } = props;
@@ -1201,18 +1223,196 @@ function useVScrollbar(props) {
1201
1223
  provide('xeScrollbarInfo', computeIsVScrollbar);
1202
1224
  return { computeIsVScrollbar };
1203
1225
  }
1204
- function usePermission(props) {
1205
- const computePermissionInfo = computed(() => {
1206
- return handleCheckInfo(props.permissionCode, props.permissionMethod);
1207
- });
1226
+ /**
1227
+ * 初始化虚拟滚动条
1228
+ * @param reactData
1229
+ * @param internalData
1230
+ * @param refViewElem
1231
+ * @returns
1232
+ */
1233
+ const useInitVScrollbar = ($xeVM) => {
1234
+ const { reactData, internalData } = $xeVM;
1235
+ const refTrackXElem = ref();
1236
+ const refTrackYElem = ref();
1237
+ const refThumbXElem = ref();
1238
+ const refThumbYElem = ref();
1239
+ const updateThumbSize = () => {
1240
+ const viewEl = $xeVM.getScrollViewElem();
1241
+ if (!viewEl) {
1242
+ return;
1243
+ }
1244
+ if (!viewEl.clientHeight || !viewEl.clientHeight) {
1245
+ return;
1246
+ }
1247
+ const trackXEl = refTrackXElem.value;
1248
+ const xThumbWidth = trackXEl ? getThumbSize(viewEl.clientWidth, viewEl.scrollWidth, trackXEl.clientWidth) : 0;
1249
+ const thumbXElem = refThumbXElem.value;
1250
+ if (thumbXElem) {
1251
+ thumbXElem.style.width = xThumbWidth + 'px';
1252
+ }
1253
+ reactData.xThumbWidth = xThumbWidth;
1254
+ const trackYEl = refTrackYElem.value;
1255
+ const yThumbHeight = trackYEl ? getThumbSize(viewEl.clientHeight, viewEl.scrollHeight, trackYEl.clientHeight) : 0;
1256
+ const thumbYElem = refThumbYElem.value;
1257
+ if (thumbYElem) {
1258
+ thumbYElem.style.height = yThumbHeight + 'px';
1259
+ }
1260
+ reactData.yThumbHeight = yThumbHeight;
1261
+ };
1262
+ const updateThumbOffset = () => {
1263
+ const viewEl = $xeVM.getScrollViewElem();
1264
+ if (!viewEl) {
1265
+ return;
1266
+ }
1267
+ if (!viewEl.clientHeight || !viewEl.clientHeight) {
1268
+ return;
1269
+ }
1270
+ const { xThumbWidth, yThumbHeight } = reactData;
1271
+ const trackXEl = refTrackXElem.value;
1272
+ const thumbXElem = refThumbXElem.value;
1273
+ const xThumbLeft = trackXEl && xThumbWidth ? getThumbOffsetSize(viewEl.scrollLeft, viewEl.clientWidth, viewEl.scrollWidth, trackXEl.clientWidth, xThumbWidth) : 0;
1274
+ internalData.xThumbLeft = xThumbLeft;
1275
+ if (thumbXElem && xThumbWidth) {
1276
+ thumbXElem.style.width = xThumbWidth + 'px';
1277
+ thumbXElem.style.transform = `translateX(${xThumbLeft}px)`;
1278
+ }
1279
+ const trackYEl = refTrackYElem.value;
1280
+ const thumbYElem = refThumbYElem.value;
1281
+ const yThumbTop = trackYEl && yThumbHeight ? getThumbOffsetSize(viewEl.scrollTop, viewEl.clientHeight, viewEl.scrollHeight, trackYEl.clientHeight, yThumbHeight) : 0;
1282
+ internalData.yThumbTop = yThumbTop;
1283
+ if (thumbYElem && yThumbHeight) {
1284
+ thumbYElem.style.height = yThumbHeight + 'px';
1285
+ thumbYElem.style.transform = `translateY(${yThumbTop}px)`;
1286
+ }
1287
+ };
1288
+ const clickTrackXEvent = (evnt) => {
1289
+ const trackEl = evnt.currentTarget;
1290
+ if (trackEl !== evnt.target) {
1291
+ return;
1292
+ }
1293
+ const viewEl = $xeVM.getScrollViewElem();
1294
+ if (!viewEl) {
1295
+ return;
1296
+ }
1297
+ const { xThumbWidth } = reactData;
1298
+ const trackRect = trackEl.getBoundingClientRect();
1299
+ viewEl.scrollTo({
1300
+ left: getScrollFromClick(evnt.clientX - trackRect.left, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth),
1301
+ behavior: 'auto'
1302
+ });
1303
+ };
1304
+ const clickTrackYEvent = (evnt) => {
1305
+ const trackEl = evnt.currentTarget;
1306
+ if (trackEl !== evnt.target) {
1307
+ return;
1308
+ }
1309
+ const viewEl = $xeVM.getScrollViewElem();
1310
+ if (!viewEl) {
1311
+ return;
1312
+ }
1313
+ const { yThumbHeight } = reactData;
1314
+ const trackRect = trackEl.getBoundingClientRect();
1315
+ viewEl.scrollTo({
1316
+ top: getScrollFromClick(evnt.clientY - trackRect.top, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight),
1317
+ behavior: 'auto'
1318
+ });
1319
+ };
1320
+ const pointerdownThumbXEvent = (evnt) => {
1321
+ const thumbEl = evnt.currentTarget;
1322
+ internalData.isThumbDrag = true;
1323
+ thumbEl.setPointerCapture(evnt.pointerId);
1324
+ const viewEl = $xeVM.getScrollViewElem();
1325
+ if (!viewEl) {
1326
+ return;
1327
+ }
1328
+ const { xThumbWidth } = reactData;
1329
+ const trackEl = thumbEl.parentElement;
1330
+ const trackRect = trackEl.getBoundingClientRect();
1331
+ const pointerPosition = evnt.clientX - trackRect.left;
1332
+ // 记录 thumb 的偏移
1333
+ const thumbOffset = getThumbOffsetSize(viewEl.scrollLeft, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth);
1334
+ internalData.thumbDragOffset = pointerPosition - thumbOffset;
1335
+ };
1336
+ const pointermoveThumbXEvent = (evnt) => {
1337
+ const thumbEl = evnt.currentTarget;
1338
+ if (!thumbEl.hasPointerCapture(evnt.pointerId)) {
1339
+ return;
1340
+ }
1341
+ const { isThumbDrag, thumbDragOffset } = internalData;
1342
+ if (isThumbDrag) {
1343
+ const viewEl = $xeVM.getScrollViewElem();
1344
+ if (!viewEl) {
1345
+ return;
1346
+ }
1347
+ const { xThumbWidth } = reactData;
1348
+ const thumbEl = evnt.currentTarget;
1349
+ const trackEl = thumbEl.parentElement;
1350
+ const trackRect = trackEl.getBoundingClientRect();
1351
+ // 更新偏移
1352
+ viewEl.scrollLeft = getScrollFromDrag(evnt.clientX - trackRect.left, thumbDragOffset, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth);
1353
+ }
1354
+ };
1355
+ const cleatPointerThumbEvent = (evnt) => {
1356
+ const thumbEl = evnt.currentTarget;
1357
+ thumbEl.releasePointerCapture(evnt.pointerId);
1358
+ internalData.isThumbDrag = false;
1359
+ };
1360
+ const pointerdownThumbYEvent = (evnt) => {
1361
+ const thumbEl = evnt.currentTarget;
1362
+ internalData.isThumbDrag = true;
1363
+ thumbEl.setPointerCapture(evnt.pointerId);
1364
+ const viewEl = $xeVM.getScrollViewElem();
1365
+ if (!viewEl) {
1366
+ return;
1367
+ }
1368
+ const { yThumbHeight } = reactData;
1369
+ const trackEl = thumbEl.parentElement;
1370
+ const trackRect = trackEl.getBoundingClientRect();
1371
+ const pointerPosition = evnt.clientY - trackRect.top;
1372
+ // 记录 thumb 的偏移
1373
+ const thumbOffset = getThumbOffsetSize(viewEl.scrollTop, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight);
1374
+ internalData.thumbDragOffset = pointerPosition - thumbOffset;
1375
+ };
1376
+ const pointermoveThumbYEvent = (evnt) => {
1377
+ const thumbEl = evnt.currentTarget;
1378
+ if (!thumbEl.hasPointerCapture(evnt.pointerId)) {
1379
+ return;
1380
+ }
1381
+ const { isThumbDrag, thumbDragOffset } = internalData;
1382
+ if (isThumbDrag) {
1383
+ const viewEl = $xeVM.getScrollViewElem();
1384
+ if (!viewEl) {
1385
+ return;
1386
+ }
1387
+ const { yThumbHeight } = reactData;
1388
+ const thumbEl = evnt.currentTarget;
1389
+ const trackEl = thumbEl.parentElement;
1390
+ const trackRect = trackEl.getBoundingClientRect();
1391
+ // 更新偏移
1392
+ viewEl.scrollTop = getScrollFromDrag(evnt.clientY - trackRect.top, thumbDragOffset, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight);
1393
+ }
1394
+ };
1208
1395
  return {
1209
- computePermissionInfo
1396
+ refTrackXElem,
1397
+ refTrackYElem,
1398
+ refThumbXElem,
1399
+ refThumbYElem,
1400
+ updateThumbSize,
1401
+ updateThumbOffset,
1402
+ clickTrackXEvent,
1403
+ clickTrackYEvent,
1404
+ pointerdownThumbXEvent,
1405
+ pointermoveThumbXEvent,
1406
+ cleatPointerThumbEvent,
1407
+ pointerdownThumbYEvent,
1408
+ pointermoveThumbYEvent
1210
1409
  };
1211
- }
1410
+ };
1212
1411
  const useFns = {
1213
1412
  useSize,
1214
1413
  useVScrollbar,
1215
- usePermission
1414
+ usePermission,
1415
+ useInitVScrollbar
1216
1416
  };
1217
1417
 
1218
1418
  const installedPlugins = [];
@@ -1299,4 +1499,4 @@ const VxeUI = Object.assign(VxeCore, {
1299
1499
  });
1300
1500
  setTheme();
1301
1501
 
1302
- export { GLOBAL_EVENT_KEYS, VxeCore, VxeUI, baseUtils, checkVersion, clipboard, commands, component, coreVersion, createEvent, VxeUI as default, domUtils, formats, getComponent, getConfig, getI18n, getIcon, getLanguage, getSlotVNs, getTheme, globalEvents, globalResize, globalStore, handleCheckInfo, hasComponent, hasLanguage, hooks, interceptor, log, menus, permission, popperUtils, renderCustomIcon, renderEmptyElement, renderGlobalIcon, renderer, scrollbarUtils, setConfig, setI18n, setIcon, setLanguage, setTheme, use, useFns, usePermission, useSize, useVScrollbar, validators };
1502
+ export { GLOBAL_EVENT_KEYS, VxeCore, VxeUI, baseUtils, checkVersion, clipboard, commands, component, coreVersion, createEvent, VxeUI as default, domUtils, formats, getComponent, getConfig, getI18n, getIcon, getLanguage, getSlotVNs, getTheme, globalEvents, globalResize, globalStore, handleCheckInfo, hasComponent, hasLanguage, hooks, interceptor, log, menus, permission, popperUtils, renderCustomIcon, renderEmptyElement, renderGlobalIcon, renderer, scrollbarUtils, setConfig, setI18n, setIcon, setLanguage, setTheme, use, useFns, useInitVScrollbar, usePermission, useSize, useVScrollbar, validators };
package/es/src/core.js CHANGED
@@ -1,4 +1,4 @@
1
- export const coreVersion = "4.4.35";
1
+ export const coreVersion = "4.4.36";
2
2
  export const VxeCore = {
3
3
  coreVersion,
4
4
  uiVersion: '',
package/es/src/log.js CHANGED
@@ -6,7 +6,7 @@ function createLog(type, name) {
6
6
  return msg;
7
7
  };
8
8
  }
9
- const version = "4.4.35";
9
+ const version = "4.4.36";
10
10
  export const log = {
11
11
  create: createLog,
12
12
  warn: createLog('warn', `v${version}`),
package/es/src/useFns.js CHANGED
@@ -1,8 +1,14 @@
1
1
  import XEUtils from 'xe-utils';
2
- import { computed, inject, provide } from 'vue';
2
+ import { computed, ref, inject, provide } from 'vue';
3
3
  import { handleCheckInfo } from './permission';
4
+ import { scrollbarUtils } from './scrollbar-utils';
5
+ const { getThumbOffsetSize, getThumbSize, getScrollFromClick, getScrollFromDrag } = scrollbarUtils;
6
+ /**
7
+ * 组件尺寸上下文
8
+ * @param props
9
+ * @returns
10
+ */
4
11
  export function useSize(props) {
5
- // 组件尺寸上下文
6
12
  const xeSizeInfo = inject('xeSizeInfo', null);
7
13
  const computeSize = computed(() => {
8
14
  const { size } = props;
@@ -11,8 +17,25 @@ export function useSize(props) {
11
17
  provide('xeSizeInfo', computeSize);
12
18
  return { computeSize };
13
19
  }
20
+ /**
21
+ * 权限码处理
22
+ * @param props
23
+ * @returns
24
+ */
25
+ export function usePermission(props) {
26
+ const computePermissionInfo = computed(() => {
27
+ return handleCheckInfo(props.permissionCode, props.permissionMethod);
28
+ });
29
+ return {
30
+ computePermissionInfo
31
+ };
32
+ }
33
+ /**
34
+ * 虚拟滚动条是否启用
35
+ * @param props
36
+ * @returns
37
+ */
14
38
  export function useVScrollbar(props) {
15
- // 组件虚拟滚动条
16
39
  const xeScrollbarInfo = inject('xeScrollbarInfo', null);
17
40
  const computeIsVScrollbar = computed(() => {
18
41
  const { useScrollbar } = props;
@@ -21,16 +44,194 @@ export function useVScrollbar(props) {
21
44
  provide('xeScrollbarInfo', computeIsVScrollbar);
22
45
  return { computeIsVScrollbar };
23
46
  }
24
- export function usePermission(props) {
25
- const computePermissionInfo = computed(() => {
26
- return handleCheckInfo(props.permissionCode, props.permissionMethod);
27
- });
47
+ /**
48
+ * 初始化虚拟滚动条
49
+ * @param reactData
50
+ * @param internalData
51
+ * @param refViewElem
52
+ * @returns
53
+ */
54
+ export const useInitVScrollbar = ($xeVM) => {
55
+ const { reactData, internalData } = $xeVM;
56
+ const refTrackXElem = ref();
57
+ const refTrackYElem = ref();
58
+ const refThumbXElem = ref();
59
+ const refThumbYElem = ref();
60
+ const updateThumbSize = () => {
61
+ const viewEl = $xeVM.getScrollViewElem();
62
+ if (!viewEl) {
63
+ return;
64
+ }
65
+ if (!viewEl.clientHeight || !viewEl.clientHeight) {
66
+ return;
67
+ }
68
+ const trackXEl = refTrackXElem.value;
69
+ const xThumbWidth = trackXEl ? getThumbSize(viewEl.clientWidth, viewEl.scrollWidth, trackXEl.clientWidth) : 0;
70
+ const thumbXElem = refThumbXElem.value;
71
+ if (thumbXElem) {
72
+ thumbXElem.style.width = xThumbWidth + 'px';
73
+ }
74
+ reactData.xThumbWidth = xThumbWidth;
75
+ const trackYEl = refTrackYElem.value;
76
+ const yThumbHeight = trackYEl ? getThumbSize(viewEl.clientHeight, viewEl.scrollHeight, trackYEl.clientHeight) : 0;
77
+ const thumbYElem = refThumbYElem.value;
78
+ if (thumbYElem) {
79
+ thumbYElem.style.height = yThumbHeight + 'px';
80
+ }
81
+ reactData.yThumbHeight = yThumbHeight;
82
+ };
83
+ const updateThumbOffset = () => {
84
+ const viewEl = $xeVM.getScrollViewElem();
85
+ if (!viewEl) {
86
+ return;
87
+ }
88
+ if (!viewEl.clientHeight || !viewEl.clientHeight) {
89
+ return;
90
+ }
91
+ const { xThumbWidth, yThumbHeight } = reactData;
92
+ const trackXEl = refTrackXElem.value;
93
+ const thumbXElem = refThumbXElem.value;
94
+ const xThumbLeft = trackXEl && xThumbWidth ? getThumbOffsetSize(viewEl.scrollLeft, viewEl.clientWidth, viewEl.scrollWidth, trackXEl.clientWidth, xThumbWidth) : 0;
95
+ internalData.xThumbLeft = xThumbLeft;
96
+ if (thumbXElem && xThumbWidth) {
97
+ thumbXElem.style.width = xThumbWidth + 'px';
98
+ thumbXElem.style.transform = `translateX(${xThumbLeft}px)`;
99
+ }
100
+ const trackYEl = refTrackYElem.value;
101
+ const thumbYElem = refThumbYElem.value;
102
+ const yThumbTop = trackYEl && yThumbHeight ? getThumbOffsetSize(viewEl.scrollTop, viewEl.clientHeight, viewEl.scrollHeight, trackYEl.clientHeight, yThumbHeight) : 0;
103
+ internalData.yThumbTop = yThumbTop;
104
+ if (thumbYElem && yThumbHeight) {
105
+ thumbYElem.style.height = yThumbHeight + 'px';
106
+ thumbYElem.style.transform = `translateY(${yThumbTop}px)`;
107
+ }
108
+ };
109
+ const clickTrackXEvent = (evnt) => {
110
+ const trackEl = evnt.currentTarget;
111
+ if (trackEl !== evnt.target) {
112
+ return;
113
+ }
114
+ const viewEl = $xeVM.getScrollViewElem();
115
+ if (!viewEl) {
116
+ return;
117
+ }
118
+ const { xThumbWidth } = reactData;
119
+ const trackRect = trackEl.getBoundingClientRect();
120
+ viewEl.scrollTo({
121
+ left: getScrollFromClick(evnt.clientX - trackRect.left, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth),
122
+ behavior: 'auto'
123
+ });
124
+ };
125
+ const clickTrackYEvent = (evnt) => {
126
+ const trackEl = evnt.currentTarget;
127
+ if (trackEl !== evnt.target) {
128
+ return;
129
+ }
130
+ const viewEl = $xeVM.getScrollViewElem();
131
+ if (!viewEl) {
132
+ return;
133
+ }
134
+ const { yThumbHeight } = reactData;
135
+ const trackRect = trackEl.getBoundingClientRect();
136
+ viewEl.scrollTo({
137
+ top: getScrollFromClick(evnt.clientY - trackRect.top, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight),
138
+ behavior: 'auto'
139
+ });
140
+ };
141
+ const pointerdownThumbXEvent = (evnt) => {
142
+ const thumbEl = evnt.currentTarget;
143
+ internalData.isThumbDrag = true;
144
+ thumbEl.setPointerCapture(evnt.pointerId);
145
+ const viewEl = $xeVM.getScrollViewElem();
146
+ if (!viewEl) {
147
+ return;
148
+ }
149
+ const { xThumbWidth } = reactData;
150
+ const trackEl = thumbEl.parentElement;
151
+ const trackRect = trackEl.getBoundingClientRect();
152
+ const pointerPosition = evnt.clientX - trackRect.left;
153
+ // 记录 thumb 的偏移
154
+ const thumbOffset = getThumbOffsetSize(viewEl.scrollLeft, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth);
155
+ internalData.thumbDragOffset = pointerPosition - thumbOffset;
156
+ };
157
+ const pointermoveThumbXEvent = (evnt) => {
158
+ const thumbEl = evnt.currentTarget;
159
+ if (!thumbEl.hasPointerCapture(evnt.pointerId)) {
160
+ return;
161
+ }
162
+ const { isThumbDrag, thumbDragOffset } = internalData;
163
+ if (isThumbDrag) {
164
+ const viewEl = $xeVM.getScrollViewElem();
165
+ if (!viewEl) {
166
+ return;
167
+ }
168
+ const { xThumbWidth } = reactData;
169
+ const thumbEl = evnt.currentTarget;
170
+ const trackEl = thumbEl.parentElement;
171
+ const trackRect = trackEl.getBoundingClientRect();
172
+ // 更新偏移
173
+ viewEl.scrollLeft = getScrollFromDrag(evnt.clientX - trackRect.left, thumbDragOffset, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth);
174
+ }
175
+ };
176
+ const cleatPointerThumbEvent = (evnt) => {
177
+ const thumbEl = evnt.currentTarget;
178
+ thumbEl.releasePointerCapture(evnt.pointerId);
179
+ internalData.isThumbDrag = false;
180
+ };
181
+ const pointerdownThumbYEvent = (evnt) => {
182
+ const thumbEl = evnt.currentTarget;
183
+ internalData.isThumbDrag = true;
184
+ thumbEl.setPointerCapture(evnt.pointerId);
185
+ const viewEl = $xeVM.getScrollViewElem();
186
+ if (!viewEl) {
187
+ return;
188
+ }
189
+ const { yThumbHeight } = reactData;
190
+ const trackEl = thumbEl.parentElement;
191
+ const trackRect = trackEl.getBoundingClientRect();
192
+ const pointerPosition = evnt.clientY - trackRect.top;
193
+ // 记录 thumb 的偏移
194
+ const thumbOffset = getThumbOffsetSize(viewEl.scrollTop, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight);
195
+ internalData.thumbDragOffset = pointerPosition - thumbOffset;
196
+ };
197
+ const pointermoveThumbYEvent = (evnt) => {
198
+ const thumbEl = evnt.currentTarget;
199
+ if (!thumbEl.hasPointerCapture(evnt.pointerId)) {
200
+ return;
201
+ }
202
+ const { isThumbDrag, thumbDragOffset } = internalData;
203
+ if (isThumbDrag) {
204
+ const viewEl = $xeVM.getScrollViewElem();
205
+ if (!viewEl) {
206
+ return;
207
+ }
208
+ const { yThumbHeight } = reactData;
209
+ const thumbEl = evnt.currentTarget;
210
+ const trackEl = thumbEl.parentElement;
211
+ const trackRect = trackEl.getBoundingClientRect();
212
+ // 更新偏移
213
+ viewEl.scrollTop = getScrollFromDrag(evnt.clientY - trackRect.top, thumbDragOffset, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight);
214
+ }
215
+ };
28
216
  return {
29
- computePermissionInfo
217
+ refTrackXElem,
218
+ refTrackYElem,
219
+ refThumbXElem,
220
+ refThumbYElem,
221
+ updateThumbSize,
222
+ updateThumbOffset,
223
+ clickTrackXEvent,
224
+ clickTrackYEvent,
225
+ pointerdownThumbXEvent,
226
+ pointermoveThumbXEvent,
227
+ cleatPointerThumbEvent,
228
+ pointerdownThumbYEvent,
229
+ pointermoveThumbYEvent
30
230
  };
31
- }
231
+ };
32
232
  export const useFns = {
33
233
  useSize,
34
234
  useVScrollbar,
35
- usePermission
235
+ usePermission,
236
+ useInitVScrollbar
36
237
  };