vxe-pc-ui 3.20.2 → 3.20.5
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/es/icon/style.css +1 -1
- package/es/list/src/list.js +3 -2
- package/es/scrollbar/src/scrollbar.js +2 -2
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/tree/src/tree.js +2 -2
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.umd.js +76 -112
- package/lib/index.umd.min.js +1 -1
- package/lib/list/src/list.js +57 -46
- package/lib/list/src/list.min.js +1 -1
- package/lib/scrollbar/src/scrollbar.js +15 -11
- package/lib/scrollbar/src/scrollbar.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/tree/src/tree.js +15 -11
- package/lib/tree/src/tree.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +1 -1
- package/packages/list/src/list.ts +5 -2
- package/packages/scrollbar/src/scrollbar.ts +3 -2
- package/packages/tree/src/tree.ts +3 -2
- package/types/components/gantt-plugins/extend-gantt-chart.d.ts +1 -1
- package/types/components/layout-aside.d.ts +15 -0
- package/types/components/layout-body.d.ts +3 -0
- package/types/components/list.d.ts +15 -0
- package/types/components/number-input.d.ts +12 -2
- package/types/components/table-plugins/extend-pivot-table.d.ts +1 -1
- package/types/components/table.d.ts +3 -0
- package/types/components/tree.d.ts +12 -0
- package/es/scrollbar/src/util.js +0 -54
- package/lib/scrollbar/src/util.js +0 -63
- package/lib/scrollbar/src/util.min.js +0 -1
- package/packages/scrollbar/src/util.ts +0 -57
- /package/es/icon/{iconfont.1792034961185.ttf → iconfont.1792048654011.ttf} +0 -0
- /package/es/icon/{iconfont.1792034961185.woff → iconfont.1792048654011.woff} +0 -0
- /package/es/icon/{iconfont.1792034961185.woff2 → iconfont.1792048654011.woff2} +0 -0
- /package/es/{iconfont.1792034961185.ttf → iconfont.1792048654011.ttf} +0 -0
- /package/es/{iconfont.1792034961185.woff → iconfont.1792048654011.woff} +0 -0
- /package/es/{iconfont.1792034961185.woff2 → iconfont.1792048654011.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1792034961185.ttf → iconfont.1792048654011.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1792034961185.woff → iconfont.1792048654011.woff} +0 -0
- /package/lib/icon/style/{iconfont.1792034961185.woff2 → iconfont.1792048654011.woff2} +0 -0
- /package/lib/{iconfont.1792034961185.ttf → iconfont.1792048654011.ttf} +0 -0
- /package/lib/{iconfont.1792034961185.woff → iconfont.1792048654011.woff} +0 -0
- /package/lib/{iconfont.1792034961185.woff2 → iconfont.1792048654011.woff2} +0 -0
|
@@ -3,14 +3,15 @@ import { defineVxeComponent } from '../../ui/src/comp'
|
|
|
3
3
|
import XEUtils from 'xe-utils'
|
|
4
4
|
import { VxeUI } from '../../ui'
|
|
5
5
|
import { toCssUnit } from '../../ui/src/dom'
|
|
6
|
-
import { getThumbOffsetSize, getThumbSize, getScrollFromClick, getScrollFromDrag } from './util'
|
|
7
6
|
import { getDefaultConfig } from '../../ui/src/utils'
|
|
8
7
|
|
|
9
8
|
import VxeLoadingComponent from '../../loading'
|
|
10
9
|
|
|
11
10
|
import type { ScrollbarReactData, ScrollbarInternalData, VxeScrollbarEmits, ValueOf, VxeScrollbarPropTypes, VxeComponentStyleType } from '../../../types'
|
|
12
11
|
|
|
13
|
-
const { getConfig, createEvent, domUtils, globalResize, globalEvents, renderEmptyElement } = VxeUI
|
|
12
|
+
const { getConfig, createEvent, domUtils, scrollbarUtils, globalResize, globalEvents, renderEmptyElement } = VxeUI
|
|
13
|
+
|
|
14
|
+
const { getThumbOffsetSize, getThumbSize, getScrollFromClick, getScrollFromDrag } = scrollbarUtils
|
|
14
15
|
|
|
15
16
|
function createReactData (): ScrollbarReactData {
|
|
16
17
|
return {
|
|
@@ -9,7 +9,6 @@ import { crossTreeDragNodeGlobal, getCrossTreeDragNodeInfo } from './store'
|
|
|
9
9
|
import { toCssUnit, isScale, getPaddingTopBottomSize, addClass, removeClass, getTpImg, hasControlKey, getEventTargetNode, hasClass } from '../../ui/src/dom'
|
|
10
10
|
import { isEnableConf, enModelValue, deModelValue, getText, getDefaultConfig } from '../../ui/src/utils'
|
|
11
11
|
import { moveRowAnimateToTb, clearRowAnimate } from '../../ui/src/anime'
|
|
12
|
-
import { getThumbOffsetSize, getThumbSize, getScrollFromClick, getScrollFromDrag } from '../../scrollbar/src/util'
|
|
13
12
|
import VxeLoadingComponent from '../../loading'
|
|
14
13
|
import VxeTooltipComponent from '../../tooltip'
|
|
15
14
|
|
|
@@ -17,7 +16,9 @@ import type { TreeReactData, VxeTreeEmits, VxeTreeConstructor, VxeTreePropTypes,
|
|
|
17
16
|
|
|
18
17
|
const { warnLog, errLog } = createComponentLog('tree')
|
|
19
18
|
|
|
20
|
-
const { menus, getConfig, getI18n, getIcon } = VxeUI
|
|
19
|
+
const { menus, scrollbarUtils, getConfig, getI18n, getIcon } = VxeUI
|
|
20
|
+
|
|
21
|
+
const { getThumbOffsetSize, getThumbSize, getScrollFromClick, getScrollFromDrag } = scrollbarUtils
|
|
21
22
|
|
|
22
23
|
let crossTreeDragNodeObj: {
|
|
23
24
|
$oldTree: VxeTreeConstructor & VxeTreePrivateMethods
|
|
@@ -37,7 +37,7 @@ export interface VxeGanttExtendChartPrivateMethods<D = any> {
|
|
|
37
37
|
* 内部方法
|
|
38
38
|
* @private
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
handleTaskBarModnEvent(evnt: MouseEvent, params: {
|
|
41
41
|
$gantt: VxeGanttConstructor<D>
|
|
42
42
|
row: D
|
|
43
43
|
scaleType: VxeGanttDefines.ColumnScaleType
|
|
@@ -43,10 +43,25 @@ export namespace VxeLayoutAsidePropTypes {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export interface VxeLayoutAsideProps {
|
|
46
|
+
/**
|
|
47
|
+
* 宽度
|
|
48
|
+
*/
|
|
46
49
|
width?: VxeLayoutAsidePropTypes.Width
|
|
50
|
+
/**
|
|
51
|
+
* 是否折叠
|
|
52
|
+
*/
|
|
47
53
|
collapsed?: VxeLayoutAsidePropTypes.Collapsed
|
|
54
|
+
/**
|
|
55
|
+
* 折叠后宽度
|
|
56
|
+
*/
|
|
48
57
|
collapseWidth?: VxeLayoutAsidePropTypes.CollapseWidth
|
|
58
|
+
/**
|
|
59
|
+
* 加载中
|
|
60
|
+
*/
|
|
49
61
|
loading?: VxeLayoutAsidePropTypes.Loading
|
|
62
|
+
/**
|
|
63
|
+
* 显示内边距
|
|
64
|
+
*/
|
|
50
65
|
padding?: VxeLayoutAsidePropTypes.Padding
|
|
51
66
|
size?: VxeLayoutAsidePropTypes.Size
|
|
52
67
|
collapseConfig?: VxeLayoutAsidePropTypes.CollapseConfig
|
|
@@ -38,6 +38,9 @@ export namespace VxeLayoutBodyPropTypes {
|
|
|
38
38
|
}
|
|
39
39
|
export interface VxeLayoutBodyProps {
|
|
40
40
|
size?: VxeLayoutBodyPropTypes.Size
|
|
41
|
+
/**
|
|
42
|
+
* 加载中
|
|
43
|
+
*/
|
|
41
44
|
loading?: VxeLayoutBodyPropTypes.Loading
|
|
42
45
|
padding?: VxeLayoutBodyPropTypes.Padding
|
|
43
46
|
showBacktop?: VxeLayoutBodyPropTypes.ShowBacktop
|
|
@@ -235,8 +235,17 @@ export namespace VxeListPropTypes {
|
|
|
235
235
|
export interface VxeListProps<D = any> {
|
|
236
236
|
size?: VxeListPropTypes.Size
|
|
237
237
|
data?: D[]
|
|
238
|
+
/**
|
|
239
|
+
* 高度
|
|
240
|
+
*/
|
|
238
241
|
height?: VxeListPropTypes.Height
|
|
242
|
+
/**
|
|
243
|
+
* 最大高度
|
|
244
|
+
*/
|
|
239
245
|
maxHeight?: VxeListPropTypes.MaxHeight
|
|
246
|
+
/**
|
|
247
|
+
* 加载中
|
|
248
|
+
*/
|
|
240
249
|
loading?: VxeListPropTypes.Loading
|
|
241
250
|
autoResize?: VxeListPropTypes.AutoResize
|
|
242
251
|
syncResize?: VxeListPropTypes.SyncResize
|
|
@@ -250,7 +259,13 @@ export interface VxeListProps<D = any> {
|
|
|
250
259
|
checkboxConfig?: VxeListPropTypes.CheckboxConfig
|
|
251
260
|
rowConfig?: VxeListPropTypes.RowConfig
|
|
252
261
|
dragConfig?: VxeListPropTypes.DragConfig
|
|
262
|
+
/**
|
|
263
|
+
* 右键菜单配置项
|
|
264
|
+
*/
|
|
253
265
|
menuConfig?: VxeListPropTypes.MenuConfig
|
|
266
|
+
/**
|
|
267
|
+
* 纵向虚拟滚动配置
|
|
268
|
+
*/
|
|
254
269
|
virtualYConfig?: VxeListPropTypes.VirtualYConfig
|
|
255
270
|
/**
|
|
256
271
|
* 使用虚拟滚动条
|
|
@@ -32,7 +32,6 @@ export namespace VxeNumberInputPropTypes {
|
|
|
32
32
|
export type FloatContent = string
|
|
33
33
|
export type FloatAlign = VxeComponentAlignType
|
|
34
34
|
export type MaxLength = string | number | null
|
|
35
|
-
export type Multiple = boolean
|
|
36
35
|
export type AutoComplete = string
|
|
37
36
|
export type Align = string
|
|
38
37
|
export type Form = string
|
|
@@ -119,6 +118,9 @@ export namespace VxeNumberInputPropTypes {
|
|
|
119
118
|
}
|
|
120
119
|
|
|
121
120
|
export interface VxeNumberInputProps {
|
|
121
|
+
/**
|
|
122
|
+
* 尺寸大小
|
|
123
|
+
*/
|
|
122
124
|
size?: VxeNumberInputPropTypes.Size
|
|
123
125
|
value?: VxeNumberInputPropTypes.ModelValue
|
|
124
126
|
className?: VxeNumberInputPropTypes.ClassName
|
|
@@ -129,7 +131,13 @@ export interface VxeNumberInputProps {
|
|
|
129
131
|
width?: VxeNumberInputPropTypes.Width
|
|
130
132
|
immediate?: VxeNumberInputPropTypes.Immediate
|
|
131
133
|
name?: VxeNumberInputPropTypes.Name
|
|
134
|
+
/**
|
|
135
|
+
* 控件类型
|
|
136
|
+
*/
|
|
132
137
|
type?: VxeNumberInputPropTypes.Type
|
|
138
|
+
/**
|
|
139
|
+
* 显示清除按钮
|
|
140
|
+
*/
|
|
133
141
|
clearable?: VxeNumberInputPropTypes.Clearable
|
|
134
142
|
readonly?: VxeNumberInputPropTypes.Readonly
|
|
135
143
|
disabled?: VxeNumberInputPropTypes.Disabled
|
|
@@ -137,8 +145,10 @@ export interface VxeNumberInputProps {
|
|
|
137
145
|
floatContent?: VxeNumberInputPropTypes.FloatContent
|
|
138
146
|
floatAlign?: VxeNumberInputPropTypes.FloatAlign
|
|
139
147
|
maxLength?: VxeNumberInputPropTypes.MaxLength
|
|
140
|
-
multiple?: VxeNumberInputPropTypes.Multiple
|
|
141
148
|
autoComplete?: VxeNumberInputPropTypes.AutoComplete
|
|
149
|
+
/**
|
|
150
|
+
* 对齐方式
|
|
151
|
+
*/
|
|
142
152
|
align?: VxeNumberInputPropTypes.Align
|
|
143
153
|
form?: VxeNumberInputPropTypes.Form
|
|
144
154
|
|
|
@@ -45,7 +45,7 @@ export interface VxeTableExtendPivotTablePrivateMethods<D = any> {
|
|
|
45
45
|
* 内部方法
|
|
46
46
|
* @private
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
handlePivotTableAggPanelDragendEvent(evnt: DragEvent): void
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
declare module '../table' {
|
|
@@ -339,10 +339,22 @@ export namespace VxeTreePropTypes {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
export interface VxeTreeProps<D = any> {
|
|
342
|
+
/**
|
|
343
|
+
* 数据源
|
|
344
|
+
*/
|
|
342
345
|
data?: VxeTreePropTypes.Data<D>
|
|
343
346
|
autoResize?: VxeTreePropTypes.AutoResize
|
|
347
|
+
/**
|
|
348
|
+
* 高度
|
|
349
|
+
*/
|
|
344
350
|
height?: VxeTreePropTypes.Height
|
|
351
|
+
/**
|
|
352
|
+
* 最小高度
|
|
353
|
+
*/
|
|
345
354
|
minHeight?: VxeTreePropTypes.MinHeight
|
|
355
|
+
/**
|
|
356
|
+
* 最大高度
|
|
357
|
+
*/
|
|
346
358
|
maxHeight?: VxeTreePropTypes.MaxHeight
|
|
347
359
|
loading?: VxeTreePropTypes.Loading
|
|
348
360
|
loadingConfig?: VxeTreePropTypes.LoadingConfig
|
package/es/scrollbar/src/util.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getScrollFromClick = getScrollFromClick;
|
|
7
|
-
exports.getScrollFromDrag = getScrollFromDrag;
|
|
8
|
-
exports.getThumbOffsetSize = getThumbOffsetSize;
|
|
9
|
-
exports.getThumbSize = getThumbSize;
|
|
10
|
-
/**
|
|
11
|
-
* 计算滚动条滑块的长度
|
|
12
|
-
*/
|
|
13
|
-
function getThumbSize(viewportSize, contentSize, trackSize) {
|
|
14
|
-
if (contentSize <= viewportSize) {
|
|
15
|
-
return 0;
|
|
16
|
-
}
|
|
17
|
-
var ratio = viewportSize / contentSize;
|
|
18
|
-
var ideal = trackSize * ratio;
|
|
19
|
-
return Math.max(20, Math.min(ideal, trackSize));
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* 计算滚动条滑块的偏移位置
|
|
23
|
-
*/
|
|
24
|
-
function getThumbOffsetSize(offsetSize, viewportSize, contentSize, trackSize, thumbSize) {
|
|
25
|
-
var maxScroll = contentSize - viewportSize;
|
|
26
|
-
if (maxScroll <= 0) {
|
|
27
|
-
return 0;
|
|
28
|
-
}
|
|
29
|
-
var maxThumbOffset = trackSize - thumbSize;
|
|
30
|
-
if (maxThumbOffset <= 0) {
|
|
31
|
-
return 0;
|
|
32
|
-
}
|
|
33
|
-
var clamped = Math.min(Math.max(offsetSize, 0), maxScroll);
|
|
34
|
-
var ratio = clamped / maxScroll;
|
|
35
|
-
return ratio * maxThumbOffset;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* 根据点击轨道的位置,计算滑块的偏移位置
|
|
39
|
-
*/
|
|
40
|
-
function getScrollFromClick(clickPosition, viewportSize, contentSize, trackSize, thumbSize) {
|
|
41
|
-
var maxThumbOffset = trackSize - thumbSize;
|
|
42
|
-
var maxScroll = contentSize - viewportSize;
|
|
43
|
-
if (maxScroll <= 0 || maxThumbOffset <= 0) {
|
|
44
|
-
return 0;
|
|
45
|
-
}
|
|
46
|
-
var thumbOffset = clickPosition - thumbSize / 2;
|
|
47
|
-
thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset);
|
|
48
|
-
var scrollOffset = thumbOffset / maxThumbOffset * maxScroll;
|
|
49
|
-
return scrollOffset;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* 拖拽 thumb 时,根据鼠标位置计算滑块的偏移位置
|
|
53
|
-
*/
|
|
54
|
-
function getScrollFromDrag(pointerPosition, dragOffset, viewportSize, contentSize, trackSize, thumbSize) {
|
|
55
|
-
var maxScroll = contentSize - viewportSize;
|
|
56
|
-
var maxThumbOffset = trackSize - thumbSize;
|
|
57
|
-
if (maxScroll <= 0 || maxThumbOffset <= 0) {
|
|
58
|
-
return 0;
|
|
59
|
-
}
|
|
60
|
-
var thumbOffset = pointerPosition - dragOffset;
|
|
61
|
-
thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset);
|
|
62
|
-
return thumbOffset / maxThumbOffset * maxScroll;
|
|
63
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function getThumbSize(t,e,r){return e<=t?0:Math.max(20,Math.min(r*(t/e),r))}function getThumbOffsetSize(t,e,r,o,m){r-=e;return r<=0||(e=o-m)<=0?0:Math.min(Math.max(t,0),r)/r*e}function getScrollFromClick(t,e,r,o,m){o-=m,r-=e;return r<=0||o<=0?0:(e=t-m/2,(e=Math.min(Math.max(e,0),o))/o*r)}function getScrollFromDrag(t,e,r,o,m,i){o-=r,r=m-i;return o<=0||r<=0?0:(m=t-e,(m=Math.min(Math.max(m,0),r))/r*o)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getScrollFromClick=getScrollFromClick,exports.getScrollFromDrag=getScrollFromDrag,exports.getThumbOffsetSize=getThumbOffsetSize,exports.getThumbSize=getThumbSize;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 计算滚动条滑块的长度
|
|
3
|
-
*/
|
|
4
|
-
export function getThumbSize (viewportSize: number, contentSize: number, trackSize: number) {
|
|
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
|
-
*/
|
|
16
|
-
export function getThumbOffsetSize (offsetSize: number, viewportSize: number, contentSize: number, trackSize: number, thumbSize: number) {
|
|
17
|
-
const maxScroll = contentSize - viewportSize
|
|
18
|
-
if (maxScroll <= 0) {
|
|
19
|
-
return 0
|
|
20
|
-
}
|
|
21
|
-
const maxThumbOffset = trackSize - thumbSize
|
|
22
|
-
if (maxThumbOffset <= 0) {
|
|
23
|
-
return 0
|
|
24
|
-
}
|
|
25
|
-
const clamped = Math.min(Math.max(offsetSize, 0), maxScroll)
|
|
26
|
-
const ratio = clamped / maxScroll
|
|
27
|
-
return ratio * maxThumbOffset
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 根据点击轨道的位置,计算滑块的偏移位置
|
|
32
|
-
*/
|
|
33
|
-
export function getScrollFromClick (clickPosition: number, viewportSize: number, contentSize: number, trackSize: number, thumbSize: number) {
|
|
34
|
-
const maxThumbOffset = trackSize - thumbSize
|
|
35
|
-
const maxScroll = contentSize - viewportSize
|
|
36
|
-
if (maxScroll <= 0 || maxThumbOffset <= 0) {
|
|
37
|
-
return 0
|
|
38
|
-
}
|
|
39
|
-
let thumbOffset = clickPosition - thumbSize / 2
|
|
40
|
-
thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset)
|
|
41
|
-
const scrollOffset = (thumbOffset / maxThumbOffset) * maxScroll
|
|
42
|
-
return scrollOffset
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 拖拽 thumb 时,根据鼠标位置计算滑块的偏移位置
|
|
47
|
-
*/
|
|
48
|
-
export function getScrollFromDrag (pointerPosition: number, dragOffset: number, viewportSize: number, contentSize: number, trackSize: number, thumbSize: number) {
|
|
49
|
-
const maxScroll = contentSize - viewportSize
|
|
50
|
-
const maxThumbOffset = trackSize - thumbSize
|
|
51
|
-
if (maxScroll <= 0 || maxThumbOffset <= 0) {
|
|
52
|
-
return 0
|
|
53
|
-
}
|
|
54
|
-
let thumbOffset = pointerPosition - dragOffset
|
|
55
|
-
thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset)
|
|
56
|
-
return (thumbOffset / maxThumbOffset) * maxScroll
|
|
57
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|