@atmo-dev/kit 0.20.0 → 0.21.0
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/gestures.d.ts +5 -1
- package/dist/gestures.js +6 -3
- package/package.json +1 -1
package/dist/gestures.d.ts
CHANGED
|
@@ -35,7 +35,11 @@ export declare const touchOf: (event: TouchEvent, id: number) => Touch | undefin
|
|
|
35
35
|
* out of sight until what `onback` returns has settled, so return a promise for a navigation
|
|
36
36
|
* that takes a moment. Returns a function that stops listening.
|
|
37
37
|
*
|
|
38
|
+
* With `follow: false` nothing moves: `onback` is called on release, as a back button would.
|
|
39
|
+
*
|
|
38
40
|
* Swipes are ignored where a drawer's are: at the left edge, in sideways scrollers, fields,
|
|
39
41
|
* dialogs and `data-no-swipe`. A page that uses this should not also open a drawer by swipe.
|
|
40
42
|
*/
|
|
41
|
-
export declare function swipeBack(target: () => HTMLElement | null | undefined, onback: () => unknown
|
|
43
|
+
export declare function swipeBack(target: () => HTMLElement | null | undefined, onback: () => unknown, { follow }?: {
|
|
44
|
+
follow?: boolean;
|
|
45
|
+
}): () => void;
|
package/dist/gestures.js
CHANGED
|
@@ -66,10 +66,13 @@ export const touchOf = (event, id) => Array.from(event.touches).find((touch) =>
|
|
|
66
66
|
* out of sight until what `onback` returns has settled, so return a promise for a navigation
|
|
67
67
|
* that takes a moment. Returns a function that stops listening.
|
|
68
68
|
*
|
|
69
|
+
* With `follow: false` nothing moves: `onback` is called on release, as a back button would.
|
|
70
|
+
*
|
|
69
71
|
* Swipes are ignored where a drawer's are: at the left edge, in sideways scrollers, fields,
|
|
70
72
|
* dialogs and `data-no-swipe`. A page that uses this should not also open a drawer by swipe.
|
|
71
73
|
*/
|
|
72
|
-
export function swipeBack(target, onback) {
|
|
74
|
+
export function swipeBack(target, onback, { follow = true } = {}) {
|
|
75
|
+
const still = () => !follow || reducedMotion();
|
|
73
76
|
let start;
|
|
74
77
|
let node;
|
|
75
78
|
let moves = [];
|
|
@@ -115,7 +118,7 @@ export function swipeBack(target, onback) {
|
|
|
115
118
|
if (event.cancelable)
|
|
116
119
|
event.preventDefault();
|
|
117
120
|
track(moves, touch, event);
|
|
118
|
-
if (!
|
|
121
|
+
if (!still())
|
|
119
122
|
node.style.transform = `translateX(${Math.max(0, touch.clientX - start.x)}px)`;
|
|
120
123
|
};
|
|
121
124
|
const onEnd = (event) => {
|
|
@@ -129,7 +132,7 @@ export function swipeBack(target, onback) {
|
|
|
129
132
|
const fast = speed(moves, 'x');
|
|
130
133
|
const back = event.type === 'touchend' &&
|
|
131
134
|
(fast > 0.4 || (fast > -0.3 && dx > Math.min(140, innerWidth * 0.35)));
|
|
132
|
-
if (
|
|
135
|
+
if (still()) {
|
|
133
136
|
node = undefined;
|
|
134
137
|
return void (back && onback());
|
|
135
138
|
}
|