vxe-pc-ui 4.18.21 → 4.18.23

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.
Files changed (84) hide show
  1. package/dist/all.esm.js +1638 -1048
  2. package/dist/style.css +1 -1
  3. package/dist/style.min.css +1 -1
  4. package/es/components.js +3 -0
  5. package/es/icon/style.css +1 -1
  6. package/es/result/src/result.js +1 -1
  7. package/es/scrollbar/index.js +12 -0
  8. package/es/scrollbar/src/scrollbar.js +520 -0
  9. package/es/scrollbar/src/util.js +54 -0
  10. package/es/scrollbar/style.css +101 -0
  11. package/es/scrollbar/style.min.css +1 -0
  12. package/es/style.css +1 -1
  13. package/es/style.min.css +1 -1
  14. package/es/ui/index.js +10 -1
  15. package/es/ui/src/log.js +1 -1
  16. package/es/upload/style.css +5 -3
  17. package/es/upload/style.min.css +1 -1
  18. package/es/vxe-scrollbar/index.js +3 -0
  19. package/es/vxe-scrollbar/style.css +101 -0
  20. package/es/vxe-scrollbar/style.min.css +1 -0
  21. package/es/vxe-upload/style.css +5 -3
  22. package/es/vxe-upload/style.min.css +1 -1
  23. package/lib/components.js +13 -1
  24. package/lib/components.min.js +1 -1
  25. package/lib/icon/style/style.css +1 -1
  26. package/lib/icon/style/style.min.css +1 -1
  27. package/lib/index.umd.js +697 -6
  28. package/lib/index.umd.min.js +1 -1
  29. package/lib/result/src/result.js +1 -1
  30. package/lib/result/src/result.min.js +1 -1
  31. package/lib/scrollbar/index.js +19 -0
  32. package/lib/scrollbar/index.min.js +1 -0
  33. package/lib/scrollbar/src/scrollbar.js +560 -0
  34. package/lib/scrollbar/src/scrollbar.min.js +1 -0
  35. package/lib/scrollbar/src/util.js +63 -0
  36. package/lib/scrollbar/src/util.min.js +1 -0
  37. package/lib/scrollbar/style/index.js +1 -0
  38. package/lib/scrollbar/style/style.css +101 -0
  39. package/lib/scrollbar/style/style.min.css +1 -0
  40. package/lib/style.css +1 -1
  41. package/lib/style.min.css +1 -1
  42. package/lib/ui/index.js +10 -1
  43. package/lib/ui/index.min.js +1 -1
  44. package/lib/ui/src/log.js +1 -1
  45. package/lib/ui/src/log.min.js +1 -1
  46. package/lib/upload/style/style.css +5 -3
  47. package/lib/upload/style/style.min.css +1 -1
  48. package/lib/vxe-scrollbar/index.js +21 -0
  49. package/lib/vxe-scrollbar/index.min.js +1 -0
  50. package/lib/vxe-scrollbar/style/index.js +1 -0
  51. package/lib/vxe-scrollbar/style/style.css +101 -0
  52. package/lib/vxe-scrollbar/style/style.min.css +1 -0
  53. package/lib/vxe-upload/style/style.css +5 -3
  54. package/lib/vxe-upload/style/style.min.css +1 -1
  55. package/package.json +2 -2
  56. package/packages/components.ts +3 -0
  57. package/packages/result/src/result.ts +1 -1
  58. package/packages/scrollbar/index.ts +16 -0
  59. package/packages/scrollbar/src/scrollbar.ts +564 -0
  60. package/packages/scrollbar/src/util.ts +57 -0
  61. package/packages/ui/index.ts +9 -0
  62. package/styles/all.scss +1 -0
  63. package/styles/components/scrollbar.scss +114 -0
  64. package/styles/components/upload.scss +5 -3
  65. package/styles/theme/base.scss +5 -0
  66. package/styles/theme/dark.scss +5 -0
  67. package/styles/theme/light.scss +5 -0
  68. package/styles/variable.scss +5 -0
  69. package/types/all.d.ts +3 -0
  70. package/types/components/gantt.d.ts +3 -3
  71. package/types/components/scrollbar.d.ts +216 -0
  72. package/types/ui/global-config.d.ts +2 -0
  73. /package/es/icon/{iconfont.1790757619500.ttf → iconfont.1791517860186.ttf} +0 -0
  74. /package/es/icon/{iconfont.1790757619500.woff → iconfont.1791517860186.woff} +0 -0
  75. /package/es/icon/{iconfont.1790757619500.woff2 → iconfont.1791517860186.woff2} +0 -0
  76. /package/es/{iconfont.1790757619500.ttf → iconfont.1791517860186.ttf} +0 -0
  77. /package/es/{iconfont.1790757619500.woff → iconfont.1791517860186.woff} +0 -0
  78. /package/es/{iconfont.1790757619500.woff2 → iconfont.1791517860186.woff2} +0 -0
  79. /package/lib/icon/style/{iconfont.1790757619500.ttf → iconfont.1791517860186.ttf} +0 -0
  80. /package/lib/icon/style/{iconfont.1790757619500.woff → iconfont.1791517860186.woff} +0 -0
  81. /package/lib/icon/style/{iconfont.1790757619500.woff2 → iconfont.1791517860186.woff2} +0 -0
  82. /package/lib/{iconfont.1790757619500.ttf → iconfont.1791517860186.ttf} +0 -0
  83. /package/lib/{iconfont.1790757619500.woff → iconfont.1791517860186.woff} +0 -0
  84. /package/lib/{iconfont.1790757619500.woff2 → iconfont.1791517860186.woff2} +0 -0
