e-virt-table 1.4.2 → 1.4.3
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/index.cjs.js +16 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1934 -1741
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +16 -16
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/BaseCell.js +3 -2
- package/dist/lib/BaseCell.js.map +1 -1
- package/dist/lib/Body.js +17 -8
- package/dist/lib/Body.js.map +1 -1
- package/dist/lib/BorderStyle.d.ts +9 -0
- package/dist/lib/BorderStyle.js +29 -0
- package/dist/lib/BorderStyle.js.map +1 -0
- package/dist/lib/Cell.d.ts +1 -0
- package/dist/lib/Cell.js +16 -9
- package/dist/lib/Cell.js.map +1 -1
- package/dist/lib/CellHeader.js +3 -2
- package/dist/lib/CellHeader.js.map +1 -1
- package/dist/lib/CellImage.js +2 -2
- package/dist/lib/CellImage.js.map +1 -1
- package/dist/lib/Config.d.ts +7 -1
- package/dist/lib/Config.js +14 -0
- package/dist/lib/Config.js.map +1 -1
- package/dist/lib/Database.js +2 -2
- package/dist/lib/Database.js.map +1 -1
- package/dist/lib/EVirtTable.d.ts +1 -0
- package/dist/lib/EVirtTable.js +8 -0
- package/dist/lib/EVirtTable.js.map +1 -1
- package/dist/lib/Editor.js +6 -2
- package/dist/lib/Editor.js.map +1 -1
- package/dist/lib/EventTable.js +5 -3
- package/dist/lib/EventTable.js.map +1 -1
- package/dist/lib/Footer.js +18 -5
- package/dist/lib/Footer.js.map +1 -1
- package/dist/lib/Header.js +14 -7
- package/dist/lib/Header.js.map +1 -1
- package/dist/lib/Overlayer.js +10 -6
- package/dist/lib/Overlayer.js.map +1 -1
- package/dist/lib/Row.d.ts +2 -0
- package/dist/lib/Row.js +10 -0
- package/dist/lib/Row.js.map +1 -1
- package/dist/lib/ScrollbarMode.d.ts +21 -0
- package/dist/lib/ScrollbarMode.js +38 -0
- package/dist/lib/ScrollbarMode.js.map +1 -0
- package/dist/lib/Scroller.d.ts +1 -0
- package/dist/lib/Scroller.js +251 -66
- package/dist/lib/Scroller.js.map +1 -1
- package/dist/lib/Selector.js +4 -2
- package/dist/lib/Selector.js.map +1 -1
- package/dist/lib/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/lib/Row.js
CHANGED
|
@@ -158,5 +158,15 @@ export default class Row {
|
|
|
158
158
|
cell.drawContainer();
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
+
drawHorizontalBorder() {
|
|
162
|
+
this.noFixedCells.forEach((cell) => {
|
|
163
|
+
cell.drawHorizontalBorder();
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
drawFixedHorizontalBorder() {
|
|
167
|
+
this.fixedCells.forEach((cell) => {
|
|
168
|
+
cell.drawHorizontalBorder();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
161
171
|
}
|
|
162
172
|
//# sourceMappingURL=Row.js.map
|
package/dist/lib/Row.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.js","sourceRoot":"","sources":["../../src/Row.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAG1B,MAAM,CAAC,OAAO,OAAO,GAAG;IAepB,YACI,GAAY,EACZ,QAAgB,EAChB,CAAC,GAAG,CAAC,EACL,CAAC,GAAG,CAAC,EACL,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,IAAS,EACT,UAAmB,MAAM;QAtBrB;;;;;WAAa;QACrB;;;;mBAAI,CAAC;WAAC;QACN;;;;mBAAY,CAAC;WAAC;QACd;;;;mBAAQ,CAAC;WAAC;QACV;;;;;WAAe;QACf;;;;mBAAgB,EAAE;WAAC;QACnB;;;;mBAAqB,EAAE;WAAC;QACxB;;;;mBAAuB,EAAE;WAAC;QAC1B;;;;mBAAgC,EAAE;WAAC;QACnC;;;;mBAAW,CAAC;WAAC;QACb;;;;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C,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC7B,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type ScrollbarMode = 'outer' | 'inner';
|
|
2
|
+
export type ScrollbarModeConfig = {
|
|
3
|
+
scrollbarMode?: unknown;
|
|
4
|
+
SCROLLBAR_MODE?: unknown;
|
|
5
|
+
SCROLLER_TRACK_SIZE?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function getScrollbarMode(config: ScrollbarModeConfig): ScrollbarMode;
|
|
8
|
+
export declare function isInnerScrollbarMode(config: ScrollbarModeConfig): boolean;
|
|
9
|
+
export declare function getLayoutScrollerTrackSize(config: ScrollbarModeConfig): number;
|
|
10
|
+
export declare function getOverlayScrollerTrackSize(config: ScrollbarModeConfig): number;
|
|
11
|
+
export declare function getScrollbarCornerOffset(config: ScrollbarModeConfig, hasOppositeScrollbar: boolean): number;
|
|
12
|
+
export declare function getScrollbarThumbEndInset(config: ScrollbarModeConfig): number;
|
|
13
|
+
export declare function shouldDrawScrollbarTrackBorder(config: ScrollbarModeConfig): boolean;
|
|
14
|
+
export declare function shouldDrawScrollbarTrackBackground(config: ScrollbarModeConfig): boolean;
|
|
15
|
+
export type ScrollbarVisibilityState = {
|
|
16
|
+
innerVisible: boolean;
|
|
17
|
+
isFocus: boolean;
|
|
18
|
+
isDragging: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare function shouldStartInnerScrollbarShowTimer(config: ScrollbarModeConfig, isPointerInsideTable: boolean): boolean;
|
|
21
|
+
export declare function shouldDrawScrollbar(config: ScrollbarModeConfig, state: ScrollbarVisibilityState): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function getScrollbarMode(config) {
|
|
2
|
+
const mode = config.scrollbarMode ?? config.SCROLLBAR_MODE;
|
|
3
|
+
return mode === 'inner' ? 'inner' : 'outer';
|
|
4
|
+
}
|
|
5
|
+
export function isInnerScrollbarMode(config) {
|
|
6
|
+
return getScrollbarMode(config) === 'inner';
|
|
7
|
+
}
|
|
8
|
+
export function getLayoutScrollerTrackSize(config) {
|
|
9
|
+
return isInnerScrollbarMode(config) ? 0 : config.SCROLLER_TRACK_SIZE || 0;
|
|
10
|
+
}
|
|
11
|
+
export function getOverlayScrollerTrackSize(config) {
|
|
12
|
+
return config.SCROLLER_TRACK_SIZE || 0;
|
|
13
|
+
}
|
|
14
|
+
export function getScrollbarCornerOffset(config, hasOppositeScrollbar) {
|
|
15
|
+
if (!isInnerScrollbarMode(config) || !hasOppositeScrollbar) {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
return getOverlayScrollerTrackSize(config);
|
|
19
|
+
}
|
|
20
|
+
export function getScrollbarThumbEndInset(config) {
|
|
21
|
+
return isInnerScrollbarMode(config) ? 1 : 0;
|
|
22
|
+
}
|
|
23
|
+
export function shouldDrawScrollbarTrackBorder(config) {
|
|
24
|
+
return !isInnerScrollbarMode(config);
|
|
25
|
+
}
|
|
26
|
+
export function shouldDrawScrollbarTrackBackground(config) {
|
|
27
|
+
return !isInnerScrollbarMode(config);
|
|
28
|
+
}
|
|
29
|
+
export function shouldStartInnerScrollbarShowTimer(config, isPointerInsideTable) {
|
|
30
|
+
return isInnerScrollbarMode(config) && isPointerInsideTable;
|
|
31
|
+
}
|
|
32
|
+
export function shouldDrawScrollbar(config, state) {
|
|
33
|
+
if (!isInnerScrollbarMode(config)) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return state.innerVisible || state.isFocus || state.isDragging;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ScrollbarMode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollbarMode.js","sourceRoot":"","sources":["../../src/ScrollbarMode.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,gBAAgB,CAAC,MAA2B;IACxD,M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ChE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAA2B,EAAE,KAA+B;IAC5F,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC;AACnE,CAAC"}
|
package/dist/lib/Scroller.d.ts
CHANGED
package/dist/lib/Scroller.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
import { shouldDrawRightBoundaryBorder, shouldDrawScrollerBorder, shouldDrawScrollerTrack } from './BorderStyle';
|
|
2
|
+
import { getLayoutScrollerTrackSize, getOverlayScrollerTrackSize, getScrollbarCornerOffset, getScrollbarThumbEndInset, isInnerScrollbarMode, shouldDrawScrollbar, shouldDrawScrollbarTrackBackground, shouldDrawScrollbarTrackBorder, shouldStartInnerScrollbarShowTimer, } from './ScrollbarMode';
|
|
3
|
+
function getScrollbarThumbSize(distance, visibleDistance, contentDistance, trackDistance = visibleDistance, minSize = 30) {
|
|
4
|
+
if (distance <= 0 || visibleDistance <= 0 || contentDistance <= 0 || trackDistance <= 0) {
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
const size = Math.floor((visibleDistance / contentDistance) * trackDistance);
|
|
8
|
+
if (size < minSize) {
|
|
9
|
+
return Math.min(minSize, trackDistance);
|
|
10
|
+
}
|
|
11
|
+
if (size > trackDistance) {
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
return size;
|
|
15
|
+
}
|
|
1
16
|
class Scrollbar {
|
|
2
17
|
constructor(ctx, type) {
|
|
3
18
|
Object.defineProperty(this, "ctx", {
|
|
@@ -84,6 +99,18 @@ class Scrollbar {
|
|
|
84
99
|
writable: true,
|
|
85
100
|
value: 0
|
|
86
101
|
}); //可见区域的长度
|
|
102
|
+
Object.defineProperty(this, "thumbTrackDistance", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
configurable: true,
|
|
105
|
+
writable: true,
|
|
106
|
+
value: 0
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(this, "thumbTravelDistance", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
configurable: true,
|
|
111
|
+
writable: true,
|
|
112
|
+
value: 0
|
|
113
|
+
});
|
|
87
114
|
Object.defineProperty(this, "clientX", {
|
|
88
115
|
enumerable: true,
|
|
89
116
|
configurable: true,
|
|
@@ -102,6 +129,18 @@ class Scrollbar {
|
|
|
102
129
|
writable: true,
|
|
103
130
|
value: 0
|
|
104
131
|
}); // 拖拽开始的位置
|
|
132
|
+
Object.defineProperty(this, "innerVisible", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
configurable: true,
|
|
135
|
+
writable: true,
|
|
136
|
+
value: false
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(this, "innerShowTimer", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
configurable: true,
|
|
141
|
+
writable: true,
|
|
142
|
+
value: 0
|
|
143
|
+
});
|
|
105
144
|
Object.defineProperty(this, "isDragging", {
|
|
106
145
|
enumerable: true,
|
|
107
146
|
configurable: true,
|
|
@@ -172,6 +211,11 @@ class Scrollbar {
|
|
|
172
211
|
const offsetY = this.ctx.zoomScale.toLogical(e.offsetY);
|
|
173
212
|
if (clientX == this.clientX && clientY == this.clientY)
|
|
174
213
|
return;
|
|
214
|
+
if (this.isInnerMode()) {
|
|
215
|
+
if (!this.canInteractWithScrollbar()) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
175
219
|
if (this.isOnScrollbar(offsetX, offsetY)) {
|
|
176
220
|
this.clientX = clientX;
|
|
177
221
|
this.clientY = clientY;
|
|
@@ -188,11 +232,11 @@ class Scrollbar {
|
|
|
188
232
|
// 滚动条位置=(鼠标位置-滚动条的高度/2-头部的高度)/(可见区域的长度-滚动条的高度)*滚动条的长度
|
|
189
233
|
// 滚动到中间所以减去滚动条的高度/2
|
|
190
234
|
const offset = offsetY - this.ctx.header.height - this.barHeight / 2;
|
|
191
|
-
scroll = (offset /
|
|
235
|
+
scroll = (offset / this.thumbTravelDistance) * this.distance;
|
|
192
236
|
}
|
|
193
237
|
else {
|
|
194
238
|
const offset = offsetX - this.barWidth / 2;
|
|
195
|
-
scroll = (offset /
|
|
239
|
+
scroll = (offset / this.thumbTravelDistance) * this.distance;
|
|
196
240
|
}
|
|
197
241
|
this.scroll = Math.max(0, Math.min(scroll, this.distance));
|
|
198
242
|
}
|
|
@@ -203,24 +247,33 @@ class Scrollbar {
|
|
|
203
247
|
this.clientX = 0;
|
|
204
248
|
this.clientY = 0;
|
|
205
249
|
}
|
|
206
|
-
onMouseMove(e) {
|
|
250
|
+
onMouseMove(e, isPointerInsideTable) {
|
|
207
251
|
const { clientX, clientY, buttons } = e;
|
|
208
252
|
const offsetX = this.ctx.zoomScale.toLogical(e.offsetX);
|
|
209
253
|
const offsetY = this.ctx.zoomScale.toLogical(e.offsetY);
|
|
254
|
+
let needsFullRedraw = false;
|
|
255
|
+
if (shouldStartInnerScrollbarShowTimer(this.ctx.config, isPointerInsideTable)) {
|
|
256
|
+
this.startInnerShowTimer();
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
needsFullRedraw = this.hideInnerScrollbar();
|
|
260
|
+
}
|
|
210
261
|
// 没有鼠标按下时不处理,要重置抬起事件
|
|
211
262
|
// 悬浮提示
|
|
212
|
-
|
|
263
|
+
const isScrollbarHover = this.canInteractWithScrollbar() && (this.isOnScrollbar(offsetX, offsetY) || this.isOnTrack(offsetX, offsetY));
|
|
264
|
+
if (isScrollbarHover && e.target === this.ctx.canvasElement) {
|
|
213
265
|
this.isFocus = true;
|
|
266
|
+
this.ctx.stageElement.style.cursor = 'pointer';
|
|
214
267
|
}
|
|
215
268
|
else {
|
|
216
269
|
this.isFocus = false;
|
|
217
270
|
}
|
|
218
271
|
if (buttons === 0) {
|
|
219
|
-
return;
|
|
272
|
+
return needsFullRedraw;
|
|
220
273
|
}
|
|
221
274
|
// 拖拽移动滚动条
|
|
222
275
|
if (clientX == this.clientX && clientY == this.clientY)
|
|
223
|
-
return;
|
|
276
|
+
return needsFullRedraw;
|
|
224
277
|
let offset = 0;
|
|
225
278
|
if (this.type === 'horizontal') {
|
|
226
279
|
offset = clientX - this.clientX;
|
|
@@ -234,13 +287,14 @@ class Scrollbar {
|
|
|
234
287
|
// scroll= 开始滚动条位置+(鼠标移动的距离/可见区域的长度)*滚动条的长度
|
|
235
288
|
let scroll = 0;
|
|
236
289
|
if (this.type === 'vertical') {
|
|
237
|
-
scroll = this.dragStart + (offset /
|
|
290
|
+
scroll = this.dragStart + (offset / this.thumbTravelDistance) * this.distance;
|
|
238
291
|
}
|
|
239
292
|
else {
|
|
240
|
-
scroll = this.dragStart + (offset /
|
|
293
|
+
scroll = this.dragStart + (offset / this.thumbTravelDistance) * this.distance;
|
|
241
294
|
}
|
|
242
295
|
this.scroll = Math.max(0, Math.min(scroll, this.distance));
|
|
243
296
|
}
|
|
297
|
+
return needsFullRedraw;
|
|
244
298
|
}
|
|
245
299
|
isPointInElement(pointX, pointY, elementX, elementY, elementWidth, elementHeight) {
|
|
246
300
|
return (pointX >= elementX &&
|
|
@@ -263,6 +317,47 @@ class Scrollbar {
|
|
|
263
317
|
isOnTrack(x, y) {
|
|
264
318
|
return this.isPointInElement(x, y, this.trackX, this.trackY, this.trackWidth, this.trackHeight);
|
|
265
319
|
}
|
|
320
|
+
isInnerMode() {
|
|
321
|
+
return isInnerScrollbarMode(this.ctx.config);
|
|
322
|
+
}
|
|
323
|
+
shouldDrawInnerScrollbar() {
|
|
324
|
+
return shouldDrawScrollbar(this.ctx.config, {
|
|
325
|
+
innerVisible: this.innerVisible,
|
|
326
|
+
isFocus: this.isFocus,
|
|
327
|
+
isDragging: this.isDragging,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
canInteractWithScrollbar() {
|
|
331
|
+
return !this.isInnerMode() || this.shouldDrawInnerScrollbar();
|
|
332
|
+
}
|
|
333
|
+
startInnerShowTimer() {
|
|
334
|
+
if (!this.isInnerMode() || this.innerVisible || this.innerShowTimer) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
const delay = Math.max(0, this.ctx.config.SCROLLBAR_SHOW_DELAY || 0);
|
|
338
|
+
this.innerShowTimer = window.setTimeout(() => {
|
|
339
|
+
this.innerVisible = true;
|
|
340
|
+
this.innerShowTimer = 0;
|
|
341
|
+
this.ctx.emit('draw');
|
|
342
|
+
}, delay);
|
|
343
|
+
}
|
|
344
|
+
cancelInnerShowTimer() {
|
|
345
|
+
if (!this.innerShowTimer) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
clearTimeout(this.innerShowTimer);
|
|
349
|
+
this.innerShowTimer = 0;
|
|
350
|
+
}
|
|
351
|
+
hideInnerScrollbar() {
|
|
352
|
+
if (!this.isInnerMode() || this.isDragging) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
const needsFullRedraw = this.innerVisible || this.isFocus;
|
|
356
|
+
this.cancelInnerShowTimer();
|
|
357
|
+
this.innerVisible = false;
|
|
358
|
+
this.isFocus = false;
|
|
359
|
+
return needsFullRedraw;
|
|
360
|
+
}
|
|
266
361
|
updateScroll(e) {
|
|
267
362
|
const deltaX = e.deltaX;
|
|
268
363
|
const deltaY = e.deltaY;
|
|
@@ -284,67 +379,66 @@ class Scrollbar {
|
|
|
284
379
|
}
|
|
285
380
|
}
|
|
286
381
|
updatedSize() {
|
|
287
|
-
const { body, header, stageHeight, stageWidth, config: {
|
|
382
|
+
const { body, header, stageHeight, stageWidth, config: { SCROLLER_SIZE = 0, BORDER }, } = this.ctx;
|
|
383
|
+
const layoutScrollerTrackSize = getLayoutScrollerTrackSize(this.ctx.config);
|
|
384
|
+
const overlayScrollerTrackSize = getOverlayScrollerTrackSize(this.ctx.config);
|
|
288
385
|
const visibleWidth = stageWidth;
|
|
289
386
|
const visibleHeight = stageHeight;
|
|
290
387
|
const headerHeight = header.height;
|
|
291
388
|
const headerWidth = header.width;
|
|
292
389
|
const bodyHeight = body.height;
|
|
293
390
|
const footerHeight = this.ctx.footer.height;
|
|
391
|
+
const verticalVisibleDistance = visibleHeight - layoutScrollerTrackSize - headerHeight;
|
|
392
|
+
const horizontalVisibleDistance = visibleWidth - layoutScrollerTrackSize;
|
|
393
|
+
const verticalDistance = Math.max(0, bodyHeight - verticalVisibleDistance + footerHeight);
|
|
394
|
+
const horizontalDistance = Math.max(0, headerWidth - horizontalVisibleDistance);
|
|
395
|
+
const thumbEndInset = getScrollbarThumbEndInset(this.ctx.config);
|
|
294
396
|
if (this.type === 'vertical') {
|
|
295
|
-
this.visibleDistance =
|
|
296
|
-
this.distance =
|
|
297
|
-
this.
|
|
397
|
+
this.visibleDistance = verticalVisibleDistance;
|
|
398
|
+
this.distance = verticalDistance;
|
|
399
|
+
const cornerOffset = getScrollbarCornerOffset(this.ctx.config, horizontalDistance > 0);
|
|
400
|
+
this.thumbTrackDistance = Math.max(0, this.visibleDistance - cornerOffset);
|
|
401
|
+
this.trackX = visibleWidth - overlayScrollerTrackSize;
|
|
298
402
|
this.trackY = 0;
|
|
299
403
|
// 分割线
|
|
300
|
-
this.splitPoints = [this.trackX, headerHeight, this.trackX +
|
|
301
|
-
this.trackWidth =
|
|
302
|
-
this.trackHeight = visibleHeight;
|
|
404
|
+
this.splitPoints = [this.trackX, headerHeight, this.trackX + overlayScrollerTrackSize, headerHeight];
|
|
405
|
+
this.trackWidth = overlayScrollerTrackSize;
|
|
406
|
+
this.trackHeight = Math.max(0, visibleHeight - cornerOffset);
|
|
303
407
|
// 滚动条的X位置=轨道的X位置+(轨道的宽度-滚动条的宽度)/2
|
|
304
|
-
this.barX = this.trackX - 1 + (
|
|
408
|
+
this.barX = this.trackX - 1 + (overlayScrollerTrackSize - SCROLLER_SIZE) / 2;
|
|
305
409
|
this.barWidth = SCROLLER_SIZE;
|
|
306
|
-
|
|
307
|
-
|
|
410
|
+
this.barHeight = getScrollbarThumbSize(this.distance, this.visibleDistance, bodyHeight + footerHeight, this.thumbTrackDistance);
|
|
411
|
+
this.thumbTravelDistance = Math.max(0, this.thumbTrackDistance - this.barHeight - thumbEndInset);
|
|
308
412
|
// 最小30,超出可见区域则隐藏
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
else if (_barHeight > this.visibleDistance) {
|
|
313
|
-
_barHeight = 0;
|
|
314
|
-
}
|
|
315
|
-
this.barHeight = _barHeight;
|
|
316
|
-
this.barY = headerHeight + (this.scroll / this.distance) * (this.visibleDistance - this.barHeight);
|
|
413
|
+
const progress = this.distance ? this.scroll / this.distance : 0;
|
|
414
|
+
this.barY = headerHeight + progress * this.thumbTravelDistance;
|
|
317
415
|
// 范围限制
|
|
318
416
|
this.scroll = Math.max(0, Math.min(this.scroll, this.distance));
|
|
319
417
|
}
|
|
320
418
|
else {
|
|
321
|
-
this.visibleDistance =
|
|
322
|
-
this.distance =
|
|
419
|
+
this.visibleDistance = horizontalVisibleDistance;
|
|
420
|
+
this.distance = horizontalDistance;
|
|
421
|
+
const cornerOffset = getScrollbarCornerOffset(this.ctx.config, verticalDistance > 0);
|
|
422
|
+
this.thumbTrackDistance = Math.max(0, this.visibleDistance - cornerOffset);
|
|
323
423
|
// 分割线
|
|
324
424
|
this.splitPoints = [
|
|
325
|
-
visibleWidth -
|
|
326
|
-
visibleHeight -
|
|
327
|
-
visibleWidth -
|
|
425
|
+
visibleWidth - overlayScrollerTrackSize,
|
|
426
|
+
visibleHeight - overlayScrollerTrackSize,
|
|
427
|
+
visibleWidth - overlayScrollerTrackSize,
|
|
328
428
|
visibleHeight,
|
|
329
429
|
];
|
|
330
|
-
const offset = BORDER ? 0 : 0.5; // 解决边框问题,补偿0.5px
|
|
430
|
+
const offset = shouldDrawScrollerBorder(BORDER) ? 0 : 0.5; // 解决边框问题,补偿0.5px
|
|
331
431
|
this.trackX = 0;
|
|
332
|
-
this.trackY = visibleHeight -
|
|
333
|
-
this.trackWidth = visibleWidth;
|
|
334
|
-
this.trackHeight =
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
this.barY = this.trackY - 1 + (
|
|
432
|
+
this.trackY = visibleHeight - overlayScrollerTrackSize + offset;
|
|
433
|
+
this.trackWidth = Math.max(0, visibleWidth - cornerOffset);
|
|
434
|
+
this.trackHeight = overlayScrollerTrackSize;
|
|
435
|
+
this.barWidth = getScrollbarThumbSize(this.distance, this.visibleDistance, headerWidth, this.thumbTrackDistance);
|
|
436
|
+
this.thumbTravelDistance = Math.max(0, this.thumbTrackDistance - this.barWidth - thumbEndInset);
|
|
437
|
+
this.barY = this.trackY - 1 + (overlayScrollerTrackSize - SCROLLER_SIZE) / 2;
|
|
338
438
|
// 最小30,超出可见区域则隐藏
|
|
339
|
-
if (_barWidth < 30) {
|
|
340
|
-
_barWidth = 30;
|
|
341
|
-
}
|
|
342
|
-
else if (_barWidth >= this.visibleDistance) {
|
|
343
|
-
_barWidth = 0;
|
|
344
|
-
}
|
|
345
|
-
this.barWidth = _barWidth;
|
|
346
439
|
this.barHeight = SCROLLER_SIZE;
|
|
347
|
-
this.
|
|
440
|
+
const progress = this.distance ? this.scroll / this.distance : 0;
|
|
441
|
+
this.barX = progress * this.thumbTravelDistance;
|
|
348
442
|
// 范围限制
|
|
349
443
|
this.scroll = Math.max(0, Math.min(this.scroll, this.distance));
|
|
350
444
|
}
|
|
@@ -352,29 +446,103 @@ class Scrollbar {
|
|
|
352
446
|
draw() {
|
|
353
447
|
const { config: { SCROLLER_FOCUS_COLOR, SCROLLER_COLOR, BORDER_COLOR, BORDER, SCROLLER_TRACK_COLOR }, } = this.ctx;
|
|
354
448
|
this.updatedSize();
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
449
|
+
if (this.isInnerMode() && !this.shouldDrawInnerScrollbar()) {
|
|
450
|
+
return this.isFocus || this.isDragging;
|
|
451
|
+
}
|
|
452
|
+
const drawTrackBorder = shouldDrawScrollbarTrackBorder(this.ctx.config);
|
|
453
|
+
const drawTrackBackground = shouldDrawScrollbarTrackBackground(this.ctx.config);
|
|
454
|
+
const borderColor = drawTrackBorder && shouldDrawScrollerBorder(BORDER) ? BORDER_COLOR : 'transparent';
|
|
455
|
+
const hasScrollbar = this.hasScrollbar();
|
|
456
|
+
const drawTrack = shouldDrawScrollerTrack(BORDER, hasScrollbar);
|
|
359
457
|
// 轨道
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
458
|
+
if (drawTrackBackground && drawTrack) {
|
|
459
|
+
this.ctx.paint.drawRect(this.trackX, this.trackY, this.trackWidth, this.trackHeight, {
|
|
460
|
+
fillColor: SCROLLER_TRACK_COLOR,
|
|
461
|
+
});
|
|
462
|
+
this.drawTrackHeaderBackground();
|
|
463
|
+
if (drawTrackBorder) {
|
|
464
|
+
this.ctx.paint.drawRect(this.trackX, this.trackY, this.trackWidth, this.trackHeight, {
|
|
465
|
+
borderColor,
|
|
466
|
+
});
|
|
467
|
+
this.drawRightBoundaryBorder();
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
else if (drawTrackBackground) {
|
|
471
|
+
this.drawInactiveTrackBackground();
|
|
472
|
+
}
|
|
364
473
|
// 滚动条
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
474
|
+
if (hasScrollbar) {
|
|
475
|
+
this.ctx.paint.drawRect(this.barX, this.barY, this.barWidth, this.barHeight, {
|
|
476
|
+
fillColor: this.isFocus || this.isDragging ? SCROLLER_FOCUS_COLOR : SCROLLER_COLOR,
|
|
477
|
+
radius: 4,
|
|
478
|
+
});
|
|
479
|
+
}
|
|
369
480
|
// 分割线范围外
|
|
370
|
-
if (this.splitPoints.length > 0) {
|
|
481
|
+
if (drawTrackBorder && drawTrack && this.splitPoints.length > 0) {
|
|
371
482
|
this.ctx.paint.drawLine(this.splitPoints, {
|
|
372
483
|
borderColor,
|
|
373
484
|
borderWidth: 1,
|
|
374
485
|
});
|
|
375
486
|
}
|
|
376
|
-
|
|
377
|
-
|
|
487
|
+
return this.isFocus || this.isDragging;
|
|
488
|
+
}
|
|
489
|
+
drawTrackHeaderBackground() {
|
|
490
|
+
if (this.type !== 'vertical' || this.trackWidth <= 0) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
const { header, config: { HEADER_BG_COLOR }, } = this.ctx;
|
|
494
|
+
const height = Math.max(0, Math.min(header.height, this.trackHeight));
|
|
495
|
+
if (height <= 0) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
this.ctx.paint.drawRect(this.trackX, this.trackY, this.trackWidth, height, {
|
|
499
|
+
fillColor: HEADER_BG_COLOR,
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
drawInactiveTrackBackground() {
|
|
503
|
+
if (this.type !== 'vertical') {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
const { footer, header, scrollY, stageHeight, config: { BODY_BG_COLOR, FOOTER_BG_COLOR, FOOTER_FIXED, FOOTER_POSITION, HEADER_BG_COLOR, SCROLLER_TRACK_SIZE = 0, }, } = this.ctx;
|
|
507
|
+
const bottom = Math.max(0, stageHeight - SCROLLER_TRACK_SIZE);
|
|
508
|
+
if (bottom <= 0 || this.trackWidth <= 0) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
this.ctx.paint.drawRect(this.trackX, 0, this.trackWidth, bottom, {
|
|
512
|
+
fillColor: BODY_BG_COLOR,
|
|
513
|
+
});
|
|
514
|
+
this.ctx.paint.drawRect(this.trackX, 0, this.trackWidth, header.height, {
|
|
515
|
+
fillColor: HEADER_BG_COLOR,
|
|
516
|
+
});
|
|
517
|
+
if (!footer.height) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const footerY = FOOTER_FIXED
|
|
521
|
+
? FOOTER_POSITION === 'top'
|
|
522
|
+
? header.height
|
|
523
|
+
: bottom - footer.height
|
|
524
|
+
: footer.y - scrollY;
|
|
525
|
+
const y = Math.max(header.height, Math.min(footerY, bottom));
|
|
526
|
+
const height = Math.max(0, Math.min(footer.height, bottom - y));
|
|
527
|
+
if (height > 0) {
|
|
528
|
+
this.ctx.paint.drawRect(this.trackX, y, this.trackWidth, height, {
|
|
529
|
+
fillColor: FOOTER_BG_COLOR,
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
drawRightBoundaryBorder() {
|
|
534
|
+
const { stageHeight, config: { BORDER, BORDER_COLOR, SCROLLER_TRACK_SIZE = 0 }, } = this.ctx;
|
|
535
|
+
if (this.type !== 'vertical' || !shouldDrawRightBoundaryBorder(BORDER) || SCROLLER_TRACK_SIZE <= 0) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
const bottom = stageHeight - SCROLLER_TRACK_SIZE;
|
|
539
|
+
if (bottom <= 0) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
this.ctx.paint.drawLine([this.trackX, 0, this.trackX, bottom], {
|
|
543
|
+
borderColor: BORDER_COLOR,
|
|
544
|
+
borderWidth: 1,
|
|
545
|
+
});
|
|
378
546
|
}
|
|
379
547
|
}
|
|
380
548
|
export default class Scroller {
|
|
@@ -434,6 +602,7 @@ export default class Scroller {
|
|
|
434
602
|
this.ctx.on('mousedown', (e) => this.onMouseDown(e));
|
|
435
603
|
this.ctx.on('mousemove', (e) => this.onMouseMove(e));
|
|
436
604
|
this.ctx.on('mouseup', () => this.onMouseUp());
|
|
605
|
+
this.ctx.on('mouseout', (e) => this.onMouseOut(e));
|
|
437
606
|
this.ctx.on('touchmove', (e) => this.onTouchmove(e));
|
|
438
607
|
this.ctx.on('touchstart', (e) => {
|
|
439
608
|
this.onTouchstart(e);
|
|
@@ -481,9 +650,16 @@ export default class Scroller {
|
|
|
481
650
|
this.draw();
|
|
482
651
|
}
|
|
483
652
|
onMouseMove(e) {
|
|
484
|
-
this.
|
|
485
|
-
|
|
486
|
-
this.
|
|
653
|
+
const rect = this.ctx.containerElement.getBoundingClientRect();
|
|
654
|
+
const isPointerInsideTable = e.clientX >= rect.left && e.clientX <= rect.right && e.clientY >= rect.top && e.clientY <= rect.bottom;
|
|
655
|
+
const verticalNeedsFullRedraw = this.verticalScrollbar.onMouseMove(e, isPointerInsideTable);
|
|
656
|
+
const horizontalNeedsFullRedraw = this.horizontalScrollbar.onMouseMove(e, isPointerInsideTable);
|
|
657
|
+
if (verticalNeedsFullRedraw || horizontalNeedsFullRedraw) {
|
|
658
|
+
this.ctx.emit('draw');
|
|
659
|
+
}
|
|
660
|
+
else {
|
|
661
|
+
this.draw();
|
|
662
|
+
}
|
|
487
663
|
}
|
|
488
664
|
onMouseUp() {
|
|
489
665
|
this.mousedownHeader = false;
|
|
@@ -491,9 +667,18 @@ export default class Scroller {
|
|
|
491
667
|
this.horizontalScrollbar.onMouseUp();
|
|
492
668
|
this.ctx.scrollerMove = false;
|
|
493
669
|
}
|
|
670
|
+
onMouseOut(e) {
|
|
671
|
+
if (this.ctx.containerElement.contains(e.relatedTarget)) {
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
this.verticalScrollbar.hideInnerScrollbar();
|
|
675
|
+
this.horizontalScrollbar.hideInnerScrollbar();
|
|
676
|
+
this.ctx.emit('draw');
|
|
677
|
+
}
|
|
494
678
|
draw() {
|
|
495
|
-
this.verticalScrollbar.draw();
|
|
496
|
-
this.horizontalScrollbar.draw();
|
|
679
|
+
const verticalFocus = this.verticalScrollbar.draw();
|
|
680
|
+
const horizontalFocus = this.horizontalScrollbar.draw();
|
|
681
|
+
this.ctx.scrollerFocus = verticalFocus || horizontalFocus;
|
|
497
682
|
const scrollX = Math.floor(this.horizontalScrollbar.scroll);
|
|
498
683
|
const scrollY = Math.floor(this.verticalScrollbar.scroll);
|
|
499
684
|
// 只有滚动条发生变化才触发绘制
|