@aplus-frontend/ui 0.4.9 → 0.4.10
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/src/scroll-view/hooks/use-scroll-back.d.ts +26 -0
- package/es/src/scroll-view/hooks/use-scroll-back.mjs +37 -0
- package/es/src/scroll-view/hooks/use-scroll-smooth.d.ts +26 -0
- package/es/src/scroll-view/hooks/use-scroll-smooth.mjs +50 -0
- package/es/src/scroll-view/index.vue.d.ts +12 -3
- package/es/src/scroll-view/index.vue.mjs +172 -120
- package/es/src/scroll-view/interface.d.ts +40 -0
- package/es/src/scroll-view/utils/index.d.ts +11 -0
- package/es/src/scroll-view/utils/index.mjs +18 -0
- package/lib/src/scroll-view/hooks/use-scroll-back.d.ts +26 -0
- package/lib/src/scroll-view/hooks/use-scroll-back.js +1 -0
- package/lib/src/scroll-view/hooks/use-scroll-smooth.d.ts +26 -0
- package/lib/src/scroll-view/hooks/use-scroll-smooth.js +1 -0
- package/lib/src/scroll-view/index.vue.d.ts +12 -3
- package/lib/src/scroll-view/index.vue.js +1 -1
- package/lib/src/scroll-view/interface.d.ts +40 -0
- package/lib/src/scroll-view/utils/index.d.ts +11 -0
- package/lib/src/scroll-view/utils/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ScrollBarDirection } from '../../scroll-bar';
|
|
2
|
+
import { Ref } from 'vue';
|
|
3
|
+
type ScrollBackOptions = {
|
|
4
|
+
scrollOffset: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
maxScrollDistance: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
timer?: number;
|
|
13
|
+
onScroll?: (direction: ScrollBarDirection) => void;
|
|
14
|
+
onScrollEnd?: (direction: ScrollBarDirection) => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 在特定的时间内滚动到0
|
|
18
|
+
* @param options
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
declare const useScrollBack: ({ scrollOffset, maxScrollDistance, timer, onScroll, onScrollEnd }: ScrollBackOptions) => {
|
|
22
|
+
start: (direction: ScrollBarDirection) => void;
|
|
23
|
+
stop: () => void;
|
|
24
|
+
isActive: Readonly< Ref<boolean, boolean>>;
|
|
25
|
+
};
|
|
26
|
+
export { useScrollBack };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import "../../scroll-bar/index.mjs";
|
|
2
|
+
import { useRafFn as x } from "@vueuse/core";
|
|
3
|
+
import { ensureRangeValue as u } from "../../scroll-bar/utils/index.mjs";
|
|
4
|
+
const m = {
|
|
5
|
+
horizontal: "x",
|
|
6
|
+
vertical: "y"
|
|
7
|
+
}, p = () => {
|
|
8
|
+
}, M = (e) => 1 - Math.pow(1 - e, 3), y = ({
|
|
9
|
+
scrollOffset: e,
|
|
10
|
+
maxScrollDistance: d,
|
|
11
|
+
timer: l = 500,
|
|
12
|
+
onScroll: n = p,
|
|
13
|
+
onScrollEnd: f = p
|
|
14
|
+
}) => {
|
|
15
|
+
let a, t, i;
|
|
16
|
+
const { pause: r, resume: g, isActive: h } = x(
|
|
17
|
+
() => {
|
|
18
|
+
const o = Date.now(), s = m[t], T = o - a, c = u(T / l, 0, 1), v = M(c);
|
|
19
|
+
c === 1 ? (e[s] = 0, r(), n(t), f(t)) : (e[s] = u(
|
|
20
|
+
i * (1 - v),
|
|
21
|
+
0,
|
|
22
|
+
d[s]
|
|
23
|
+
), n(t));
|
|
24
|
+
},
|
|
25
|
+
{ immediate: !1 }
|
|
26
|
+
);
|
|
27
|
+
function w(o) {
|
|
28
|
+
t = o, a = Date.now(), i = e[m[o]], g();
|
|
29
|
+
}
|
|
30
|
+
function D() {
|
|
31
|
+
r();
|
|
32
|
+
}
|
|
33
|
+
return { start: w, stop: D, isActive: h };
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
y as useScrollBack
|
|
37
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ScrollOffsetType } from '../interface';
|
|
2
|
+
import { Ref } from 'vue';
|
|
3
|
+
type ScrollBackOptions = {
|
|
4
|
+
scrollOffset: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
maxScrollDistance: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
timer?: number;
|
|
13
|
+
onScroll?: (x: boolean, y: boolean) => void;
|
|
14
|
+
onScrollEnd?: (x: boolean, y: boolean) => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 在特定的时间内滚动到0
|
|
18
|
+
* @param options
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
declare const useScrollSmooth: ({ scrollOffset, maxScrollDistance, timer, onScroll, onScrollEnd }: ScrollBackOptions) => {
|
|
22
|
+
start: (target: Partial<ScrollOffsetType>) => void;
|
|
23
|
+
stop: () => void;
|
|
24
|
+
isActive: Readonly< Ref<boolean, boolean>>;
|
|
25
|
+
};
|
|
26
|
+
export { useScrollSmooth };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import "../../scroll-bar/index.mjs";
|
|
2
|
+
import { useRafFn as R } from "@vueuse/core";
|
|
3
|
+
import { isDef as f } from "../../utils/index.mjs";
|
|
4
|
+
import { ensureRangeValue as s } from "../../scroll-bar/utils/index.mjs";
|
|
5
|
+
const g = () => {
|
|
6
|
+
}, b = (i) => 1 - Math.pow(1 - i, 3), V = ({
|
|
7
|
+
scrollOffset: i,
|
|
8
|
+
maxScrollDistance: r,
|
|
9
|
+
timer: l = 500,
|
|
10
|
+
onScroll: u = g,
|
|
11
|
+
onScrollEnd: T = g
|
|
12
|
+
}) => {
|
|
13
|
+
let m, e, t, o, n;
|
|
14
|
+
const { pause: a, resume: w, isActive: p } = R(
|
|
15
|
+
() => {
|
|
16
|
+
const v = Date.now() - m, c = s(v / l, 0, 1), y = b(c);
|
|
17
|
+
c === 1 ? (o && (i.x = t.x), n && (i.y = t.y), a(), u(o, n), T(o, n)) : (o && (t.x > e.x ? i.x = s(
|
|
18
|
+
e.x + (t.x - e.x) * y,
|
|
19
|
+
e.x,
|
|
20
|
+
r.x
|
|
21
|
+
) : i.x = s(
|
|
22
|
+
t.x + (e.x - t.x) * (1 - y),
|
|
23
|
+
0,
|
|
24
|
+
e.x
|
|
25
|
+
)), n && (t.y > e.y ? i.y = s(
|
|
26
|
+
e.y + (t.y - e.y) * y,
|
|
27
|
+
e.y,
|
|
28
|
+
r.y
|
|
29
|
+
) : i.y = s(
|
|
30
|
+
t.y + (e.y - t.y) * (1 - y),
|
|
31
|
+
0,
|
|
32
|
+
e.y
|
|
33
|
+
)), u(o, n));
|
|
34
|
+
},
|
|
35
|
+
{ immediate: !1 }
|
|
36
|
+
);
|
|
37
|
+
function d(x) {
|
|
38
|
+
p.value && a(), m = Date.now(), e = {
|
|
39
|
+
x: i.x,
|
|
40
|
+
y: i.y
|
|
41
|
+
}, t = x, o = f(x.x), n = f(x.y), w();
|
|
42
|
+
}
|
|
43
|
+
function h() {
|
|
44
|
+
a();
|
|
45
|
+
}
|
|
46
|
+
return { start: d, stop: h, isActive: p };
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
V as useScrollSmooth
|
|
50
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { ScrollViewProps } from './interface';
|
|
1
|
+
import { ScrollOptions, ScrollViewProps } from './interface';
|
|
2
2
|
import { ScrollBarDirection, InternalScrollBarProps } from '../scroll-bar';
|
|
3
|
-
import { CreateComponentPublicInstanceWithMixins, Ref, ComponentOptionsMixin, PublicProps, GlobalComponents, GlobalDirectives, ComponentProvideOptions, DefineComponent } from 'vue';
|
|
3
|
+
import { CreateComponentPublicInstanceWithMixins, Ref, ComponentOptionsMixin, PublicProps, GlobalComponents, GlobalDirectives, ComponentProvideOptions, DefineComponent, ComputedRef } from 'vue';
|
|
4
|
+
declare function scroll(x?: number, y?: number): void;
|
|
5
|
+
declare function scrollTo({ smooth, left, top }: ScrollOptions): void;
|
|
6
|
+
declare function scrollIntoView(element: HTMLElement, position?: 'start' | 'center' | 'end'): void;
|
|
4
7
|
declare function __VLS_template(): {
|
|
5
8
|
attrs: Partial<{}>;
|
|
6
9
|
slots: {
|
|
@@ -89,7 +92,13 @@ declare function __VLS_template(): {
|
|
|
89
92
|
rootEl: HTMLDivElement;
|
|
90
93
|
};
|
|
91
94
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
92
|
-
declare const __VLS_component: DefineComponent<ScrollViewProps, {
|
|
95
|
+
declare const __VLS_component: DefineComponent<ScrollViewProps, {
|
|
96
|
+
scrollTop: ComputedRef<number>;
|
|
97
|
+
scrollLeft: ComputedRef<number>;
|
|
98
|
+
scroll: typeof scroll;
|
|
99
|
+
scrollTo: typeof scrollTo;
|
|
100
|
+
scrollIntoView: typeof scrollIntoView;
|
|
101
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ScrollViewProps> & Readonly<{}>, {
|
|
93
102
|
showXBar: boolean;
|
|
94
103
|
showYBar: boolean;
|
|
95
104
|
xBarProps: {
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as fe, ref as ue, reactive as he, computed as v, unref as l, watchEffect as _, watch as pe, openBlock as P, createElementBlock as ye, normalizeClass as B, normalizeStyle as M, withModifiers as A, createElementVNode as z, renderSlot as me, createBlock as L, mergeProps as O, createCommentVNode as T } from "vue";
|
|
2
2
|
import "../config-provider/index.mjs";
|
|
3
3
|
import "../scroll-bar/index.mjs";
|
|
4
|
-
import { isDef as
|
|
5
|
-
import { ensureRangeValue as
|
|
6
|
-
import
|
|
7
|
-
import { isString as
|
|
8
|
-
import { useElementSize as
|
|
9
|
-
import { wait as
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
|
|
4
|
+
import { isDef as f } from "../utils/index.mjs";
|
|
5
|
+
import { ensureRangeValue as n, getScrollable as k } from "../scroll-bar/utils/index.mjs";
|
|
6
|
+
import de from "./hooks/use-scroll-wrapper.mjs";
|
|
7
|
+
import { isString as j } from "lodash-unified";
|
|
8
|
+
import { useElementSize as F, useRafFn as ve } from "@vueuse/core";
|
|
9
|
+
import { wait as R } from "@aplus-frontend/utils";
|
|
10
|
+
import { useScrollBack as xe } from "./hooks/use-scroll-back.mjs";
|
|
11
|
+
import { useScrollSmooth as Be } from "./hooks/use-scroll-smooth.mjs";
|
|
12
|
+
import { getElementScrollOffset as we } from "./utils/index.mjs";
|
|
13
|
+
import { useNamespace as ge } from "../config-provider/hooks/use-namespace.mjs";
|
|
14
|
+
import H from "../scroll-bar/internal.vue.mjs";
|
|
15
|
+
const Ye = /* @__PURE__ */ fe({
|
|
13
16
|
name: "ScrollView",
|
|
14
17
|
__name: "index",
|
|
15
18
|
props: {
|
|
@@ -22,180 +25,229 @@ const Pe = /* @__PURE__ */ re({
|
|
|
22
25
|
yBarProps: { default: () => ({}) },
|
|
23
26
|
onWheel: {}
|
|
24
27
|
},
|
|
25
|
-
setup(
|
|
26
|
-
const
|
|
28
|
+
setup(I, { expose: q }) {
|
|
29
|
+
const o = I, G = {
|
|
27
30
|
direction: "vertical",
|
|
28
31
|
rate: 1,
|
|
29
32
|
repeat: !0
|
|
30
|
-
}, { b:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
}, { b: J, e: w, em: W } = ge("scroll-view"), u = ue(), c = he({ x: 30, y: 30 });
|
|
34
|
+
let g = !1;
|
|
35
|
+
const {
|
|
36
|
+
scrollOffset: r,
|
|
37
|
+
maxScrollDistance: i,
|
|
38
|
+
xBarRef: K,
|
|
39
|
+
yBarRef: Q,
|
|
40
|
+
containerRef: s,
|
|
41
|
+
scrollYBar: h,
|
|
42
|
+
scrollXBar: p,
|
|
43
|
+
updateMaxScrollDistance: U
|
|
44
|
+
} = de(), { width: Z, height: ee } = F(u), { width: te, height: re } = F(s), { start: N } = xe({
|
|
45
|
+
scrollOffset: r,
|
|
46
|
+
maxScrollDistance: i,
|
|
47
|
+
onScroll: (t) => {
|
|
48
|
+
t === "horizontal" ? p() : h();
|
|
49
|
+
},
|
|
50
|
+
async onScrollEnd() {
|
|
51
|
+
await R(200), S();
|
|
52
|
+
}
|
|
53
|
+
}), { start: $ } = Be({
|
|
54
|
+
scrollOffset: r,
|
|
55
|
+
maxScrollDistance: i,
|
|
56
|
+
onScroll(t, e) {
|
|
57
|
+
V.value && (y(), g = !0), t && p(), e && h();
|
|
58
|
+
},
|
|
59
|
+
async onScrollEnd() {
|
|
60
|
+
g && (await R(200), S(), g = !1);
|
|
61
|
+
}
|
|
62
|
+
}), { resume: S, pause: y, isActive: V } = ve(
|
|
40
63
|
() => {
|
|
41
|
-
if (!
|
|
42
|
-
|
|
64
|
+
if (!o.autoPlay) {
|
|
65
|
+
y();
|
|
43
66
|
return;
|
|
44
67
|
}
|
|
45
|
-
const
|
|
46
|
-
...
|
|
47
|
-
...
|
|
68
|
+
const t = o.autoPlay === !0 ? {} : o.autoPlay, e = {
|
|
69
|
+
...G,
|
|
70
|
+
...t
|
|
48
71
|
};
|
|
49
|
-
if (
|
|
50
|
-
if (
|
|
51
|
-
|
|
72
|
+
if (e.direction === "horizontal") {
|
|
73
|
+
if (r.x === i.x) {
|
|
74
|
+
y(), e.repeat && N("horizontal");
|
|
52
75
|
return;
|
|
53
76
|
}
|
|
54
|
-
|
|
55
|
-
|
|
77
|
+
r.x = n(
|
|
78
|
+
r.x + e.rate,
|
|
56
79
|
0,
|
|
57
|
-
|
|
58
|
-
),
|
|
80
|
+
i.x
|
|
81
|
+
), p();
|
|
59
82
|
} else {
|
|
60
|
-
if (
|
|
61
|
-
|
|
83
|
+
if (r.y === i.y) {
|
|
84
|
+
y(), e.repeat && N("vertical");
|
|
62
85
|
return;
|
|
63
86
|
}
|
|
64
|
-
|
|
65
|
-
|
|
87
|
+
r.y = n(
|
|
88
|
+
r.y + e.rate,
|
|
66
89
|
0,
|
|
67
|
-
|
|
68
|
-
),
|
|
90
|
+
i.y
|
|
91
|
+
), h();
|
|
69
92
|
}
|
|
70
93
|
},
|
|
71
94
|
{ immediate: !0 }
|
|
72
|
-
),
|
|
73
|
-
width:
|
|
74
|
-
height:
|
|
75
|
-
padding: `${
|
|
95
|
+
), m = v(() => o.showXBar && c.x !== 100), x = v(() => o.showYBar && c.y !== 100), oe = v(() => ({
|
|
96
|
+
width: f(o.width) ? j(o.width) ? o.width : Number.isNaN(o.width) ? void 0 : `${o.width}px` : void 0,
|
|
97
|
+
height: f(o.heigth) ? j(o.heigth) ? o.heigth : Number.isNaN(o.heigth) ? void 0 : `${o.heigth}px` : void 0,
|
|
98
|
+
padding: `${o.xBarProps.trackWidth || 10}px ${o.yBarProps.trackWidth || 10}px`
|
|
76
99
|
}));
|
|
77
|
-
async function
|
|
78
|
-
|
|
100
|
+
async function b() {
|
|
101
|
+
V.value && (y(), await R(500), S());
|
|
79
102
|
}
|
|
80
|
-
async function
|
|
81
|
-
var
|
|
82
|
-
if (
|
|
83
|
-
|
|
103
|
+
async function ae(t) {
|
|
104
|
+
var e;
|
|
105
|
+
if (l(x))
|
|
106
|
+
t.preventDefault(), t.stopPropagation();
|
|
84
107
|
else
|
|
85
108
|
return;
|
|
86
|
-
|
|
87
|
-
|
|
109
|
+
r.y = n(
|
|
110
|
+
r.y + t.deltaY,
|
|
88
111
|
0,
|
|
89
|
-
|
|
90
|
-
),
|
|
112
|
+
i.y
|
|
113
|
+
), h(), (e = o.onWheel) == null || e.call(o, "vertical", r.y), b();
|
|
91
114
|
}
|
|
92
|
-
function
|
|
93
|
-
var
|
|
94
|
-
if (
|
|
95
|
-
|
|
115
|
+
function le(t) {
|
|
116
|
+
var e;
|
|
117
|
+
if (l(m))
|
|
118
|
+
t.preventDefault(), t.stopPropagation();
|
|
96
119
|
else
|
|
97
120
|
return;
|
|
98
|
-
|
|
99
|
-
|
|
121
|
+
r.x = n(
|
|
122
|
+
r.x + t.deltaX,
|
|
100
123
|
0,
|
|
101
|
-
|
|
102
|
-
),
|
|
124
|
+
i.x
|
|
125
|
+
), p(), (e = o.onWheel) == null || e.call(o, "horizontal", r.x), b();
|
|
103
126
|
}
|
|
104
|
-
function
|
|
105
|
-
if (
|
|
106
|
-
const { visibleSize:
|
|
107
|
-
|
|
127
|
+
function E() {
|
|
128
|
+
if (o.showYBar) {
|
|
129
|
+
const { visibleSize: t, totalSize: e } = k(
|
|
130
|
+
s.value,
|
|
108
131
|
"vertical"
|
|
109
132
|
);
|
|
110
|
-
|
|
111
|
-
Math.min(
|
|
133
|
+
c.y = n(
|
|
134
|
+
Math.min(t / (e || 1) * 100)
|
|
112
135
|
);
|
|
113
136
|
}
|
|
114
|
-
if (
|
|
115
|
-
const { visibleSize:
|
|
116
|
-
|
|
137
|
+
if (o.showXBar) {
|
|
138
|
+
const { visibleSize: t, totalSize: e } = k(
|
|
139
|
+
s.value,
|
|
117
140
|
"horizontal"
|
|
118
141
|
);
|
|
119
|
-
|
|
120
|
-
Math.min(
|
|
142
|
+
c.x = n(
|
|
143
|
+
Math.min(t / (e || 1) * 100)
|
|
121
144
|
);
|
|
122
145
|
}
|
|
123
146
|
}
|
|
124
|
-
function
|
|
125
|
-
const
|
|
126
|
-
if (!
|
|
127
|
-
const { visibleSize:
|
|
128
|
-
if (
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
|
|
147
|
+
function X(t, e) {
|
|
148
|
+
const a = l(s), d = l(u);
|
|
149
|
+
if (!a || !d) return;
|
|
150
|
+
const { visibleSize: C, totalSize: D } = k(a, e);
|
|
151
|
+
if (D <= C) return;
|
|
152
|
+
const Y = (D - C) * t / 100, ce = e === "vertical";
|
|
153
|
+
if (b(), ce) {
|
|
154
|
+
r.y = Y;
|
|
132
155
|
return;
|
|
133
156
|
}
|
|
134
|
-
|
|
157
|
+
r.x = Y;
|
|
135
158
|
}
|
|
136
|
-
|
|
159
|
+
_(
|
|
137
160
|
() => {
|
|
138
|
-
|
|
161
|
+
l(s.value) && E();
|
|
139
162
|
},
|
|
140
163
|
{ flush: "post" }
|
|
141
|
-
),
|
|
164
|
+
), pe(
|
|
142
165
|
() => [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
166
|
+
Z.value,
|
|
167
|
+
ee.value,
|
|
168
|
+
te.value,
|
|
169
|
+
re.value
|
|
147
170
|
],
|
|
148
171
|
() => {
|
|
149
|
-
|
|
172
|
+
E(), U();
|
|
150
173
|
}
|
|
151
|
-
),
|
|
152
|
-
|
|
153
|
-
})
|
|
174
|
+
), _(() => {
|
|
175
|
+
u.value && (u.value.style.transform = `translate3d(-${r.x}px, -${r.y}px, 0px)`);
|
|
176
|
+
});
|
|
177
|
+
function ie(t, e) {
|
|
178
|
+
f(t) && m.value && (r.x = n(t, 0, i.x), p()), f(e) && x.value && (r.y = n(e, 0, i.y), h());
|
|
179
|
+
}
|
|
180
|
+
function ne({ smooth: t, left: e, top: a }) {
|
|
181
|
+
t ? $({ x: e, y: a }) : (f(e) && (r.x = e), f(a) && (r.y = a));
|
|
182
|
+
}
|
|
183
|
+
function se(t, e = "start") {
|
|
184
|
+
const a = we(
|
|
185
|
+
s.value,
|
|
186
|
+
t,
|
|
187
|
+
e
|
|
188
|
+
), d = {};
|
|
189
|
+
m.value && (d.x = n(
|
|
190
|
+
r.x + a.x,
|
|
191
|
+
0,
|
|
192
|
+
i.x
|
|
193
|
+
)), x.value && (d.y = n(
|
|
194
|
+
r.y + a.y,
|
|
195
|
+
0,
|
|
196
|
+
i.y
|
|
197
|
+
)), $(d);
|
|
198
|
+
}
|
|
199
|
+
return q({
|
|
200
|
+
scrollTop: v(() => r.y),
|
|
201
|
+
scrollLeft: v(() => r.x),
|
|
202
|
+
scroll: ie,
|
|
203
|
+
scrollTo: ne,
|
|
204
|
+
scrollIntoView: se
|
|
205
|
+
}), (t, e) => (P(), ye("div", {
|
|
154
206
|
ref_key: "containerRef",
|
|
155
|
-
ref:
|
|
156
|
-
class:
|
|
157
|
-
style:
|
|
207
|
+
ref: s,
|
|
208
|
+
class: B(l(J)()),
|
|
209
|
+
style: M(oe.value),
|
|
158
210
|
onWheel: [
|
|
159
|
-
|
|
160
|
-
|
|
211
|
+
A(ae, ["exact"]),
|
|
212
|
+
A(le, ["shift"])
|
|
161
213
|
]
|
|
162
214
|
}, [
|
|
163
|
-
|
|
215
|
+
z("div", {
|
|
164
216
|
ref_key: "contentRef",
|
|
165
|
-
ref:
|
|
166
|
-
class:
|
|
217
|
+
ref: u,
|
|
218
|
+
class: B(l(w)("content"))
|
|
167
219
|
}, [
|
|
168
|
-
|
|
220
|
+
me(t.$slots, "default")
|
|
169
221
|
], 2),
|
|
170
|
-
|
|
171
|
-
class:
|
|
172
|
-
style:
|
|
222
|
+
z("div", {
|
|
223
|
+
class: B([l(w)("bar-wrapper"), l(W)("bar-wrapper", "vertical")]),
|
|
224
|
+
style: M(`height: calc(100% - ${m.value ? t.xBarProps.trackWidth || 10 : 0}px)`)
|
|
173
225
|
}, [
|
|
174
|
-
|
|
226
|
+
x.value ? (P(), L(l(H), O({
|
|
175
227
|
key: 0,
|
|
176
228
|
ref_key: "yBarRef",
|
|
177
|
-
ref:
|
|
178
|
-
},
|
|
179
|
-
"bar-length":
|
|
180
|
-
onScroll:
|
|
181
|
-
}), null, 16, ["bar-length"])) :
|
|
229
|
+
ref: Q
|
|
230
|
+
}, t.yBarProps, {
|
|
231
|
+
"bar-length": c.y,
|
|
232
|
+
onScroll: e[0] || (e[0] = (a) => X(a, "vertical"))
|
|
233
|
+
}), null, 16, ["bar-length"])) : T("", !0)
|
|
182
234
|
], 6),
|
|
183
|
-
|
|
184
|
-
class:
|
|
235
|
+
z("div", {
|
|
236
|
+
class: B([l(w)("bar-wrapper"), l(W)("bar-wrapper", "horizontal")])
|
|
185
237
|
}, [
|
|
186
|
-
|
|
238
|
+
m.value ? (P(), L(l(H), O({
|
|
187
239
|
key: 0,
|
|
188
240
|
ref_key: "xBarRef",
|
|
189
|
-
ref:
|
|
190
|
-
},
|
|
241
|
+
ref: K
|
|
242
|
+
}, t.xBarProps, {
|
|
191
243
|
direction: "horizontal",
|
|
192
|
-
"bar-length":
|
|
193
|
-
onScroll:
|
|
194
|
-
}), null, 16, ["bar-length"])) :
|
|
244
|
+
"bar-length": c.x,
|
|
245
|
+
onScroll: e[1] || (e[1] = (a) => X(a, "horizontal"))
|
|
246
|
+
}), null, 16, ["bar-length"])) : T("", !0)
|
|
195
247
|
], 2)
|
|
196
248
|
], 38));
|
|
197
249
|
}
|
|
198
250
|
});
|
|
199
251
|
export {
|
|
200
|
-
|
|
252
|
+
Ye as default
|
|
201
253
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { InternalScrollBarProps, ScrollBarDirection } from '../scroll-bar';
|
|
2
|
+
import { Ref } from 'vue';
|
|
2
3
|
type BarExtraProps = Omit<InternalScrollBarProps, 'direction' | 'scroll' | 'barLength'>;
|
|
4
|
+
export type ScrollOffsetType = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
3
8
|
export type AutoPlayConfig = {
|
|
4
9
|
/**
|
|
5
10
|
* 自动滚动的方向
|
|
@@ -49,4 +54,39 @@ export interface ScrollViewProps {
|
|
|
49
54
|
*/
|
|
50
55
|
onWheel?: (direction: ScrollBarDirection, offset: number) => void;
|
|
51
56
|
}
|
|
57
|
+
export type ScrollOptions = {
|
|
58
|
+
top?: number;
|
|
59
|
+
left?: number;
|
|
60
|
+
smooth?: boolean;
|
|
61
|
+
};
|
|
62
|
+
export type ScrollViewExpose = {
|
|
63
|
+
/**
|
|
64
|
+
* 当前滚动距离顶部的位置
|
|
65
|
+
*/
|
|
66
|
+
scrollTop: Ref<number>;
|
|
67
|
+
/**
|
|
68
|
+
* 当前滚动距离左侧的位置
|
|
69
|
+
*/
|
|
70
|
+
scrollLeft: Ref<number>;
|
|
71
|
+
/**
|
|
72
|
+
* 滚动到指定位置
|
|
73
|
+
* @param x
|
|
74
|
+
* @param y
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
scroll: (x?: number, y?: number) => void;
|
|
78
|
+
/**
|
|
79
|
+
* 滚动到指定位置(支持指定平滑滚动)
|
|
80
|
+
* @param options
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
scrollTo: (options: ScrollOptions) => void;
|
|
84
|
+
/**
|
|
85
|
+
* 将子元素滚动到可视区域
|
|
86
|
+
* @param element
|
|
87
|
+
* @param position
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
scrollIntoView: (element: Element, position?: 'start' | 'center' | 'end') => void;
|
|
91
|
+
};
|
|
52
92
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取某个元素相对滚动容器可见应该滚动的偏移量(绝对值)
|
|
3
|
+
* @param container
|
|
4
|
+
* @param element
|
|
5
|
+
* @param position
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function getElementScrollOffset(container: HTMLElement, element: HTMLElement, position: 'start' | 'center' | 'end'): {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function i(o, c, t) {
|
|
2
|
+
const e = o.getBoundingClientRect(), n = c.getBoundingClientRect(), s = t === "x" ? "left" : "top", f = t === "x" ? "right" : "bottom", g = t === "x" ? "width" : "height";
|
|
3
|
+
return {
|
|
4
|
+
start: n[s] - e[s],
|
|
5
|
+
end: n[f] - e[f],
|
|
6
|
+
center: n[f] - e[f] + (e[g] - n[g]) / 2
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function r(o, c, t) {
|
|
10
|
+
const e = i(o, c, "x"), n = i(o, c, "y");
|
|
11
|
+
return {
|
|
12
|
+
x: e[t],
|
|
13
|
+
y: n[t]
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
r as getElementScrollOffset
|
|
18
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ScrollBarDirection } from '../../scroll-bar';
|
|
2
|
+
import { Ref } from 'vue';
|
|
3
|
+
type ScrollBackOptions = {
|
|
4
|
+
scrollOffset: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
maxScrollDistance: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
timer?: number;
|
|
13
|
+
onScroll?: (direction: ScrollBarDirection) => void;
|
|
14
|
+
onScrollEnd?: (direction: ScrollBarDirection) => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 在特定的时间内滚动到0
|
|
18
|
+
* @param options
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
declare const useScrollBack: ({ scrollOffset, maxScrollDistance, timer, onScroll, onScrollEnd }: ScrollBackOptions) => {
|
|
22
|
+
start: (direction: ScrollBarDirection) => void;
|
|
23
|
+
stop: () => void;
|
|
24
|
+
isActive: Readonly< Ref<boolean, boolean>>;
|
|
25
|
+
};
|
|
26
|
+
export { useScrollBack };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../scroll-bar/index.js");const y=require("@vueuse/core"),u=require("../../scroll-bar/utils/index.js"),l={horizontal:"x",vertical:"y"},d=()=>{},D=e=>1-Math.pow(1-e,3),M=({scrollOffset:e,maxScrollDistance:p,timer:m=500,onScroll:a=d,onScrollEnd:g=d})=>{let o,t,r;const{pause:c,resume:T,isActive:b}=y.useRafFn(()=>{const n=Date.now(),s=l[t],v=n-o,i=u.ensureRangeValue(v/m,0,1),w=D(i);i===1?(e[s]=0,c(),a(t),g(t)):(e[s]=u.ensureRangeValue(r*(1-w),0,p[s]),a(t))},{immediate:!1});function h(n){t=n,o=Date.now(),r=e[l[n]],T()}function q(){c()}return{start:h,stop:q,isActive:b}};exports.useScrollBack=M;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ScrollOffsetType } from '../interface';
|
|
2
|
+
import { Ref } from 'vue';
|
|
3
|
+
type ScrollBackOptions = {
|
|
4
|
+
scrollOffset: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
maxScrollDistance: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
timer?: number;
|
|
13
|
+
onScroll?: (x: boolean, y: boolean) => void;
|
|
14
|
+
onScrollEnd?: (x: boolean, y: boolean) => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 在特定的时间内滚动到0
|
|
18
|
+
* @param options
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
declare const useScrollSmooth: ({ scrollOffset, maxScrollDistance, timer, onScroll, onScrollEnd }: ScrollBackOptions) => {
|
|
22
|
+
start: (target: Partial<ScrollOffsetType>) => void;
|
|
23
|
+
stop: () => void;
|
|
24
|
+
isActive: Readonly< Ref<boolean, boolean>>;
|
|
25
|
+
};
|
|
26
|
+
export { useScrollSmooth };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../scroll-bar/index.js");const b=require("@vueuse/core"),m=require("../../utils/index.js"),i=require("../../scroll-bar/utils/index.js"),f=()=>{},h=t=>1-Math.pow(1-t,3),v=({scrollOffset:t,maxScrollDistance:y,timer:p=500,onScroll:x=f,onScrollEnd:d=f})=>{let c,e,n,u,s;const{pause:r,resume:R,isActive:l}=b.useRafFn(()=>{const q=Date.now()-c,g=i.ensureRangeValue(q/p,0,1),o=h(g);g===1?(u&&(t.x=n.x),s&&(t.y=n.y),r(),x(u,s),d(u,s)):(u&&(n.x>e.x?t.x=i.ensureRangeValue(e.x+(n.x-e.x)*o,e.x,y.x):t.x=i.ensureRangeValue(n.x+(e.x-n.x)*(1-o),0,e.x)),s&&(n.y>e.y?t.y=i.ensureRangeValue(e.y+(n.y-e.y)*o,e.y,y.y):t.y=i.ensureRangeValue(n.y+(e.y-n.y)*(1-o),0,e.y)),x(u,s))},{immediate:!1});function T(a){l.value&&r(),c=Date.now(),e={x:t.x,y:t.y},n=a,u=m.isDef(a.x),s=m.isDef(a.y),R()}function V(){r()}return{start:T,stop:V,isActive:l}};exports.useScrollSmooth=v;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { ScrollViewProps } from './interface';
|
|
1
|
+
import { ScrollOptions, ScrollViewProps } from './interface';
|
|
2
2
|
import { ScrollBarDirection, InternalScrollBarProps } from '../scroll-bar';
|
|
3
|
-
import { CreateComponentPublicInstanceWithMixins, Ref, ComponentOptionsMixin, PublicProps, GlobalComponents, GlobalDirectives, ComponentProvideOptions, DefineComponent } from 'vue';
|
|
3
|
+
import { CreateComponentPublicInstanceWithMixins, Ref, ComponentOptionsMixin, PublicProps, GlobalComponents, GlobalDirectives, ComponentProvideOptions, DefineComponent, ComputedRef } from 'vue';
|
|
4
|
+
declare function scroll(x?: number, y?: number): void;
|
|
5
|
+
declare function scrollTo({ smooth, left, top }: ScrollOptions): void;
|
|
6
|
+
declare function scrollIntoView(element: HTMLElement, position?: 'start' | 'center' | 'end'): void;
|
|
4
7
|
declare function __VLS_template(): {
|
|
5
8
|
attrs: Partial<{}>;
|
|
6
9
|
slots: {
|
|
@@ -89,7 +92,13 @@ declare function __VLS_template(): {
|
|
|
89
92
|
rootEl: HTMLDivElement;
|
|
90
93
|
};
|
|
91
94
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
92
|
-
declare const __VLS_component: DefineComponent<ScrollViewProps, {
|
|
95
|
+
declare const __VLS_component: DefineComponent<ScrollViewProps, {
|
|
96
|
+
scrollTop: ComputedRef<number>;
|
|
97
|
+
scrollLeft: ComputedRef<number>;
|
|
98
|
+
scroll: typeof scroll;
|
|
99
|
+
scrollTo: typeof scrollTo;
|
|
100
|
+
scrollIntoView: typeof scrollIntoView;
|
|
101
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ScrollViewProps> & Readonly<{}>, {
|
|
93
102
|
showXBar: boolean;
|
|
94
103
|
showYBar: boolean;
|
|
95
104
|
xBarProps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");require("../config-provider/index.js");require("../scroll-bar/index.js");const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");require("../config-provider/index.js");require("../scroll-bar/index.js");const c=require("../utils/index.js"),o=require("../scroll-bar/utils/index.js"),Z=require("./hooks/use-scroll-wrapper.js"),W=require("lodash-unified"),w=require("@vueuse/core"),b=require("@aplus-frontend/utils"),ee=require("./hooks/use-scroll-back.js"),te=require("./hooks/use-scroll-smooth.js"),re=require("./utils/index.js"),ae=require("../config-provider/hooks/use-namespace.js"),D=require("../scroll-bar/internal.vue.js"),ne=e.defineComponent({name:"ScrollView",__name:"index",props:{width:{},heigth:{},showXBar:{type:Boolean,default:!0},showYBar:{type:Boolean,default:!0},autoPlay:{type:[Boolean,Object]},xBarProps:{default:()=>({})},yBarProps:{default:()=>({})},onWheel:{}},setup($,{expose:C}){const n=$,M={direction:"vertical",rate:1,repeat:!0},{b:X,e:g,em:z}=ae.useNamespace("scroll-view"),f=e.ref(),u=e.reactive({x:30,y:30});let m=!1;const{scrollOffset:a,maxScrollDistance:i,xBarRef:Y,yBarRef:O,containerRef:s,scrollYBar:h,scrollXBar:d,updateMaxScrollDistance:A}=Z.default(),{width:L,height:T}=w.useElementSize(f),{width:j,height:F}=w.useElementSize(s),{start:P}=ee.useScrollBack({scrollOffset:a,maxScrollDistance:i,onScroll:r=>{r==="horizontal"?d():h()},async onScrollEnd(){await b.wait(200),S()}}),{start:R}=te.useScrollSmooth({scrollOffset:a,maxScrollDistance:i,onScroll(r,t){V.value&&(y(),m=!0),r&&d(),t&&h()},async onScrollEnd(){m&&(await b.wait(200),S(),m=!1)}}),{resume:S,pause:y,isActive:V}=w.useRafFn(()=>{if(!n.autoPlay){y();return}const r=n.autoPlay===!0?{}:n.autoPlay,t={...M,...r};if(t.direction==="horizontal"){if(a.x===i.x){y(),t.repeat&&P("horizontal");return}a.x=o.ensureRangeValue(a.x+t.rate,0,i.x),d()}else{if(a.y===i.y){y(),t.repeat&&P("vertical");return}a.y=o.ensureRangeValue(a.y+t.rate,0,i.y),h()}},{immediate:!0}),p=e.computed(()=>n.showXBar&&u.x!==100),x=e.computed(()=>n.showYBar&&u.y!==100),H=e.computed(()=>({width:c.isDef(n.width)?W.isString(n.width)?n.width:Number.isNaN(n.width)?void 0:`${n.width}px`:void 0,height:c.isDef(n.heigth)?W.isString(n.heigth)?n.heigth:Number.isNaN(n.heigth)?void 0:`${n.heigth}px`:void 0,padding:`${n.xBarProps.trackWidth||10}px ${n.yBarProps.trackWidth||10}px`}));async function B(){V.value&&(y(),await b.wait(500),S())}async function I(r){var t;if(e.unref(x))r.preventDefault(),r.stopPropagation();else return;a.y=o.ensureRangeValue(a.y+r.deltaY,0,i.y),h(),(t=n.onWheel)==null||t.call(n,"vertical",a.y),B()}function U(r){var t;if(e.unref(p))r.preventDefault(),r.stopPropagation();else return;a.x=o.ensureRangeValue(a.x+r.deltaX,0,i.x),d(),(t=n.onWheel)==null||t.call(n,"horizontal",a.x),B()}function k(){if(n.showYBar){const{visibleSize:r,totalSize:t}=o.getScrollable(s.value,"vertical");u.y=o.ensureRangeValue(Math.min(r/(t||1)*100))}if(n.showXBar){const{visibleSize:r,totalSize:t}=o.getScrollable(s.value,"horizontal");u.x=o.ensureRangeValue(Math.min(r/(t||1)*100))}}function q(r,t){const l=e.unref(s),v=e.unref(f);if(!l||!v)return;const{visibleSize:N,totalSize:_}=o.getScrollable(l,t);if(_<=N)return;const E=(_-N)*r/100,Q=t==="vertical";if(B(),Q){a.y=E;return}a.x=E}e.watchEffect(()=>{e.unref(s.value)&&k()},{flush:"post"}),e.watch(()=>[L.value,T.value,j.value,F.value],()=>{k(),A()}),e.watchEffect(()=>{f.value&&(f.value.style.transform=`translate3d(-${a.x}px, -${a.y}px, 0px)`)});function G(r,t){c.isDef(r)&&p.value&&(a.x=o.ensureRangeValue(r,0,i.x),d()),c.isDef(t)&&x.value&&(a.y=o.ensureRangeValue(t,0,i.y),h())}function J({smooth:r,left:t,top:l}){r?R({x:t,y:l}):(c.isDef(t)&&(a.x=t),c.isDef(l)&&(a.y=l))}function K(r,t="start"){const l=re.getElementScrollOffset(s.value,r,t),v={};p.value&&(v.x=o.ensureRangeValue(a.x+l.x,0,i.x)),x.value&&(v.y=o.ensureRangeValue(a.y+l.y,0,i.y)),R(v)}return C({scrollTop:e.computed(()=>a.y),scrollLeft:e.computed(()=>a.x),scroll:G,scrollTo:J,scrollIntoView:K}),(r,t)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:s,class:e.normalizeClass(e.unref(X)()),style:e.normalizeStyle(H.value),onWheel:[e.withModifiers(I,["exact"]),e.withModifiers(U,["shift"])]},[e.createElementVNode("div",{ref_key:"contentRef",ref:f,class:e.normalizeClass(e.unref(g)("content"))},[e.renderSlot(r.$slots,"default")],2),e.createElementVNode("div",{class:e.normalizeClass([e.unref(g)("bar-wrapper"),e.unref(z)("bar-wrapper","vertical")]),style:e.normalizeStyle(`height: calc(100% - ${p.value?r.xBarProps.trackWidth||10:0}px)`)},[x.value?(e.openBlock(),e.createBlock(e.unref(D.default),e.mergeProps({key:0,ref_key:"yBarRef",ref:O},r.yBarProps,{"bar-length":u.y,onScroll:t[0]||(t[0]=l=>q(l,"vertical"))}),null,16,["bar-length"])):e.createCommentVNode("",!0)],6),e.createElementVNode("div",{class:e.normalizeClass([e.unref(g)("bar-wrapper"),e.unref(z)("bar-wrapper","horizontal")])},[p.value?(e.openBlock(),e.createBlock(e.unref(D.default),e.mergeProps({key:0,ref_key:"xBarRef",ref:Y},r.xBarProps,{direction:"horizontal","bar-length":u.x,onScroll:t[1]||(t[1]=l=>q(l,"horizontal"))}),null,16,["bar-length"])):e.createCommentVNode("",!0)],2)],38))}});exports.default=ne;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { InternalScrollBarProps, ScrollBarDirection } from '../scroll-bar';
|
|
2
|
+
import { Ref } from 'vue';
|
|
2
3
|
type BarExtraProps = Omit<InternalScrollBarProps, 'direction' | 'scroll' | 'barLength'>;
|
|
4
|
+
export type ScrollOffsetType = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
3
8
|
export type AutoPlayConfig = {
|
|
4
9
|
/**
|
|
5
10
|
* 自动滚动的方向
|
|
@@ -49,4 +54,39 @@ export interface ScrollViewProps {
|
|
|
49
54
|
*/
|
|
50
55
|
onWheel?: (direction: ScrollBarDirection, offset: number) => void;
|
|
51
56
|
}
|
|
57
|
+
export type ScrollOptions = {
|
|
58
|
+
top?: number;
|
|
59
|
+
left?: number;
|
|
60
|
+
smooth?: boolean;
|
|
61
|
+
};
|
|
62
|
+
export type ScrollViewExpose = {
|
|
63
|
+
/**
|
|
64
|
+
* 当前滚动距离顶部的位置
|
|
65
|
+
*/
|
|
66
|
+
scrollTop: Ref<number>;
|
|
67
|
+
/**
|
|
68
|
+
* 当前滚动距离左侧的位置
|
|
69
|
+
*/
|
|
70
|
+
scrollLeft: Ref<number>;
|
|
71
|
+
/**
|
|
72
|
+
* 滚动到指定位置
|
|
73
|
+
* @param x
|
|
74
|
+
* @param y
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
scroll: (x?: number, y?: number) => void;
|
|
78
|
+
/**
|
|
79
|
+
* 滚动到指定位置(支持指定平滑滚动)
|
|
80
|
+
* @param options
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
scrollTo: (options: ScrollOptions) => void;
|
|
84
|
+
/**
|
|
85
|
+
* 将子元素滚动到可视区域
|
|
86
|
+
* @param element
|
|
87
|
+
* @param position
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
scrollIntoView: (element: Element, position?: 'start' | 'center' | 'end') => void;
|
|
91
|
+
};
|
|
52
92
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取某个元素相对滚动容器可见应该滚动的偏移量(绝对值)
|
|
3
|
+
* @param container
|
|
4
|
+
* @param element
|
|
5
|
+
* @param position
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function getElementScrollOffset(container: HTMLElement, element: HTMLElement, position: 'start' | 'center' | 'end'): {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(o,c,t){const e=o.getBoundingClientRect(),n=c.getBoundingClientRect(),s=t==="x"?"left":"top",f=t==="x"?"right":"bottom",l=t==="x"?"width":"height";return{start:n[s]-e[s],end:n[f]-e[f],center:n[f]-e[f]+(e[l]-n[l])/2}}function r(o,c,t){const e=g(o,c,"x"),n=g(o,c,"y");return{x:e[t],y:n[t]}}exports.getElementScrollOffset=r;
|