@@ -0,0 +1,520 @@
1
+ import { ref, h, reactive, computed, onMounted, onBeforeUnmount, nextTick, watch } from 'vue';
2
+ import { defineVxeComponent } from '../../ui/src/comp';
3
+ import XEUtils from 'xe-utils';
4
+ import { VxeUI } from '../../ui';
5
+ import { toCssUnit } from '../../ui/src/dom';
6
+ import { getThumbOffsetSize, getThumbSize, getScrollFromClick, getScrollFromDrag } from './util';
7
+ import VxeLoadingComponent from '../../loading';
8
+ const { getConfig, createEvent, domUtils, globalResize, renderEmptyElement } = VxeUI;
9
+ function createReactData() {
10
+ return {
11
+ yThumbHeight: 0,
12
+ xThumbWidth: 0
13
+ };
14
+ }
15
+ function createInternalData() {
16
+ return {
17
+ // resizeObserver: undefined,
18
+ // isThumbDrag: false,
19
+ thumbDragOffset: 0,
20
+ yThumbTop: 0,
21
+ xThumbLeft: 0,
22
+ lastScrollTop: 0,
23
+ lastScrollLeft: 0
24
+ };
25
+ }
26
+ export default defineVxeComponent({
27
+ name: 'VxeScrollbar',
28
+ props: {
29
+ width: [String, Number],
30
+ height: [String, Number],
31
+ minWidth: [String, Number],
32
+ minHeight: [String, Number],
33
+ maxWidth: [String, Number],
34
+ maxHeight: [String, Number],
35
+ loading: Boolean,
36
+ native: {
37
+ type: Boolean,
38
+ default: () => getConfig().scrollbar.native
39
+ },
40
+ xConfig: Object,
41
+ yConfig: Object,
42
+ className: String,
43
+ viewClassName: String,
44
+ autoResize: {
45
+ type: Boolean,
46
+ default: () => getConfig().scrollbar.autoResize
47
+ },
48
+ syncResize: [Boolean, String, Number]
49
+ },
50
+ emits: [
51
+ 'scroll',
52
+ 'scroll-boundary'
53
+ ],
54
+ setup(props, context) {
55
+ const { emit, slots } = context;
56
+ const xID = XEUtils.uniqueId();
57
+ const refElem = ref();
58
+ const refViewElem = ref();
59
+ const refViewInnerElem = ref();
60
+ const refTrackXElem = ref();
61
+ const refTrackYElem = ref();
62
+ const refThumbXElem = ref();
63
+ const refThumbYElem = ref();
64
+ const reactData = reactive(createReactData());
65
+ const internalData = createInternalData();
66
+ const computeWrapperStyle = computed(() => {
67
+ const { width, height, minWidth, minHeight, maxWidth, maxHeight } = props;
68
+ const xOpts = computeXOpts.value;
69
+ const yOpts = computeYOpts.value;
70
+ const stys = {};
71
+ if (width) {
72
+ stys.width = toCssUnit(width);
73
+ }
74
+ if (height) {
75
+ stys.height = toCssUnit(height);
76
+ }
77
+ if (minWidth) {
78
+ stys.minWidth = toCssUnit(minWidth);
79
+ }
80
+ if (minHeight) {
81
+ stys.minHeight = toCssUnit(minHeight);
82
+ }
83
+ if (maxWidth) {
84
+ stys.maxWidth = toCssUnit(maxWidth);
85
+ }
86
+ if (maxHeight) {
87
+ stys.maxHeight = toCssUnit(maxHeight);
88
+ }
89
+ if (yOpts.width) {
90
+ stys['--vxe-ui-scrollbar-y-width'] = toCssUnit(yOpts.width);
91
+ }
92
+ if (xOpts.height) {
93
+ stys['--vxe-ui-scrollbar-x-height'] = toCssUnit(xOpts.height);
94
+ }
95
+ return stys;
96
+ });
97
+ const computeWrapperClss = computed(() => {
98
+ const { native, className } = props;
99
+ const xOpts = computeXOpts.value;
100
+ const yOpts = computeYOpts.value;
101
+ return domUtils.buildClass([
102
+ 'vxe-scrollbar',
103
+ `ov-x--${xOpts.visible || 'visible'}`,
104
+ `ov-y--${yOpts.visible || 'visible'}`,
105
+ native ? 'is--native' : 'is--virtual',
106
+ className
107
+ ], {
108
+ 'ov-x--auto-hide': xOpts.autoHide,
109
+ 'ov-y--auto-hide': yOpts.autoHide
110
+ });
111
+ });
112
+ const computeViewClss = computed(() => {
113
+ const { viewClassName } = props;
114
+ return domUtils.buildClass([
115
+ 'vxe-scrollbar--view',
116
+ viewClassName
117
+ ]);
118
+ });
119
+ const computeXOpts = computed(() => {
120
+ return Object.assign({}, getConfig().scrollbar.xConfig, props.xConfig);
121
+ });
122
+ const computeYOpts = computed(() => {
123
+ return Object.assign({}, getConfig().scrollbar.yConfig, props.yConfig);
124
+ });
125
+ const refMaps = {
126
+ refElem
127
+ };
128
+ const computeMaps = {};
129
+ const $xeScrollbar = {
130
+ xID,
131
+ props,
132
+ context,
133
+ reactData,
134
+ internalData,
135
+ getRefMaps: () => refMaps,
136
+ getComputeMaps: () => computeMaps
137
+ };
138
+ const dispatchEvent = (type, params, evnt) => {
139
+ emit(type, createEvent(evnt, { $scrollbar: $xeScrollbar }, params));
140
+ };
141
+ const scrollbarMethods = {
142
+ dispatchEvent,
143
+ scrollTo(left, top) {
144
+ const viewEl = refViewElem.value;
145
+ if (viewEl) {
146
+ if (XEUtils.isNumber(left)) {
147
+ viewEl.scrollTo(left, top || 0);
148
+ }
149
+ else {
150
+ viewEl.scrollTo(left);
151
+ }
152
+ }
153
+ },
154
+ scrollIntoView() {
155
+ const viewEl = refViewElem.value;
156
+ if (viewEl) {
157
+ viewEl.scrollIntoView();
158
+ }
159
+ },
160
+ recalculate() {
161
+ updateThumbSize();
162
+ updateThumbOffset();
163
+ return nextTick();
164
+ }
165
+ };
166
+ const updateThumbSize = () => {
167
+ const viewEl = refViewElem.value;
168
+ if (!viewEl) {
169
+ return;
170
+ }
171
+ const trackXEl = refTrackXElem.value;
172
+ const xThumbWidth = trackXEl ? getThumbSize(viewEl.clientWidth, viewEl.scrollWidth, trackXEl.clientWidth) : 0;
173
+ const thumbXElem = refThumbXElem.value;
174
+ if (thumbXElem) {
175
+ thumbXElem.style.width = xThumbWidth + 'px';
176
+ }
177
+ reactData.xThumbWidth = xThumbWidth;
178
+ const trackYEl = refTrackYElem.value;
179
+ const yThumbHeight = trackYEl ? getThumbSize(viewEl.clientHeight, viewEl.scrollHeight, trackYEl.clientHeight) : 0;
180
+ const thumbYElem = refThumbYElem.value;
181
+ if (thumbYElem) {
182
+ thumbYElem.style.height = yThumbHeight + 'px';
183
+ }
184
+ reactData.yThumbHeight = yThumbHeight;
185
+ };
186
+ const updateThumbOffset = () => {
187
+ const viewEl = refViewElem.value;
188
+ if (!viewEl) {
189
+ return;
190
+ }
191
+ const { xThumbWidth, yThumbHeight } = reactData;
192
+ const trackXEl = refTrackXElem.value;
193
+ const thumbXElem = refThumbXElem.value;
194
+ const xThumbLeft = trackXEl && xThumbWidth ? getThumbOffsetSize(viewEl.scrollLeft, viewEl.clientWidth, viewEl.scrollWidth, trackXEl.clientWidth, xThumbWidth) : 0;
195
+ internalData.xThumbLeft = xThumbLeft;
196
+ if (thumbXElem && xThumbWidth) {
197
+ thumbXElem.style.width = xThumbWidth + 'px';
198
+ thumbXElem.style.transform = `translateX(${xThumbLeft}px)`;
199
+ }
200
+ const trackYEl = refTrackYElem.value;
201
+ const thumbYElem = refThumbYElem.value;
202
+ const yThumbTop = trackYEl && yThumbHeight ? getThumbOffsetSize(viewEl.scrollTop, viewEl.clientHeight, viewEl.scrollHeight, trackYEl.clientHeight, yThumbHeight) : 0;
203
+ internalData.yThumbTop = yThumbTop;
204
+ if (thumbYElem && yThumbHeight) {
205
+ thumbYElem.style.height = yThumbHeight + 'px';
206
+ thumbYElem.style.transform = `translateY(${yThumbTop}px)`;
207
+ }
208
+ };
209
+ const scrollEvent = (evnt) => {
210
+ const { xThumbWidth, yThumbHeight } = reactData;
211
+ const { lastScrollTop, lastScrollLeft } = internalData;
212
+ const xOpts = computeXOpts.value;
213
+ const yOpts = computeYOpts.value;
214
+ const viewEl = evnt.currentTarget;
215
+ const { scrollTop, scrollLeft, clientWidth, clientHeight, scrollHeight, scrollWidth } = viewEl;
216
+ let direction = '';
217
+ let isTopBoundary = false;
218
+ let isBottomBoundary = false;
219
+ let isLeftBoundary = false;
220
+ let isRightBoundary = false;
221
+ if (lastScrollTop !== scrollTop) {
222
+ const yThreshold = XEUtils.toNumber(yOpts.threshold) || 1;
223
+ if (lastScrollTop < scrollTop) {
224
+ direction = 'bottom';
225
+ if (yThumbHeight > 0 && scrollTop + clientHeight >= scrollHeight - yThreshold) {
226
+ isBottomBoundary = true;
227
+ }
228
+ }
229
+ else {
230
+ direction = 'top';
231
+ if (yThumbHeight > 0 && scrollTop <= yThreshold) {
232
+ isTopBoundary = true;
233
+ }
234
+ }
235
+ }
236
+ if (lastScrollLeft !== scrollLeft) {
237
+ const xThreshold = XEUtils.toNumber(xOpts.threshold) || 1;
238
+ if (lastScrollLeft < scrollLeft) {
239
+ direction = 'right';
240
+ if (xThumbWidth > 0 && scrollLeft + clientWidth >= scrollWidth - xThreshold) {
241
+ isRightBoundary = true;
242
+ }
243
+ }
244
+ else {
245
+ direction = 'left';
246
+ if (xThumbWidth > 0 && scrollLeft <= xThreshold) {
247
+ isLeftBoundary = true;
248
+ }
249
+ }
250
+ }
251
+ updateThumbOffset();
252
+ internalData.lastScrollTop = scrollTop;
253
+ internalData.lastScrollLeft = scrollLeft;
254
+ if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
255
+ dispatchEvent('scroll-boundary', {
256
+ direction: direction,
257
+ isTop: isTopBoundary,
258
+ isBottom: isBottomBoundary,
259
+ isLeft: isLeftBoundary,
260
+ isRight: isRightBoundary,
261
+ scrollTop: scrollTop,
262
+ scrollLeft: scrollLeft,
263
+ clientWidth: clientWidth,
264
+ clientHeight: clientHeight,
265
+ scrollHeight: scrollHeight,
266
+ scrollWidth: scrollWidth
267
+ }, evnt);
268
+ }
269
+ dispatchEvent('scroll', {
270
+ direction: direction,
271
+ isTop: yThumbHeight > 0 && scrollTop <= 0,
272
+ isBottom: yThumbHeight > 0 && scrollTop + clientHeight >= scrollHeight,
273
+ isLeft: xThumbWidth > 0 && scrollLeft <= 0,
274
+ isRight: xThumbWidth > 0 && scrollLeft + clientWidth >= scrollWidth,
275
+ scrollTop: scrollTop,
276
+ scrollLeft: scrollLeft,
277
+ clientWidth: clientWidth,
278
+ clientHeight: clientHeight,
279
+ scrollHeight: scrollHeight,
280
+ scrollWidth: scrollWidth
281
+ }, evnt);
282
+ };
283
+ const clickTrackXEvent = (evnt) => {
284
+ const trackEl = evnt.currentTarget;
285
+ if (trackEl !== evnt.target) {
286
+ return;
287
+ }
288
+ const viewEl = refViewElem.value;
289
+ if (!viewEl) {
290
+ return;
291
+ }
292
+ const { xThumbWidth } = reactData;
293
+ const trackRect = trackEl.getBoundingClientRect();
294
+ viewEl.scrollTo({
295
+ left: getScrollFromClick(evnt.clientX - trackRect.left, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth),
296
+ behavior: 'auto'
297
+ });
298
+ };
299
+ const clickTrackYEvent = (evnt) => {
300
+ const trackEl = evnt.currentTarget;
301
+ if (trackEl !== evnt.target) {
302
+ return;
303
+ }
304
+ const viewEl = refViewElem.value;
305
+ if (!viewEl) {
306
+ return;
307
+ }
308
+ const { yThumbHeight } = reactData;
309
+ const trackRect = trackEl.getBoundingClientRect();
310
+ viewEl.scrollTo({
311
+ top: getScrollFromClick(evnt.clientY - trackRect.top, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight),
312
+ behavior: 'auto'
313
+ });
314
+ };
315
+ const pointerdownThumbXEvent = (evnt) => {
316
+ const thumbEl = evnt.currentTarget;
317
+ internalData.isThumbDrag = true;
318
+ thumbEl.setPointerCapture(evnt.pointerId);
319
+ const viewEl = refViewElem.value;
320
+ if (!viewEl) {
321
+ return;
322
+ }
323
+ const { xThumbWidth } = reactData;
324
+ const trackEl = thumbEl.parentElement;
325
+ const trackRect = trackEl.getBoundingClientRect();
326
+ const pointerPosition = evnt.clientX - trackRect.left;
327
+ // 记录 thumb 的偏移
328
+ const thumbOffset = getThumbOffsetSize(viewEl.scrollLeft, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth);
329
+ internalData.thumbDragOffset = pointerPosition - thumbOffset;
330
+ };
331
+ const pointermoveThumbXEvent = (evnt) => {
332
+ const thumbEl = evnt.currentTarget;
333
+ if (!thumbEl.hasPointerCapture(evnt.pointerId)) {
334
+ return;
335
+ }
336
+ const { isThumbDrag, thumbDragOffset } = internalData;
337
+ if (isThumbDrag) {
338
+ const viewEl = refViewElem.value;
339
+ if (!viewEl) {
340
+ return;
341
+ }
342
+ const { xThumbWidth } = reactData;
343
+ const thumbEl = evnt.currentTarget;
344
+ const trackEl = thumbEl.parentElement;
345
+ const trackRect = trackEl.getBoundingClientRect();
346
+ // 更新偏移
347
+ viewEl.scrollLeft = getScrollFromDrag(evnt.clientX - trackRect.left, thumbDragOffset, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth);
348
+ }
349
+ };
350
+ const cleatPointerThumbEvent = (evnt) => {
351
+ const thumbEl = evnt.currentTarget;
352
+ thumbEl.releasePointerCapture(evnt.pointerId);
353
+ internalData.isThumbDrag = false;
354
+ };
355
+ const pointerdownThumbYEvent = (evnt) => {
356
+ const thumbEl = evnt.currentTarget;
357
+ internalData.isThumbDrag = true;
358
+ thumbEl.setPointerCapture(evnt.pointerId);
359
+ const viewEl = refViewElem.value;
360
+ if (!viewEl) {
361
+ return;
362
+ }
363
+ const { yThumbHeight } = reactData;
364
+ const trackEl = thumbEl.parentElement;
365
+ const trackRect = trackEl.getBoundingClientRect();
366
+ const pointerPosition = evnt.clientY - trackRect.top;
367
+ // 记录 thumb 的偏移
368
+ const thumbOffset = getThumbOffsetSize(viewEl.scrollTop, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight);
369
+ internalData.thumbDragOffset = pointerPosition - thumbOffset;
370
+ };
371
+ const pointermoveThumbYEvent = (evnt) => {
372
+ const thumbEl = evnt.currentTarget;
373
+ if (!thumbEl.hasPointerCapture(evnt.pointerId)) {
374
+ return;
375
+ }
376
+ const { isThumbDrag, thumbDragOffset } = internalData;
377
+ if (isThumbDrag) {
378
+ const viewEl = refViewElem.value;
379
+ if (!viewEl) {
380
+ return;
381
+ }
382
+ const { yThumbHeight } = reactData;
383
+ const thumbEl = evnt.currentTarget;
384
+ const trackEl = thumbEl.parentElement;
385
+ const trackRect = trackEl.getBoundingClientRect();
386
+ // 更新偏移
387
+ viewEl.scrollTop = getScrollFromDrag(evnt.clientY - trackRect.top, thumbDragOffset, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight);
388
+ }
389
+ };
390
+ const scrollbarPrivateMethods = {};
391
+ Object.assign($xeScrollbar, scrollbarMethods, scrollbarPrivateMethods);
392
+ const renderVN = () => {
393
+ const { native, loading, autoResize } = props;
394
+ const wrapperStyle = computeWrapperStyle.value;
395
+ const wrapperClss = computeWrapperClss.value;
396
+ const viewClss = computeViewClss.value;
397
+ const xOpts = computeXOpts.value;
398
+ const yOpts = computeYOpts.value;
399
+ const defaultSlot = slots.default;
400
+ return h('div', {
401
+ ref: refElem,
402
+ class: wrapperClss,
403
+ style: wrapperStyle
404
+ }, [
405
+ h('div', {
406
+ ref: refViewElem,
407
+ class: viewClss,
408
+ onScroll: scrollEvent
409
+ }, autoResize
410
+ ? [
411
+ h('div', {
412
+ key: 'vi',
413
+ ref: refViewInnerElem,
414
+ class: 'vxe-scrollbar--view-inner'
415
+ }, defaultSlot ? defaultSlot({}) : [])
416
+ ]
417
+ : defaultSlot ? defaultSlot({}) : []),
418
+ native || xOpts.visible === 'hidden'
419
+ ? renderEmptyElement($xeScrollbar)
420
+ : h('div', {
421
+ ref: refTrackXElem,
422
+ class: 'vxe-scrollbar--track-x',
423
+ onClick: clickTrackXEvent
424
+ }, [
425
+ h('div', {
426
+ ref: refThumbXElem,
427
+ class: 'vxe-scrollbar--thumb-x',
428
+ onPointerdown: pointerdownThumbXEvent,
429
+ onPointermove: pointermoveThumbXEvent,
430
+ onPointerup: cleatPointerThumbEvent,
431
+ onPointercancel: cleatPointerThumbEvent,
432
+ onLostpointercapture: cleatPointerThumbEvent
433
+ })
434
+ ]),
435
+ native || yOpts.visible === 'hidden'
436
+ ? renderEmptyElement($xeScrollbar)
437
+ : h('div', {
438
+ ref: refTrackYElem,
439
+ class: 'vxe-scrollbar--track-y',
440
+ onClick: clickTrackYEvent
441
+ }, [
442
+ h('div', {
443
+ ref: refThumbYElem,
444
+ class: 'vxe-scrollbar--thumb-y',
445
+ onPointerdown: pointerdownThumbYEvent,
446
+ onPointermove: pointermoveThumbYEvent,
447
+ onPointerup: cleatPointerThumbEvent,
448
+ onPointercancel: cleatPointerThumbEvent,
449
+ onLostpointercapture: cleatPointerThumbEvent
450
+ })
451
+ ]),
452
+ h(VxeLoadingComponent, {
453
+ class: 'vxe-scrollbar--loading',
454
+ modelValue: loading
455
+ })
456
+ ]);
457
+ };
458
+ const reFlag = ref(0);
459
+ watch(() => props.height, () => {
460
+ reFlag.value++;
461
+ });
462
+ watch(() => props.width, () => {
463
+ reFlag.value++;
464
+ });
465
+ watch(() => props.minHeight, () => {
466
+ reFlag.value++;
467
+ });
468
+ watch(() => props.minWidth, () => {
469
+ reFlag.value++;
470
+ });
471
+ watch(() => props.maxHeight, () => {
472
+ reFlag.value++;
473
+ });
474
+ watch(() => props.maxWidth, () => {
475
+ reFlag.value++;
476
+ });
477
+ watch(() => props.native, () => {
478
+ reFlag.value++;
479
+ });
480
+ watch(() => props.syncResize, () => {
481
+ reFlag.value++;
482
+ });
483
+ watch(reFlag, () => {
484
+ $xeScrollbar.recalculate().then(() => {
485
+ $xeScrollbar.recalculate();
486
+ });
487
+ });
488
+ onMounted(() => {
489
+ const { autoResize } = props;
490
+ const viewEl = refViewElem.value;
491
+ const viewInnerEl = refViewInnerElem.value;
492
+ if (autoResize) {
493
+ const resizeObserver = globalResize.create(() => {
494
+ if (props.autoResize) {
495
+ reFlag.value++;
496
+ }
497
+ });
498
+ if (viewEl) {
499
+ resizeObserver.observe(viewEl);
500
+ }
501
+ if (viewInnerEl) {
502
+ resizeObserver.observe(viewInnerEl);
503
+ }
504
+ internalData.resizeObserver = resizeObserver;
505
+ }
506
+ reFlag.value++;
507
+ });
508
+ onBeforeUnmount(() => {
509
+ const { resizeObserver } = internalData;
510
+ if (resizeObserver) {
511
+ resizeObserver.disconnect();
512
+ }
513
+ });
514
+ $xeScrollbar.renderVN = renderVN;
515
+ return $xeScrollbar;
516
+ },
517
+ render() {
518
+ return this.renderVN();
519
+ }
520
+ });
@@ -0,0 +1,54 @@
1
+ /**
2
+ * 计算滚动条滑块的长度
3
+ */
4
+ export function getThumbSize(viewportSize, contentSize, trackSize) {
5
+ if (contentSize <= viewportSize) {
6
+ return 0;
7
+ }
8
+ const ratio = viewportSize / contentSize;
9
+ const ideal = trackSize * ratio;
10
+ return Math.max(20, Math.min(ideal, trackSize));
11
+ }
12
+ /**
13
+ * 计算滚动条滑块的偏移位置
14
+ */
15
+ export function getThumbOffsetSize(offsetSize, viewportSize, contentSize, trackSize, thumbSize) {
16
+ const maxScroll = contentSize - viewportSize;
17
+ if (maxScroll <= 0) {
18
+ return 0;
19
+ }
20
+ const maxThumbOffset = trackSize - thumbSize;
21
+ if (maxThumbOffset <= 0) {
22
+ return 0;
23
+ }
24
+ const clamped = Math.min(Math.max(offsetSize, 0), maxScroll);
25
+ const ratio = clamped / maxScroll;
26
+ return ratio * maxThumbOffset;
27
+ }
28
+ /**
29
+ * 根据点击轨道的位置,计算滑块的偏移位置
30
+ */
31
+ export function getScrollFromClick(clickPosition, viewportSize, contentSize, trackSize, thumbSize) {
32
+ const maxThumbOffset = trackSize - thumbSize;
33
+ const maxScroll = contentSize - viewportSize;
34
+ if (maxScroll <= 0 || maxThumbOffset <= 0) {
35
+ return 0;
36
+ }
37
+ let thumbOffset = clickPosition - thumbSize / 2;
38
+ thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset);
39
+ const scrollOffset = (thumbOffset / maxThumbOffset) * maxScroll;
40
+ return scrollOffset;
41
+ }
42
+ /**
43
+ * 拖拽 thumb 时,根据鼠标位置计算滑块的偏移位置
44
+ */
45
+ export function getScrollFromDrag(pointerPosition, dragOffset, viewportSize, contentSize, trackSize, thumbSize) {
46
+ const maxScroll = contentSize - viewportSize;
47
+ const maxThumbOffset = trackSize - thumbSize;
48
+ if (maxScroll <= 0 || maxThumbOffset <= 0) {
49
+ return 0;
50
+ }
51
+ let thumbOffset = pointerPosition - dragOffset;
52
+ thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset);
53
+ return (thumbOffset / maxThumbOffset) * maxScroll;
54
+ }
@@ -0,0 +1,101 @@
1
+ .vxe-scrollbar {
2
+ width: 100%;
3
+ position: relative;
4
+ }
5
+ .vxe-scrollbar.is--virtual > .vxe-scrollbar--view {
6
+ scrollbar-width: none;
7
+ -ms-overflow-style: none;
8
+ overflow-x: auto;
9
+ overflow-y: auto;
10
+ }
11
+ .vxe-scrollbar.is--virtual > .vxe-scrollbar--view::-webkit-scrollbar {
12
+ display: none;
13
+ }
14
+ .vxe-scrollbar.is--virtual.ov-x--auto-hide:hover > .vxe-scrollbar--track-x {
15
+ opacity: 1;
16
+ }
17
+ .vxe-scrollbar.is--virtual.ov-x--auto-hide > .vxe-scrollbar--track-x {
18
+ opacity: 0;
19
+ transition: opacity 0.8s ease-in-out;
20
+ }
21
+ .vxe-scrollbar.is--virtual.ov-y--auto-hide:hover > .vxe-scrollbar--track-y {
22
+ opacity: 1;
23
+ }
24
+ .vxe-scrollbar.is--virtual.ov-y--auto-hide > .vxe-scrollbar--track-y {
25
+ opacity: 0;
26
+ transition: opacity 0.8s ease-in-out;
27
+ }
28
+ .vxe-scrollbar.is--native > .vxe-scrollbar--view {
29
+ overflow-x: auto;
30
+ overflow-y: auto;
31
+ }
32
+ .vxe-scrollbar.is--native.ov-x--hidden > .vxe-scrollbar--view {
33
+ overflow-x: hidden;
34
+ }
35
+ .vxe-scrollbar.is--native.ov-y--hidden > .vxe-scrollbar--view {
36
+ overflow-y: hidden;
37
+ }
38
+ .vxe-scrollbar.is--native > .vxe-scrollbar--view::-webkit-scrollbar {
39
+ width: var(--vxe-ui-scrollbar-y-width);
40
+ height: var(--vxe-ui-scrollbar-x-height);
41
+ }
42
+ .vxe-scrollbar.is--native > .vxe-scrollbar--view::-webkit-scrollbar-thumb {
43
+ border-radius: var(--vxe-ui-base-border-radius);
44
+ background-color: var(--vxe-ui-scrollbar-thumb-background-color);
45
+ }
46
+ .vxe-scrollbar.is--native > .vxe-scrollbar--view::-webkit-scrollbar-thumb:hover {
47
+ background-color: var(--vxe-ui-scrollbar-thumb-hover-background-color);
48
+ }
49
+ .vxe-scrollbar.is--native > .vxe-scrollbar--view::-webkit-scrollbar-thumb:active {
50
+ background-color: var(--vxe-ui-scrollbar-thumb-active-background-color);
51
+ }
52
+
53
+ .vxe-scrollbar--view {
54
+ height: 100%;
55
+ width: 100%;
56
+ }
57
+
58
+ .vxe-scrollbar--track-x,
59
+ .vxe-scrollbar--track-y {
60
+ position: absolute;
61
+ background-color: var(--vxe-ui-scrollbar-track-background-color);
62
+ -webkit-user-select: none;
63
+ -moz-user-select: none;
64
+ user-select: none;
65
+ }
66
+
67
+ .vxe-scrollbar--track-x {
68
+ width: 100%;
69
+ bottom: 0;
70
+ left: 0;
71
+ height: var(--vxe-ui-scrollbar-x-height);
72
+ }
73
+
74
+ .vxe-scrollbar--track-y {
75
+ height: 100%;
76
+ right: 0;
77
+ top: 0;
78
+ width: var(--vxe-ui-scrollbar-y-width);
79
+ }
80
+
81
+ .vxe-scrollbar--thumb-y {
82
+ width: 100%;
83
+ }
84
+
85
+ .vxe-scrollbar--thumb-x {
86
+ height: 100%;
87
+ }
88
+
89
+ .vxe-scrollbar--thumb-x,
90
+ .vxe-scrollbar--thumb-y {
91
+ border-radius: var(--vxe-ui-base-border-radius);
92
+ background-color: var(--vxe-ui-scrollbar-thumb-background-color);
93
+ }
94
+ .vxe-scrollbar--thumb-x:hover,
95
+ .vxe-scrollbar--thumb-y:hover {
96
+ background-color: var(--vxe-ui-scrollbar-thumb-hover-background-color);
97
+ }
98
+ .vxe-scrollbar--thumb-x:active,
99
+ .vxe-scrollbar--thumb-y:active {
100
+ background-color: var(--vxe-ui-scrollbar-thumb-active-background-color);
101
+ }
@@ -0,0 +1 @@
1
+ .vxe-scrollbar{width:100%;position:relative}.vxe-scrollbar.is--virtual>.vxe-scrollbar--view{scrollbar-width:none;-ms-overflow-style:none;overflow-x:auto;overflow-y:auto}.vxe-scrollbar.is--virtual>.vxe-scrollbar--view::-webkit-scrollbar{display:none}.vxe-scrollbar.is--virtual.ov-x--auto-hide:hover>.vxe-scrollbar--track-x{opacity:1}.vxe-scrollbar.is--virtual.ov-x--auto-hide>.vxe-scrollbar--track-x{opacity:0;transition:opacity .8s ease-in-out}.vxe-scrollbar.is--virtual.ov-y--auto-hide:hover>.vxe-scrollbar--track-y{opacity:1}.vxe-scrollbar.is--virtual.ov-y--auto-hide>.vxe-scrollbar--track-y{opacity:0;transition:opacity .8s ease-in-out}.vxe-scrollbar.is--native>.vxe-scrollbar--view{overflow-x:auto;overflow-y:auto}.vxe-scrollbar.is--native.ov-x--hidden>.vxe-scrollbar--view{overflow-x:hidden}.vxe-scrollbar.is--native.ov-y--hidden>.vxe-scrollbar--view{overflow-y:hidden}.vxe-scrollbar.is--native>.vxe-scrollbar--view::-webkit-scrollbar{width:var(--vxe-ui-scrollbar-y-width);height:var(--vxe-ui-scrollbar-x-height)}.vxe-scrollbar.is--native>.vxe-scrollbar--view::-webkit-scrollbar-thumb{border-radius:var(--vxe-ui-base-border-radius);background-color:var(--vxe-ui-scrollbar-thumb-background-color)}.vxe-scrollbar.is--native>.vxe-scrollbar--view::-webkit-scrollbar-thumb:hover{background-color:var(--vxe-ui-scrollbar-thumb-hover-background-color)}.vxe-scrollbar.is--native>.vxe-scrollbar--view::-webkit-scrollbar-thumb:active{background-color:var(--vxe-ui-scrollbar-thumb-active-background-color)}.vxe-scrollbar--view{height:100%;width:100%}.vxe-scrollbar--track-x,.vxe-scrollbar--track-y{position:absolute;background-color:var(--vxe-ui-scrollbar-track-background-color);-webkit-user-select:none;-moz-user-select:none;user-select:none}.vxe-scrollbar--track-x{width:100%;bottom:0;left:0;height:var(--vxe-ui-scrollbar-x-height)}.vxe-scrollbar--track-y{height:100%;right:0;top:0;width:var(--vxe-ui-scrollbar-y-width)}.vxe-scrollbar--thumb-y{width:100%}.vxe-scrollbar--thumb-x{height:100%}.vxe-scrollbar--thumb-x,.vxe-scrollbar--thumb-y{border-radius:var(--vxe-ui-base-border-radius);background-color:var(--vxe-ui-scrollbar-thumb-background-color)}.vxe-scrollbar--thumb-x:hover,.vxe-scrollbar--thumb-y:hover{background-color:var(--vxe-ui-scrollbar-thumb-hover-background-color)}.vxe-scrollbar--thumb-x:active,.vxe-scrollbar--thumb-y:active{background-color:var(--vxe-ui-scrollbar-thumb-active-background-color)}