plain-design 1.0.0-beta.95 → 1.0.0-beta.96
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/plain-design.commonjs.min.js +2 -2
- package/dist/plain-design.min.css +1 -1
- package/dist/plain-design.min.js +2 -2
- package/dist/report.html +2 -2
- package/package.json +1 -1
- package/src/packages/components/Form/form.scss +6 -0
- package/src/packages/components/createScrollDraggier/index.ts +14 -10
package/package.json
CHANGED
@@ -21,15 +21,19 @@ export function createScrollDraggier(
|
|
21
21
|
getScroll,
|
22
22
|
dataModel,
|
23
23
|
getItemElements,
|
24
|
+
getHost,
|
25
|
+
getStrut,
|
24
26
|
onDraggierStart,
|
25
27
|
onDraggierMove,
|
26
28
|
onDraggierEnd,
|
27
29
|
onDraggierTap,
|
28
30
|
}: {
|
29
31
|
props: { horizontal: boolean },
|
30
|
-
getScroll: () => PlainScroll | undefined,
|
32
|
+
getScroll: undefined | null | (() => PlainScroll | undefined),
|
31
33
|
dataModel: { value: any[] | undefined | null },
|
32
34
|
getItemElements: () => HTMLElement[],
|
35
|
+
getHost?: () => HTMLElement,
|
36
|
+
getStrut?: () => HTMLElement,
|
33
37
|
|
34
38
|
onDraggierStart?: iVirtualDraggierHandler,
|
35
39
|
onDraggierMove?: iVirtualDraggierHandler,
|
@@ -39,7 +43,7 @@ export function createScrollDraggier(
|
|
39
43
|
) {
|
40
44
|
|
41
45
|
/*管理自动滚动*/
|
42
|
-
const autoScrollManager = createAutoScrollManager(getScroll);
|
46
|
+
const autoScrollManager = !getScroll ? null : createAutoScrollManager(getScroll);
|
43
47
|
|
44
48
|
/*静态变量*/
|
45
49
|
const dragStaticState = {
|
@@ -83,11 +87,11 @@ export function createScrollDraggier(
|
|
83
87
|
throw new Error(`Can't find [data-vid] elements!`);
|
84
88
|
}
|
85
89
|
|
86
|
-
dragStaticState.hostElement = findParentElement(dragStaticState.dragElement, el => hasClass(el, getComponentCls('scroll')))!;
|
90
|
+
dragStaticState.hostElement = getHost ? getHost() : findParentElement(dragStaticState.dragElement, el => hasClass(el, getComponentCls('scroll')))!;
|
87
91
|
if (!dragStaticState.hostElement) {
|
88
92
|
throw new Error(`Can't find host elements`);
|
89
93
|
}
|
90
|
-
dragStaticState.strutElement = findParentElement(dragStaticState.dragElement, el => hasClass(el, 'scroll-content'))!;
|
94
|
+
dragStaticState.strutElement = getStrut ? getStrut() : findParentElement(dragStaticState.dragElement, el => hasClass(el, 'scroll-content'))!;
|
91
95
|
if (!dragStaticState.strutElement) {
|
92
96
|
throw new Error(`Can't find strut elements`);
|
93
97
|
}
|
@@ -200,14 +204,14 @@ export function createScrollDraggier(
|
|
200
204
|
dragReactiveState.onScroll = (e: Event) => {
|
201
205
|
update();
|
202
206
|
};
|
203
|
-
const ejectOnScroll = getScroll()
|
207
|
+
const ejectOnScroll = !getScroll ? null : getScroll()?.on.onScroll(dragReactiveState.onScroll);
|
204
208
|
draggierEffects.push(() => {
|
205
|
-
ejectOnScroll();
|
209
|
+
ejectOnScroll?.();
|
206
210
|
dragReactiveState.onScroll = doNothing;
|
207
211
|
});
|
208
212
|
|
209
213
|
/*拖拽结束的时候停止自动滚动*/
|
210
|
-
draggierEffects.push(() => getScroll()?.methods.stopAutoScroll());
|
214
|
+
draggierEffects.push(() => getScroll?.()?.methods.stopAutoScroll());
|
211
215
|
draggierEffects.push(async () => {
|
212
216
|
await dragReactiveState.endingDefer.promise;
|
213
217
|
dragReactiveState.pointIndex = null;
|
@@ -301,11 +305,11 @@ export function createScrollDraggier(
|
|
301
305
|
const resultStart = Math.max(minStart, Math.min(maxStart, newStart));
|
302
306
|
|
303
307
|
if (resultStart == minStart) {
|
304
|
-
autoScrollManager
|
308
|
+
autoScrollManager?.set(props.horizontal ? 'left' : 'top');
|
305
309
|
} else if (resultStart == maxStart) {
|
306
|
-
autoScrollManager
|
310
|
+
autoScrollManager?.set(props.horizontal ? 'right' : 'bottom');
|
307
311
|
} else {
|
308
|
-
autoScrollManager
|
312
|
+
autoScrollManager?.set(null);
|
309
313
|
}
|
310
314
|
|
311
315
|
const styleName = props.horizontal ? 'left' : 'top';
|