sard 1.0.3 → 1.0.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/all-components.js +1 -2
- package/components/cascader/cascader.js +2 -2
- package/components/cascader/common.d.ts +1 -1
- package/components/cascader/common.js +4 -4
- package/components/cascader/useCascaderTree.d.ts +1 -1
- package/components/cascader/useCascaderTree.js +1 -1
- package/components/cascader-input/cascader-input.js +3 -3
- package/components/divider/index.css +1 -1
- package/components/index.js +2 -2
- package/components/picker/common.d.ts +4 -4
- package/components/picker/common.js +12 -12
- package/components/picker/picker.js +22 -47
- package/components/picker-input/picker-input.js +3 -3
- package/components/picker-popout/picker-popout.js +2 -2
- package/components/picker-view/common.d.ts +0 -1
- package/components/picker-view/picker-view-column.js +38 -36
- package/components/picker-view/picker-view.js +3 -13
- package/components/popover/popover.js +1 -1
- package/components/status-bar/common.d.ts +0 -1
- package/components/status-bar/status-bar.d.ts +1 -3
- package/components/status-bar/status-bar.js +2 -8
- package/components/sticky/index.css +1 -1
- package/components/sticky/sticky.js +53 -49
- package/components/swipe-action/common.d.ts +5 -18
- package/components/swipe-action/common.js +2 -3
- package/components/swipe-action/index.d.ts +1 -3
- package/components/swipe-action/index.js +1 -3
- package/components/swipe-action/swipe-action.d.ts +5 -1
- package/components/swipe-action/swipe-action.js +36 -13
- package/global.d.ts +0 -1
- package/index.css +1 -1
- package/index.js +2 -2
- package/package.json +1 -1
- package/use/useClickOutside.d.ts +2 -2
- package/use/useClickOutside.js +2 -2
- package/use/useResizeObserver.js +3 -3
- package/utils/scroller/Scroll.js +2 -2
- package/utils/scroller/useScroller.d.ts +4 -20
- package/utils/scroller/useScroller.js +24 -84
- package/components/swipe-action/swipe-action-group.d.ts +0 -13
- package/components/swipe-action/swipe-action-group.js +0 -39
package/index.js
CHANGED
|
@@ -185,7 +185,7 @@ import { StatusBar } from "./components/status-bar/index.js";
|
|
|
185
185
|
import { Stepper } from "./components/stepper/index.js";
|
|
186
186
|
import { Step, Steps } from "./components/steps/index.js";
|
|
187
187
|
import { Sticky, StickyBox } from "./components/sticky/index.js";
|
|
188
|
-
import { SwipeAction
|
|
188
|
+
import { SwipeAction } from "./components/swipe-action/index.js";
|
|
189
189
|
import { Swiper, SwiperItem } from "./components/swiper/index.js";
|
|
190
190
|
import { Switch } from "./components/switch/index.js";
|
|
191
191
|
import { Tabbar, TabbarItem } from "./components/tabbar/index.js";
|
|
@@ -216,4 +216,4 @@ function prepareEnvironment() {
|
|
|
216
216
|
});
|
|
217
217
|
}
|
|
218
218
|
//#endregion
|
|
219
|
-
export { ADD_SWIPER_CONTEXT_KEY, ALPHANUMERIC_CHARS, Accordion, AccordionItem, ActionSheet, ActionSheetItem, Alert, Avatar, AvatarGroup, BackTop, Badge, Barcode, BarcodeFormatList, BarcodeTextPositionList, Button, Calendar, CalendarInput, CalendarPopout, Card, Cascader, CascaderInput, CascaderPopout, Checkbox, CheckboxGroup, CheckboxInput, CheckboxPopout, Col, Collapse, ColorPicker, ColorPickerInput, ColorPickerPopout, Compact, CoolIcon, CountDown, CountTo, CropImage, DateStrip, DatetimePicker, DatetimePickerInput, DatetimePickerPopout, DatetimeRangePicker, DatetimeRangePickerInput, DatetimeRangePickerPopout, Descriptions, DescriptionsItem, Dialog, Divider, Dnd, DndHandle, DndItem, Dropdown, DropdownItem, ECLList, Ellipsis, Empty, Fab, FabItem, FloatingBubble, FloatingPanel, Form, FormItem, FormItemPlain, FormPlain, Friction, Grid, GridItem, Image, Indexes, IndexesAnchor, IndexesNav, InfiniteList, Input, Keyboard, KeyboardPopout, List, ListItem, LoadMore, Loading, Marquee, Menu, MenuItem, Motion, Navbar, NavbarItem, NavbarPit, NoticeBar, Notify, OnlyChild, Overlay, Pagination, PasswordInput, Picker, PickerInput, PickerPopout, PickerView, PickerViewColumn, Popout, PopoutInput, Popover, Popup, PreviewImage, ProgressBar, ProgressCircle, PullDownRefresh, PuzzleVerify, Qrcode, REMOVE_SWIPER_CONTEXT_KEY, Radio, RadioGroup, RadioInput, RadioPopout, Rate, ReadMore, Result, RotateVerify, Row, SWIPER_AUTO_HEIGHT_KEY, ScrollList, ScrollSpy, ScrollSpyAnchor, Search, Segmented, SegmentedItem, Select, SelectInput, SelectOption, SelectOptionGroup, SelectPopout, ShareSheet, ShareSheetIcon, ShareSheetItem, ShareSheetRow, Sidebar, SidebarItem, Signature, Skeleton, SkeletonAvatar, SkeletonBlock, SkeletonParagraph, SkeletonTitle, SlideVerify, Slider, Space, Spring, StatusBar, Step, Stepper, Steps, Sticky, StickyBox, SwipeAction,
|
|
219
|
+
export { ADD_SWIPER_CONTEXT_KEY, ALPHANUMERIC_CHARS, Accordion, AccordionItem, ActionSheet, ActionSheetItem, Alert, Avatar, AvatarGroup, BackTop, Badge, Barcode, BarcodeFormatList, BarcodeTextPositionList, Button, Calendar, CalendarInput, CalendarPopout, Card, Cascader, CascaderInput, CascaderPopout, Checkbox, CheckboxGroup, CheckboxInput, CheckboxPopout, Col, Collapse, ColorPicker, ColorPickerInput, ColorPickerPopout, Compact, CoolIcon, CountDown, CountTo, CropImage, DateStrip, DatetimePicker, DatetimePickerInput, DatetimePickerPopout, DatetimeRangePicker, DatetimeRangePickerInput, DatetimeRangePickerPopout, Descriptions, DescriptionsItem, Dialog, Divider, Dnd, DndHandle, DndItem, Dropdown, DropdownItem, ECLList, Ellipsis, Empty, Fab, FabItem, FloatingBubble, FloatingPanel, Form, FormItem, FormItemPlain, FormPlain, Friction, Grid, GridItem, Image, Indexes, IndexesAnchor, IndexesNav, InfiniteList, Input, Keyboard, KeyboardPopout, List, ListItem, LoadMore, Loading, Marquee, Menu, MenuItem, Motion, Navbar, NavbarItem, NavbarPit, NoticeBar, Notify, OnlyChild, Overlay, Pagination, PasswordInput, Picker, PickerInput, PickerPopout, PickerView, PickerViewColumn, Popout, PopoutInput, Popover, Popup, PreviewImage, ProgressBar, ProgressCircle, PullDownRefresh, PuzzleVerify, Qrcode, REMOVE_SWIPER_CONTEXT_KEY, Radio, RadioGroup, RadioInput, RadioPopout, Rate, ReadMore, Result, RotateVerify, Row, SWIPER_AUTO_HEIGHT_KEY, ScrollList, ScrollSpy, ScrollSpyAnchor, Search, Segmented, SegmentedItem, Select, SelectInput, SelectOption, SelectOptionGroup, SelectPopout, ShareSheet, ShareSheetIcon, ShareSheetItem, ShareSheetRow, Sidebar, SidebarItem, Signature, Skeleton, SkeletonAvatar, SkeletonBlock, SkeletonParagraph, SkeletonTitle, SlideVerify, Slider, Space, Spring, StatusBar, Step, Stepper, Steps, Sticky, StickyBox, SwipeAction, Swiper, SwiperItem, Switch, Tab, Tabbar, TabbarItem, TabbarPit, Table, Tabs, Tag, Text, Timeline, TimelineItem, Toast, Tree, TreeBranch, TreeNode, Upload, UploadPreview, Waterfall, WaterfallItem, WaterfallLoad, Watermark, actionSheet, addSeparator, addUnit, arrayEqual, arrayMove, autoUpdate, barcode, baseLunarYear, calculateBarcodeLayout, camelCase, capitalize, chainGet, chainSet, checkRtl, chooseFile, clamp, clipboard, computePosition, createActionSheet, createBem, createBemStruct, createCropImage, createDialog, createInertialAnimate, createNotify, createPreviewImage, createToast, cropImage, cssVar, cssVarName, currentLocale, debounce, deepClone, defaultBemConfig, defaultColorPickerPresets, defaultColorPickerValue, defaultOptionKeys, defineSetupFnComponent, dialog, earthlyBranches, enhanceComponent, extend, flatVNode, formatColor, formatDate, formatNumber, formatTime, getAllImperatives, getAspectFillSize, getAspectFitSize, getAvailableImperative, getCurrentTime, getDampingValue, getDayOfYear, getDaysAfterLastDay, getDaysBeforeFirstDay, getDaysInMonth, getDaysSinceUnixEpoch, getDecimalsLength, getFileName, getFirstDayWeekday, getGridCenterSize, getGridIndex, getGridPrizeCount, getImperatives, getInBoundValue, getLeafNodes, getLunarDayName, getLunarHourName, getLunarLeapMonth, getLunarLeapMonthDays, getLunarMonthDays, getLunarMonthName, getLunarYearDays, getLunarYearName, getNextMonthDate, getNextMonthHeadDays, getNodeLevel, getOverflowRangeInArea, getPageRange, getPrevMonthDate, getPrevMonthTailDays, getPreviewColor, getRectDampingValue, getRotatedRect, getScrollIntoViewValue, getTouchPoint, getTransformOrigin, getTreeCheckedKeys, getTreeHalfCheckedKeys, getTwoPointsDistance, heavenlyStems, hslToHsv, hslToHwb, hslToRgb, hsvToHsl, hwbToHsl, imageDataToDataURL, inRange, initializeCheckNodes, installer, isBoolean, isColorScheme, isConfigObject, isDate, isEmptyArray, isEmptyBinding, isEmptyValue, isFileUrl, isFunction, isImageFile, isImageUrl, isKorean, isLeapYear, isNoEmptyArray, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isRectEqual, isRenderVisible, isSizeEqual, isString, isUndefined, isVideoFile, isVideoUrl, isVisibleEmpty, kebabCase, loadImage, localeContextKey, logError, looseToNumber, lowerFirst, lunarDayNames, lunarInfo, lunarMonthNames, lunarToSolar, lunarYearNames, mapTreeToGrid, matchScrollVisible, measureTextWidth, minmaxDate, mround, nestedToMulti, noop, normalizeBarcodeOptions, normalizeHsla, normalizeHsva, notify, omit, omitFormPopoutProps, parseColor, parseDate, partition, partitionPopoutInputProps, pascalCase, pick, plateEnglishLetterKeys, plateProvinceKeys, plateSuffixKeys, prepareEnvironment, previewImage, provideColorScheme, provideLocale, qrcode, random, reactiveComputed, readFileContent, rgbToHsl, round, safeAreaInsets, scrollToTarget, setCheckedRecursively, setLocale, shuffle, sleep, snakeCase, solarToLunar, spaceSizes, splitUnit, spreadEach, springFestivals, throttle, toArray, toDate, toDateNumber, toDateString, toMonthNumber, toReactive, toTouchEvent, toast, treeToMap, uniqid, updateAncestorsChecked, upperFirst, useClickOutside, useColorScheme, useComposition, useCountDown, useDragPinch, useElementBackTop, useElementScroll, useFormContext, useFormItem, useFormItemContext, useFormPopout, useImperative, useInPopup, useIndeterminate, useInitialVelocity, useIntersectionObserver, useKeyList, useLoadMore, useLocale, useLockScroll, useLuckyDraw, useLuckyGrid, useLuckyWheel, useMotioning, useOptionKeys, usePageBackTop, usePageScroll, usePointerDown, usePopoutInput, usePopper, usePopupEnter, usePopupVisibleHookProvide, useReachBottom, useResizeObserver, useRtl, useScrollSide, useScrollSpy, useScroller, useSimulatedClick, useSimulatedDblClick, useSimulatedPress, useSingleTask, useSlotMachine, useStopMovedClick, useTimeout, useTimeoutLoading, useTranslate, useTranslateWithPrefix, useWindowResize, useZIndex, walkAncestor, walkDescendant, walkNodes, windowInfo, withResolvers };
|
package/package.json
CHANGED
package/use/useClickOutside.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type Ref } from 'vue';
|
|
2
|
-
export declare function useClickOutside(elRef: Ref<Element | null>, callback: (event: Event) => void, enabled:
|
|
1
|
+
import { type MaybeRefOrGetter, type Ref } from 'vue';
|
|
2
|
+
export declare function useClickOutside(elRef: Ref<Element | null>, callback: (event: Event) => void, enabled: MaybeRefOrGetter<boolean>, type?: 'click' | 'touchstart'): void;
|
package/use/useClickOutside.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useTimeout } from "./useTimeout.js";
|
|
2
|
-
import { onUnmounted, watch } from "vue";
|
|
2
|
+
import { onUnmounted, toValue, watch } from "vue";
|
|
3
3
|
//#region packages/sard/use/useClickOutside.ts
|
|
4
4
|
function useClickOutside(elRef, callback, enabled, type = "click") {
|
|
5
5
|
const events = {
|
|
@@ -28,7 +28,7 @@ function useClickOutside(elRef, callback, enabled, type = "click") {
|
|
|
28
28
|
});
|
|
29
29
|
isBinding = false;
|
|
30
30
|
};
|
|
31
|
-
watch(enabled, (enabled) => {
|
|
31
|
+
watch(() => toValue(enabled), (enabled) => {
|
|
32
32
|
bindTimer.clear();
|
|
33
33
|
if (enabled) bindTimer.set(() => {
|
|
34
34
|
bind();
|
package/use/useResizeObserver.js
CHANGED
|
@@ -7,10 +7,10 @@ function useResizeObserver(target, callback, disabled) {
|
|
|
7
7
|
});
|
|
8
8
|
const observer = new ResizeObserver((entries) => {
|
|
9
9
|
for (const entry of entries) {
|
|
10
|
-
const contentSize = entry.
|
|
10
|
+
const contentSize = entry.contentRect;
|
|
11
11
|
Object.assign(size, {
|
|
12
|
-
width: contentSize.
|
|
13
|
-
height: contentSize.
|
|
12
|
+
width: contentSize.width,
|
|
13
|
+
height: contentSize.height
|
|
14
14
|
});
|
|
15
15
|
callback?.(size);
|
|
16
16
|
}
|
package/utils/scroller/Scroll.js
CHANGED
|
@@ -54,14 +54,14 @@ var Scroll = class {
|
|
|
54
54
|
this.spring.snap(e);
|
|
55
55
|
this.spring.setEnd(-this.extent);
|
|
56
56
|
} else this.springing = false;
|
|
57
|
-
this.startTime =
|
|
57
|
+
this.startTime = Date.now();
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* 计算当前时间点的位置,如果超出边界则切换到弹簧回弹模式。
|
|
61
61
|
*/
|
|
62
62
|
position(e) {
|
|
63
63
|
if (!this.startTime) return 0;
|
|
64
|
-
if (!e) e = (
|
|
64
|
+
if (!e) e = (Date.now() - this.startTime) / 1e3;
|
|
65
65
|
if (this.springing) return this.spring.position() + this.springOffset;
|
|
66
66
|
let t = this.friction.position(e);
|
|
67
67
|
const n = this.velocity(e);
|
|
@@ -1,39 +1,23 @@
|
|
|
1
|
-
import { type Ref } from 'vue';
|
|
2
1
|
import type { Friction } from './Friction';
|
|
3
2
|
import type { Spring } from './Spring';
|
|
4
|
-
interface OnScrollEvent {
|
|
5
|
-
target: {
|
|
6
|
-
scrollLeft: number;
|
|
7
|
-
scrollTop: number;
|
|
8
|
-
scrollHeight: number;
|
|
9
|
-
scrollWidth: number;
|
|
10
|
-
offsetHeight: number;
|
|
11
|
-
offsetWidth: number;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
3
|
export interface ScrollerOptions {
|
|
15
|
-
enableSnap?: boolean;
|
|
16
4
|
itemSize?: number;
|
|
17
|
-
enableX?: boolean;
|
|
18
|
-
enableY?: boolean;
|
|
19
5
|
scrollWidth?: number;
|
|
20
6
|
scrollHeight?: number;
|
|
21
7
|
friction?: Friction;
|
|
22
8
|
spring?: Spring;
|
|
23
|
-
|
|
24
|
-
onSnap?: (index: number) => void;
|
|
9
|
+
onSnap: (index: number) => void;
|
|
25
10
|
onTap?: (event: TouchEvent) => void;
|
|
26
11
|
}
|
|
27
12
|
/**
|
|
28
13
|
* 触摸滚动器,负责处理触摸/鼠标滚动交互、惯性滚动、越界回弹和 snap 对齐。
|
|
29
|
-
* @param element 滚动的 DOM 容器元素
|
|
30
14
|
*/
|
|
31
|
-
export declare function useScroller(
|
|
32
|
-
|
|
15
|
+
export declare function useScroller(options: ScrollerOptions): {
|
|
16
|
+
position: import("vue").ComputedRef<number>;
|
|
17
|
+
update: (height: number, _itemSize: number, containerHeight: number, contentHeight: number) => void;
|
|
33
18
|
scrollTo: (_position: number, time?: number) => Promise<void>;
|
|
34
19
|
isIdle: () => boolean;
|
|
35
20
|
handleTouchStart: (event: TouchEvent) => void;
|
|
36
21
|
handleTouchMove: (event: TouchEvent) => void;
|
|
37
22
|
handleTouchEnd: (event: TouchEvent) => void;
|
|
38
23
|
};
|
|
39
|
-
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { clamp } from "../number.js";
|
|
2
2
|
import { useScrollBinding } from "./useScrollBinding.js";
|
|
3
3
|
import { Scroll } from "./Scroll.js";
|
|
4
4
|
import { useEasingAnimation } from "./useEasingAnimation.js";
|
|
5
5
|
import { useScrollAnimation } from "./useScrollAnimation.js";
|
|
6
|
-
import { computed, ref
|
|
6
|
+
import { computed, ref } from "vue";
|
|
7
7
|
//#region packages/sard/utils/scroller/useScroller.ts
|
|
8
8
|
/**
|
|
9
9
|
* 计算当前滚动位置对应的 snap 索引。
|
|
@@ -16,23 +16,12 @@ function calculateSnapIndex(position, itemSize) {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* 触摸滚动器,负责处理触摸/鼠标滚动交互、惯性滚动、越界回弹和 snap 对齐。
|
|
19
|
-
* @param element 滚动的 DOM 容器元素
|
|
20
19
|
*/
|
|
21
|
-
function useScroller(
|
|
20
|
+
function useScroller(options) {
|
|
22
21
|
/** 单项尺寸,用于 snap 计算 */
|
|
23
22
|
let itemSize = options.itemSize || 0;
|
|
24
|
-
/** 是否启用 snap 对齐 */
|
|
25
|
-
const enableSnap = computed(() => options.enableSnap);
|
|
26
|
-
/** 是否启用水平滚动 */
|
|
27
|
-
const enableX = computed(() => options.enableX);
|
|
28
|
-
/** 是否启用垂直滚动 */
|
|
29
|
-
const enableY = computed(() => options.enableY);
|
|
30
23
|
/** 可滚动范围大小 */
|
|
31
24
|
let extent = 0;
|
|
32
|
-
/** 可滚动内容宽度 */
|
|
33
|
-
let scrollWidth = 0;
|
|
34
|
-
/** 可滚动内容高度 */
|
|
35
|
-
let scrollHeight = 0;
|
|
36
25
|
/** 当前滚动偏移位置 */
|
|
37
26
|
const position = ref(0);
|
|
38
27
|
/** 滚动物理模型 */
|
|
@@ -53,7 +42,7 @@ function useScroller(element, options) {
|
|
|
53
42
|
const _position = position.value % _itemSize;
|
|
54
43
|
const i = Math.abs(_position) > _itemSize / 2 ? position.value - (_itemSize - Math.abs(_position)) : position.value - _position;
|
|
55
44
|
if (position.value !== i) scrollTo(-i, time).then(() => {
|
|
56
|
-
|
|
45
|
+
options.onSnap(Math.round(Math.abs(position.value) / _itemSize));
|
|
57
46
|
});
|
|
58
47
|
else status = "idle";
|
|
59
48
|
};
|
|
@@ -71,45 +60,17 @@ function useScroller(element, options) {
|
|
|
71
60
|
});
|
|
72
61
|
};
|
|
73
62
|
/**
|
|
74
|
-
* 触发 onScroll 回调,仅在位置实际变化时执行。
|
|
75
|
-
*/
|
|
76
|
-
const dispatchScroll = () => {
|
|
77
|
-
const el = element.value;
|
|
78
|
-
if (!el) return;
|
|
79
|
-
if (isFunction(options.onScroll)) {
|
|
80
|
-
const event = { target: {
|
|
81
|
-
scrollLeft: enableX.value ? -position.value : 0,
|
|
82
|
-
scrollTop: enableY.value ? -position.value : 0,
|
|
83
|
-
scrollHeight: scrollHeight || el.offsetHeight,
|
|
84
|
-
scrollWidth: scrollWidth || el.offsetWidth,
|
|
85
|
-
offsetHeight: el.parentElement.offsetHeight,
|
|
86
|
-
offsetWidth: el.parentElement.offsetWidth
|
|
87
|
-
} };
|
|
88
|
-
options.onScroll(event);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
63
|
* 更新滚动范围、位置、itemSize,并根据变化派发事件与 snap 回调。
|
|
93
64
|
*/
|
|
94
|
-
const update = (height,
|
|
95
|
-
const el = element.value;
|
|
96
|
-
if (!el) return;
|
|
65
|
+
const update = (height, _itemSize, containerHeight, contentHeight) => {
|
|
97
66
|
let nextExtent = 0;
|
|
98
67
|
const _position = position.value;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
scrollWidth = _scrollHeight || 0;
|
|
102
|
-
} else {
|
|
103
|
-
nextExtent = el.childNodes.length ? (_scrollHeight || el.offsetHeight) - el.parentElement.offsetHeight : 0;
|
|
104
|
-
scrollHeight = _scrollHeight || 0;
|
|
105
|
-
}
|
|
106
|
-
if (typeof height === "number") position.value = -height;
|
|
68
|
+
nextExtent = contentHeight - containerHeight;
|
|
69
|
+
position.value = -height;
|
|
107
70
|
if (position.value < -nextExtent) position.value = -nextExtent;
|
|
108
71
|
else if (position.value > 0) position.value = 0;
|
|
109
|
-
itemSize = _itemSize
|
|
110
|
-
if (_position !== position.value)
|
|
111
|
-
if (isFunction(options.onSnap)) options.onSnap(Math.round(Math.abs(position.value) / itemSize));
|
|
112
|
-
}
|
|
72
|
+
itemSize = _itemSize;
|
|
73
|
+
if (_position !== position.value) options.onSnap(Math.round(Math.abs(position.value) / itemSize));
|
|
113
74
|
extent = nextExtent;
|
|
114
75
|
scroll.extent = nextExtent;
|
|
115
76
|
};
|
|
@@ -133,11 +94,10 @@ function useScroller(element, options) {
|
|
|
133
94
|
/**
|
|
134
95
|
* 根据手势移动距离更新当前位置,并触发滚动事件。
|
|
135
96
|
*/
|
|
136
|
-
const onTouchMove = (
|
|
97
|
+
const onTouchMove = (_x, y) => {
|
|
137
98
|
status = "drag";
|
|
138
99
|
let nextPos = startPosition;
|
|
139
|
-
|
|
140
|
-
else if (enableY.value) nextPos += y;
|
|
100
|
+
nextPos += y;
|
|
141
101
|
if (nextPos > 0) nextPos *= .5;
|
|
142
102
|
else if (nextPos < -extent) nextPos = .5 * (nextPos + extent) - extent;
|
|
143
103
|
position.value = nextPos;
|
|
@@ -150,54 +110,34 @@ function useScroller(element, options) {
|
|
|
150
110
|
options.onTap?.(event);
|
|
151
111
|
return;
|
|
152
112
|
}
|
|
153
|
-
if (
|
|
154
|
-
if (
|
|
155
|
-
snap();
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
if (enableX.value && (Math.abs(x) < itemSize && Math.abs(o.x) < 300 || Math.abs(o.x) < 150)) {
|
|
113
|
+
if (position.value > -extent && position.value < 0) {
|
|
114
|
+
if (Math.abs(y) < itemSize && Math.abs(o.y) < 300 || Math.abs(o.y) < 150) {
|
|
159
115
|
snap();
|
|
160
116
|
return;
|
|
161
117
|
}
|
|
162
118
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const l = s % itemSize;
|
|
169
|
-
c = Math.abs(l) > itemSize / 2 ? s - (itemSize - Math.abs(l)) : s - l;
|
|
170
|
-
if (c <= 0 && c >= -extent) scroll.setVelocityByEnd(c);
|
|
171
|
-
}
|
|
119
|
+
scroll.set(position.value, o.y);
|
|
120
|
+
const s = scroll.friction.position(100);
|
|
121
|
+
const l = s % itemSize;
|
|
122
|
+
const c = Math.abs(l) > itemSize / 2 ? s - (itemSize - Math.abs(l)) : s - l;
|
|
123
|
+
if (c <= 0 && c >= -extent) scroll.setVelocityByEnd(c);
|
|
172
124
|
status = "scroll";
|
|
173
125
|
scrollAnim.play(() => {
|
|
174
126
|
const pos = scroll.position((Date.now() - scroll.startTime) / 1e3);
|
|
175
127
|
position.value = pos;
|
|
176
128
|
}, () => {
|
|
177
129
|
status = "idle";
|
|
178
|
-
if (
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
position.value = c;
|
|
182
|
-
}
|
|
183
|
-
if (isFunction(options.onSnap)) options.onSnap(calculateSnapIndex(position.value, itemSize));
|
|
130
|
+
if (c <= 0 && c >= -extent) {
|
|
131
|
+
scroll.setVelocityByEnd(c);
|
|
132
|
+
position.value = c;
|
|
184
133
|
}
|
|
134
|
+
position.value = clamp(position.value, -extent, 0);
|
|
135
|
+
options.onSnap(calculateSnapIndex(position.value, itemSize));
|
|
185
136
|
});
|
|
186
137
|
};
|
|
187
138
|
const { handleTouchStart, handleTouchMove, handleTouchEnd } = useScrollBinding(onTouchStart, onTouchMove, onTouchEnd);
|
|
188
|
-
watchPostEffect(() => {
|
|
189
|
-
const el = element.value;
|
|
190
|
-
if (el) {
|
|
191
|
-
let transform = "";
|
|
192
|
-
if (enableX.value) transform = "translateX(" + position.value + "px) translateZ(0)";
|
|
193
|
-
else if (enableY.value) transform = "translateY(" + position.value + "px) translateZ(0)";
|
|
194
|
-
el.style.transform = transform;
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
watch(position, () => {
|
|
198
|
-
dispatchScroll();
|
|
199
|
-
});
|
|
200
139
|
return {
|
|
140
|
+
position: computed(() => position.value),
|
|
201
141
|
update,
|
|
202
142
|
scrollTo,
|
|
203
143
|
isIdle,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type SwipeActionGroupProps, type SwipeActionGroupSlots, type SwipeActionGroupExpose } from './common';
|
|
2
|
-
type __VLS_Slots = SwipeActionGroupSlots;
|
|
3
|
-
declare const __VLS_base: import("vue").DefineComponent<SwipeActionGroupProps, SwipeActionGroupExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<SwipeActionGroupProps> & Readonly<{}>, {
|
|
4
|
-
multiple: boolean;
|
|
5
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
-
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
7
|
-
declare const _default: typeof __VLS_export;
|
|
8
|
-
export default _default;
|
|
9
|
-
type __VLS_WithSlots<T, S> = T & {
|
|
10
|
-
new (): {
|
|
11
|
-
$slots: S;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { createBem } from "../../utils/bem.js";
|
|
2
|
-
import { defaultSwipeActionGroupProps, swipeActionGroupContextKey } from "./common.js";
|
|
3
|
-
import { createElementBlock, defineComponent, mergeDefaults, normalizeClass, openBlock, provide, reactive, renderSlot, toRef, unref } from "vue";
|
|
4
|
-
//#region packages/sard/components/swipe-action/swipe-action-group.vue
|
|
5
|
-
var swipe_action_group_default = /*@__PURE__*/ defineComponent({
|
|
6
|
-
__name: "swipe-action-group",
|
|
7
|
-
props: /*@__PURE__*/ mergeDefaults({ multiple: {
|
|
8
|
-
type: Boolean,
|
|
9
|
-
required: false
|
|
10
|
-
} }, defaultSwipeActionGroupProps),
|
|
11
|
-
setup(__props, { expose: __expose }) {
|
|
12
|
-
const props = __props;
|
|
13
|
-
const bem = createBem("swipe-action-group");
|
|
14
|
-
const itemMap = /* @__PURE__ */ new Map();
|
|
15
|
-
const closeAll = (exceptId) => {
|
|
16
|
-
itemMap.forEach((item, id) => {
|
|
17
|
-
if (id !== exceptId) item.hide();
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
const register = (id, expose) => {
|
|
21
|
-
itemMap.set(id, expose);
|
|
22
|
-
};
|
|
23
|
-
const unregister = (id) => {
|
|
24
|
-
itemMap.delete(id);
|
|
25
|
-
};
|
|
26
|
-
provide(swipeActionGroupContextKey, reactive({
|
|
27
|
-
multiple: toRef(() => props.multiple),
|
|
28
|
-
register,
|
|
29
|
-
unregister,
|
|
30
|
-
closeAll
|
|
31
|
-
}));
|
|
32
|
-
__expose({ closeAll: () => closeAll() });
|
|
33
|
-
return (_ctx, _cache) => {
|
|
34
|
-
return openBlock(), createElementBlock("div", { class: normalizeClass(unref(bem).b()) }, [renderSlot(_ctx.$slots, "default")], 2);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
//#endregion
|
|
39
|
-
export { swipe_action_group_default as default };
|