@celljs/ta-web 4.9.1 → 4.10.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/README.en.md +4 -3
- package/README.md +4 -3
- package/esm/browser/assistant/assistant-chat-list.js +8 -2
- package/esm/browser/assistant/assistant-extension.d.ts +8 -1
- package/esm/browser/assistant/assistant-extension.js +20 -0
- package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
- package/esm/browser/assistant/assistant-task-util.d.ts +2 -0
- package/esm/browser/assistant/assistant-task-util.js +5 -3
- package/esm/browser/assistant/assistant-view.js +81 -56
- package/esm/browser/assistant/assistant.d.ts +10 -1
- package/esm/browser/assistant/assistant.js +44 -5
- package/esm/browser/chat/chat-packages.d.ts +39 -0
- package/esm/browser/chat/chat-packages.js +70 -0
- package/esm/browser/chat/chat-protocol.d.ts +23 -1
- package/esm/browser/chat/chat-stores.d.ts +59 -0
- package/esm/browser/chat/chat-stores.js +121 -0
- package/esm/browser/chat/chat-util.d.ts +17 -0
- package/esm/browser/chat/chat-util.js +61 -0
- package/esm/browser/chat/chat-view.js +33 -12
- package/esm/browser/chat/chat.d.ts +31 -39
- package/esm/browser/chat/chat.js +226 -175
- package/esm/browser/components/app-nav.d.ts +6 -3
- package/esm/browser/components/app-nav.js +19 -10
- package/esm/browser/components/app-shell-hooks.d.ts +2 -2
- package/esm/browser/components/app-shell-hooks.js +7 -3
- package/esm/browser/components/app-view.js +75 -21
- package/esm/browser/components/chat-list.d.ts +20 -2
- package/esm/browser/components/chat-list.js +138 -22
- package/esm/browser/components/composer-box.d.ts +5 -5
- package/esm/browser/components/composer-box.js +111 -4
- package/esm/browser/components/composer.d.ts +7 -0
- package/esm/browser/components/composer.js +5 -4
- package/esm/browser/components/connection-bar.js +50 -17
- package/esm/browser/components/context-menu.d.ts +30 -4
- package/esm/browser/components/context-menu.js +199 -37
- package/esm/browser/components/conversation-scroll.d.ts +129 -6
- package/esm/browser/components/conversation-scroll.js +429 -109
- package/esm/browser/components/earlier-messages.d.ts +2 -1
- package/esm/browser/components/earlier-messages.js +2 -17
- package/esm/browser/components/editor-area.d.ts +3 -1
- package/esm/browser/components/editor-area.js +6 -5
- package/esm/browser/components/empty-pictures.d.ts +0 -2
- package/esm/browser/components/empty-pictures.js +0 -16
- package/esm/browser/components/folder-picker.d.ts +5 -2
- package/esm/browser/components/folder-picker.js +26 -8
- package/esm/browser/components/held-talk.d.ts +28 -0
- package/esm/browser/components/held-talk.js +76 -0
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/icon.d.ts +2 -2
- package/esm/browser/components/icon.js +5 -6
- package/esm/browser/components/image-viewer.d.ts +124 -0
- package/esm/browser/components/image-viewer.js +397 -0
- package/esm/browser/components/lightbox.d.ts +11 -0
- package/esm/browser/components/lightbox.js +24 -0
- package/esm/browser/components/markdown.d.ts +6 -2
- package/esm/browser/components/markdown.js +24 -10
- package/esm/browser/components/media.js +1 -10
- package/esm/browser/components/message-footer.d.ts +16 -2
- package/esm/browser/components/message-footer.js +29 -12
- package/esm/browser/components/message-list.d.ts +24 -3
- package/esm/browser/components/message-list.js +149 -20
- package/esm/browser/components/message-menu.d.ts +3 -1
- package/esm/browser/components/message-menu.js +18 -3
- package/esm/browser/components/nav-places.d.ts +16 -1
- package/esm/browser/components/nav-places.js +12 -3
- package/esm/browser/components/phone-shell.d.ts +4 -1
- package/esm/browser/components/phone-shell.js +3 -1
- package/esm/browser/components/run-status.js +3 -3
- package/esm/browser/components/session-settings.d.ts +6 -0
- package/esm/browser/components/session-settings.js +14 -1
- package/esm/browser/components/session-view.js +8 -4
- package/esm/browser/components/settings-parts.d.ts +2 -2
- package/esm/browser/components/settings-parts.js +24 -1
- package/esm/browser/components/swipe-row.d.ts +2 -2
- package/esm/browser/components/swipe-row.js +7 -3
- package/esm/browser/components/tool-view.js +14 -12
- package/esm/browser/components/voice-button.d.ts +1 -1
- package/esm/browser/components/voice-button.js +1 -1
- package/esm/browser/components/voice-talk.d.ts +43 -0
- package/esm/browser/components/voice-talk.js +222 -0
- package/esm/browser/device/device.d.ts +3 -0
- package/esm/browser/device/device.js +11 -1
- package/esm/browser/device/hold.d.ts +42 -0
- package/esm/browser/device/hold.js +136 -0
- package/esm/browser/device/launch-screen.d.ts +1 -1
- package/esm/browser/device/launch-screen.js +1 -1
- package/esm/browser/device/long-press.d.ts +2 -0
- package/esm/browser/device/long-press.js +16 -1
- package/esm/browser/device/pull-down.d.ts +4 -2
- package/esm/browser/device/pull-down.js +64 -76
- package/esm/browser/device/row-swipe.d.ts +35 -10
- package/esm/browser/device/row-swipe.js +149 -71
- package/esm/browser/device/shake-undo.d.ts +16 -0
- package/esm/browser/device/shake-undo.js +59 -0
- package/esm/browser/device/sheet-swipe.d.ts +118 -18
- package/esm/browser/device/sheet-swipe.js +406 -107
- package/esm/browser/extension/web-extension-api.d.ts +97 -1
- package/esm/browser/extension/web-extension-code.d.ts +6 -0
- package/esm/browser/extension/web-extension-code.js +24 -0
- package/esm/browser/extension/web-extension-protocol.d.ts +23 -1
- package/esm/browser/extension/web-extension-protocol.js +8 -0
- package/esm/browser/extension/web-extensions.d.ts +14 -1
- package/esm/browser/extension/web-extensions.js +122 -23
- package/esm/browser/files/files-protocol.d.ts +25 -0
- package/esm/browser/files/files-protocol.js +2 -0
- package/esm/browser/files/files.d.ts +35 -0
- package/esm/browser/files/files.js +119 -0
- package/esm/browser/i18n/locales.d.ts +24 -2
- package/esm/browser/i18n/messages.d.ts +23 -1
- package/esm/browser/i18n/messages.js +48 -4
- package/esm/browser/index.d.ts +6 -0
- package/esm/browser/index.js +6 -0
- package/esm/browser/notices/notices-protocol.d.ts +9 -1
- package/esm/browser/notices/notices.d.ts +2 -0
- package/esm/browser/notices/notices.js +20 -10
- package/esm/browser/offline/device-values.d.ts +55 -0
- package/esm/browser/offline/device-values.js +142 -0
- package/esm/browser/offline/kept-chats-protocol.d.ts +17 -0
- package/esm/browser/offline/kept-chats-protocol.js +2 -0
- package/esm/browser/offline/kept-chats.d.ts +47 -0
- package/esm/browser/offline/kept-chats.js +146 -0
- package/esm/browser/offline/offline-reads.d.ts +44 -0
- package/esm/browser/offline/offline-reads.js +107 -0
- package/esm/browser/settings/settings-protocol.d.ts +2 -0
- package/esm/browser/settings/settings-protocol.js +2 -0
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +57 -17
- package/esm/browser/style/device.js +27 -4
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +67 -15
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +2 -1
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +46 -3
- package/esm/browser/util/frame.d.ts +5 -4
- package/esm/browser/util/frame.js +5 -4
- package/esm/browser/util/markdown.d.ts +18 -1
- package/esm/browser/util/markdown.js +119 -5
- package/esm/browser/util/process.d.ts +21 -0
- package/esm/browser/util/process.js +45 -1
- package/esm/browser/util/voice.d.ts +5 -2
- package/esm/browser/util/voice.js +6 -3
- package/esm/browser/util/zoom.d.ts +46 -0
- package/esm/browser/util/zoom.js +96 -0
- package/esm/browser/workbench-calls.d.ts +59 -0
- package/esm/browser/workbench-calls.js +141 -0
- package/esm/browser/workbench-protocol.d.ts +5 -1
- package/esm/browser/workbench-util.d.ts +7 -0
- package/esm/browser/workbench-util.js +9 -2
- package/esm/browser/workbench.d.ts +14 -5
- package/esm/browser/workbench.js +51 -31
- package/lib/browser/assistant/assistant-chat-list.js +8 -2
- package/lib/browser/assistant/assistant-extension.d.ts +8 -1
- package/lib/browser/assistant/assistant-extension.js +20 -0
- package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
- package/lib/browser/assistant/assistant-task-util.d.ts +2 -0
- package/lib/browser/assistant/assistant-task-util.js +5 -3
- package/lib/browser/assistant/assistant-view.js +78 -53
- package/lib/browser/assistant/assistant.d.ts +10 -1
- package/lib/browser/assistant/assistant.js +44 -5
- package/lib/browser/chat/chat-packages.d.ts +40 -0
- package/lib/browser/chat/chat-packages.js +74 -0
- package/lib/browser/chat/chat-protocol.d.ts +23 -1
- package/lib/browser/chat/chat-stores.d.ts +60 -0
- package/lib/browser/chat/chat-stores.js +125 -0
- package/lib/browser/chat/chat-util.d.ts +18 -0
- package/lib/browser/chat/chat-util.js +64 -0
- package/lib/browser/chat/chat-view.js +33 -12
- package/lib/browser/chat/chat.d.ts +31 -39
- package/lib/browser/chat/chat.js +227 -176
- package/lib/browser/components/app-nav.d.ts +6 -3
- package/lib/browser/components/app-nav.js +17 -8
- package/lib/browser/components/app-shell-hooks.d.ts +2 -2
- package/lib/browser/components/app-shell-hooks.js +7 -3
- package/lib/browser/components/app-view.js +74 -20
- package/lib/browser/components/chat-list.d.ts +20 -2
- package/lib/browser/components/chat-list.js +137 -21
- package/lib/browser/components/composer-box.d.ts +5 -5
- package/lib/browser/components/composer-box.js +111 -4
- package/lib/browser/components/composer.d.ts +7 -0
- package/lib/browser/components/composer.js +5 -4
- package/lib/browser/components/connection-bar.js +48 -15
- package/lib/browser/components/context-menu.d.ts +30 -4
- package/lib/browser/components/context-menu.js +198 -36
- package/lib/browser/components/conversation-scroll.d.ts +129 -6
- package/lib/browser/components/conversation-scroll.js +431 -110
- package/lib/browser/components/earlier-messages.d.ts +2 -1
- package/lib/browser/components/earlier-messages.js +2 -17
- package/lib/browser/components/editor-area.d.ts +3 -1
- package/lib/browser/components/editor-area.js +5 -4
- package/lib/browser/components/empty-pictures.d.ts +0 -2
- package/lib/browser/components/empty-pictures.js +0 -17
- package/lib/browser/components/folder-picker.d.ts +5 -2
- package/lib/browser/components/folder-picker.js +26 -8
- package/lib/browser/components/held-talk.d.ts +29 -0
- package/lib/browser/components/held-talk.js +79 -0
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/icon.d.ts +2 -2
- package/lib/browser/components/icon.js +7 -6
- package/lib/browser/components/image-viewer.d.ts +125 -0
- package/lib/browser/components/image-viewer.js +435 -0
- package/lib/browser/components/lightbox.d.ts +12 -0
- package/lib/browser/components/lightbox.js +60 -0
- package/lib/browser/components/markdown.d.ts +6 -2
- package/lib/browser/components/markdown.js +24 -10
- package/lib/browser/components/media.js +2 -11
- package/lib/browser/components/message-footer.d.ts +16 -2
- package/lib/browser/components/message-footer.js +31 -12
- package/lib/browser/components/message-list.d.ts +24 -3
- package/lib/browser/components/message-list.js +146 -16
- package/lib/browser/components/message-menu.d.ts +3 -1
- package/lib/browser/components/message-menu.js +17 -2
- package/lib/browser/components/nav-places.d.ts +16 -1
- package/lib/browser/components/nav-places.js +13 -3
- package/lib/browser/components/phone-shell.d.ts +4 -1
- package/lib/browser/components/phone-shell.js +3 -1
- package/lib/browser/components/run-status.js +3 -3
- package/lib/browser/components/session-settings.d.ts +6 -0
- package/lib/browser/components/session-settings.js +14 -1
- package/lib/browser/components/session-view.js +7 -3
- package/lib/browser/components/settings-parts.d.ts +2 -2
- package/lib/browser/components/settings-parts.js +24 -1
- package/lib/browser/components/swipe-row.d.ts +2 -2
- package/lib/browser/components/swipe-row.js +7 -3
- package/lib/browser/components/tool-view.js +14 -12
- package/lib/browser/components/voice-button.d.ts +1 -1
- package/lib/browser/components/voice-button.js +1 -1
- package/lib/browser/components/voice-talk.d.ts +44 -0
- package/lib/browser/components/voice-talk.js +260 -0
- package/lib/browser/device/device.d.ts +3 -0
- package/lib/browser/device/device.js +11 -1
- package/lib/browser/device/hold.d.ts +43 -0
- package/lib/browser/device/hold.js +173 -0
- package/lib/browser/device/launch-screen.d.ts +1 -1
- package/lib/browser/device/launch-screen.js +1 -1
- package/lib/browser/device/long-press.d.ts +2 -0
- package/lib/browser/device/long-press.js +16 -1
- package/lib/browser/device/pull-down.d.ts +4 -2
- package/lib/browser/device/pull-down.js +63 -75
- package/lib/browser/device/row-swipe.d.ts +35 -10
- package/lib/browser/device/row-swipe.js +148 -70
- package/lib/browser/device/shake-undo.d.ts +17 -0
- package/lib/browser/device/shake-undo.js +63 -0
- package/lib/browser/device/sheet-swipe.d.ts +118 -18
- package/lib/browser/device/sheet-swipe.js +410 -108
- package/lib/browser/extension/web-extension-api.d.ts +97 -1
- package/lib/browser/extension/web-extension-code.d.ts +6 -0
- package/lib/browser/extension/web-extension-code.js +24 -0
- package/lib/browser/extension/web-extension-protocol.d.ts +23 -1
- package/lib/browser/extension/web-extension-protocol.js +9 -1
- package/lib/browser/extension/web-extensions.d.ts +14 -1
- package/lib/browser/extension/web-extensions.js +120 -21
- package/lib/browser/files/files-protocol.d.ts +26 -0
- package/lib/browser/files/files-protocol.js +5 -0
- package/lib/browser/files/files.d.ts +36 -0
- package/lib/browser/files/files.js +122 -0
- package/lib/browser/i18n/locales.d.ts +24 -2
- package/lib/browser/i18n/messages.d.ts +23 -1
- package/lib/browser/i18n/messages.js +48 -4
- package/lib/browser/index.d.ts +6 -0
- package/lib/browser/index.js +6 -0
- package/lib/browser/notices/notices-protocol.d.ts +9 -1
- package/lib/browser/notices/notices.d.ts +2 -0
- package/lib/browser/notices/notices.js +20 -10
- package/lib/browser/offline/device-values.d.ts +56 -0
- package/lib/browser/offline/device-values.js +148 -0
- package/lib/browser/offline/kept-chats-protocol.d.ts +18 -0
- package/lib/browser/offline/kept-chats-protocol.js +5 -0
- package/lib/browser/offline/kept-chats.d.ts +48 -0
- package/lib/browser/offline/kept-chats.js +149 -0
- package/lib/browser/offline/offline-reads.d.ts +45 -0
- package/lib/browser/offline/offline-reads.js +111 -0
- package/lib/browser/settings/settings-protocol.d.ts +2 -0
- package/lib/browser/settings/settings-protocol.js +2 -0
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +57 -17
- package/lib/browser/style/device.js +27 -4
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +67 -15
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +2 -1
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +46 -3
- package/lib/browser/util/frame.d.ts +5 -4
- package/lib/browser/util/frame.js +5 -4
- package/lib/browser/util/markdown.d.ts +18 -1
- package/lib/browser/util/markdown.js +119 -5
- package/lib/browser/util/process.d.ts +21 -0
- package/lib/browser/util/process.js +46 -2
- package/lib/browser/util/voice.d.ts +5 -2
- package/lib/browser/util/voice.js +6 -3
- package/lib/browser/util/zoom.d.ts +47 -0
- package/lib/browser/util/zoom.js +99 -0
- package/lib/browser/workbench-calls.d.ts +60 -0
- package/lib/browser/workbench-calls.js +145 -0
- package/lib/browser/workbench-protocol.d.ts +5 -1
- package/lib/browser/workbench-util.d.ts +7 -0
- package/lib/browser/workbench-util.js +10 -3
- package/lib/browser/workbench.d.ts +14 -5
- package/lib/browser/workbench.js +51 -31
- package/package.json +10 -10
- package/public/launch.svg +46 -42
|
@@ -33,9 +33,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.SwipeSettle = exports.SwipeVelocity = exports.SwipeUtil = void 0;
|
|
36
|
+
exports.SwipeFinger = exports.SwipeSettle = exports.SwipeVelocity = exports.SwipeSpring = exports.SwipeUtil = void 0;
|
|
37
|
+
exports.afterLetGo = afterLetGo;
|
|
38
|
+
exports.translated = translated;
|
|
37
39
|
exports.useSheetSwipe = useSheetSwipe;
|
|
38
40
|
const React = __importStar(require("react"));
|
|
41
|
+
const frame_1 = require("../util/frame");
|
|
39
42
|
const device_protocol_1 = require("./device-protocol");
|
|
40
43
|
/** It follows the finger and, let go, ends where it was flicked to, or the nearer side. Pure, for the tests. */
|
|
41
44
|
var SwipeUtil;
|
|
@@ -92,24 +95,29 @@ var SwipeUtil;
|
|
|
92
95
|
return claimed === undefined ? undefined : claimed && !sideways();
|
|
93
96
|
}
|
|
94
97
|
SwipeUtil.takes = takes;
|
|
95
|
-
/** Where the sheet
|
|
96
|
-
function
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
/** Where the sheet rests away: `∓width`, on its side; out, it rests at 0. */
|
|
99
|
+
function away(sheet, width) {
|
|
100
|
+
return -outward(sheet) * width;
|
|
101
|
+
}
|
|
102
|
+
SwipeUtil.away = away;
|
|
103
|
+
/** Where the sheet is, between 0 (out) and away, when the finger moved `dx` from where it took it (`from`). */
|
|
104
|
+
function position(sheet, from, dx, width) {
|
|
105
|
+
const rest = away(sheet, width);
|
|
106
|
+
return Math.min(Math.max(rest, 0), Math.max(Math.min(rest, 0), from + dx));
|
|
107
|
+
}
|
|
108
|
+
SwipeUtil.position = position;
|
|
109
|
+
/** Whether it ends out, let go at `x` at `speed` (pixels a millisecond, SwipeVelocity): the way it was flicked, or the nearer side. */
|
|
110
|
+
function settle(sheet, x, width, speed) {
|
|
103
111
|
if (Math.abs(speed) > SwipeUtil.FLICK) {
|
|
104
112
|
return speed * outward(sheet) > 0;
|
|
105
113
|
}
|
|
106
|
-
return Math.abs(
|
|
114
|
+
return Math.abs(x) < width / 2;
|
|
107
115
|
}
|
|
108
116
|
SwipeUtil.settle = settle;
|
|
109
117
|
/**
|
|
110
|
-
* How long it slides on to where it rests, `distance` away (signed), let go at `speed
|
|
111
|
-
*
|
|
112
|
-
*
|
|
118
|
+
* How long it slides on to where it rests, `distance` away (signed), let go at `speed`, where the curves of
|
|
119
|
+
* `linear()` are not (SwipeSpring): on CURVE, as fast at first as the finger was; `longest` (the style's)
|
|
120
|
+
* when the finger was slow, or going the other way.
|
|
113
121
|
*/
|
|
114
122
|
function duration(distance, speed, longest) {
|
|
115
123
|
const toward = Math.sign(distance) * speed;
|
|
@@ -119,12 +127,73 @@ var SwipeUtil;
|
|
|
119
127
|
return Math.round(Math.min(longest, Math.max(SwipeUtil.SHORTEST_MS, (CURVE_START * Math.abs(distance)) / toward)));
|
|
120
128
|
}
|
|
121
129
|
SwipeUtil.duration = duration;
|
|
122
|
-
/**
|
|
123
|
-
|
|
124
|
-
|
|
130
|
+
/** Whether the page draws the curves of `linear()` (iOS 17.2, Chrome 113 on): a spring then, else CURVE. */
|
|
131
|
+
SwipeUtil.springs = (() => {
|
|
132
|
+
try {
|
|
133
|
+
return typeof CSS !== 'undefined' && CSS.supports('transition-timing-function', 'linear(0, 1)');
|
|
134
|
+
}
|
|
135
|
+
catch (_a) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
})();
|
|
139
|
+
/**
|
|
140
|
+
* How what the finger let go at `from` at `speed` slides on to `to`, never past `bounds`: a spring that starts at
|
|
141
|
+
* the speed of the finger where the page draws it (SwipeSpring), else CURVE for `duration`. `longest` is how long
|
|
142
|
+
* its style slides it.
|
|
143
|
+
*/
|
|
144
|
+
function motion(from, to, speed, longest, bounds = [-Infinity, Infinity]) {
|
|
145
|
+
if (SwipeUtil.springs) {
|
|
146
|
+
return SwipeSpring.motion(from, to, speed, longest, bounds);
|
|
147
|
+
}
|
|
148
|
+
return { ms: Math.abs(to - from) < SwipeSpring.REST_PX ? 0 : duration(to - from, speed, longest), easing: SwipeUtil.CURVE };
|
|
125
149
|
}
|
|
126
|
-
SwipeUtil.
|
|
150
|
+
SwipeUtil.motion = motion;
|
|
127
151
|
})(SwipeUtil || (exports.SwipeUtil = SwipeUtil = {}));
|
|
152
|
+
/**
|
|
153
|
+
* What a finger lets go slides on as on a spring, as the sheets of iOS: at the speed the finger had, slowing
|
|
154
|
+
* down to where it rests, never past it; going the other way, it goes on a little that way first, as far as it
|
|
155
|
+
* may. A sheet let go near where it rests settles there quickly, one let go far away takes its time. Drawn by
|
|
156
|
+
* the compositor as a CSS transition, its curve a `linear()` of the spring's points. Pure, for the tests.
|
|
157
|
+
*/
|
|
158
|
+
var SwipeSpring;
|
|
159
|
+
(function (SwipeSpring) {
|
|
160
|
+
/** How stiff, for what its style slides in `longest` ms: ω = STIFFNESS / longest, 95% of the way in about 0.6 × longest from rest. */
|
|
161
|
+
SwipeSpring.STIFFNESS = 8;
|
|
162
|
+
/** It rests once nearer than this, in pixels. */
|
|
163
|
+
SwipeSpring.REST_PX = 0.5;
|
|
164
|
+
/** A point of its curve this often, in milliseconds. */
|
|
165
|
+
const STEP_MS = 12;
|
|
166
|
+
/** How far it still is from where it rests, of the way, after `t` ms: critically damped, at `speed` (of the way a millisecond) at first. */
|
|
167
|
+
function left(t, omega, speed) {
|
|
168
|
+
return (1 + (omega - speed) * t) * Math.exp(-omega * t);
|
|
169
|
+
}
|
|
170
|
+
SwipeSpring.left = left;
|
|
171
|
+
function motion(from, to, speed, longest, bounds = [-Infinity, Infinity]) {
|
|
172
|
+
const distance = to - from;
|
|
173
|
+
const span = Math.abs(distance);
|
|
174
|
+
if (span < SwipeSpring.REST_PX) {
|
|
175
|
+
return { ms: 0, easing: 'linear' };
|
|
176
|
+
}
|
|
177
|
+
const toward = (Math.sign(distance) * speed) / span;
|
|
178
|
+
// Flicked faster than the spring goes, it is stiffer: it goes on at the finger's speed, and never past where it rests.
|
|
179
|
+
const omega = Math.max(SwipeSpring.STIFFNESS / longest, toward);
|
|
180
|
+
let ms = STEP_MS;
|
|
181
|
+
while (ms < longest * 2 && Math.abs(left(ms, omega, toward)) * span > SwipeSpring.REST_PX) {
|
|
182
|
+
ms += 4;
|
|
183
|
+
}
|
|
184
|
+
// The other way, it goes on only as far as it may.
|
|
185
|
+
const behind = distance > 0 ? from - bounds[0] : bounds[1] - from;
|
|
186
|
+
const lowest = -Math.max(0, behind) / span;
|
|
187
|
+
const count = Math.max(8, Math.ceil(ms / STEP_MS));
|
|
188
|
+
const points = [];
|
|
189
|
+
for (let i = 0; i <= count; i++) {
|
|
190
|
+
const progress = i === count ? 1 : Math.max(lowest, 1 - left((ms * i) / count, omega, toward));
|
|
191
|
+
points.push(String(Math.round(progress * 1000) / 1000));
|
|
192
|
+
}
|
|
193
|
+
return { ms, easing: `linear(${points.join(', ')})` };
|
|
194
|
+
}
|
|
195
|
+
SwipeSpring.motion = motion;
|
|
196
|
+
})(SwipeSpring || (exports.SwipeSpring = SwipeSpring = {}));
|
|
128
197
|
/**
|
|
129
198
|
* The speed of a finger along x, in pixels a millisecond, of its last moves (SwipeUtil.VELOCITY_MS): let go
|
|
130
199
|
* after a slow drag and a flick it is the flick's, held still a moment it is none.
|
|
@@ -153,46 +222,258 @@ class SwipeVelocity {
|
|
|
153
222
|
}
|
|
154
223
|
}
|
|
155
224
|
exports.SwipeVelocity = SwipeVelocity;
|
|
225
|
+
/** The settle that holds an element now: one at a time, so that a finger that takes it stops whatever slid it. */
|
|
226
|
+
const holders = new WeakMap();
|
|
156
227
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
228
|
+
* The elements a finger moves, then lets go (SwipeMotion): while it moves them their styles do not slide
|
|
229
|
+
* them; let go, they slide on to where they rest with transitions of their own, and only once they are there,
|
|
230
|
+
* and the state has them there too (`ready`), they are their styles' again. So the slide starts in the frame
|
|
231
|
+
* the finger lets go, before the page draws what the state changed (which may take a while: a long
|
|
232
|
+
* conversation), and never jumps if it takes longer than the slide. A finger that takes one of them again, or
|
|
233
|
+
* another swipe that moves it, stops it where it is now.
|
|
159
234
|
*/
|
|
160
235
|
class SwipeSettle {
|
|
161
236
|
constructor() {
|
|
162
|
-
this.elements =
|
|
237
|
+
this.elements = new Set();
|
|
163
238
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
239
|
+
/** Whether some of its elements are still its own: moved, or sliding on. */
|
|
240
|
+
get busy() {
|
|
241
|
+
return this.elements.size > 0;
|
|
242
|
+
}
|
|
243
|
+
/** A finger moves these: each stops where it is, whatever slid it, and its style no longer slides it. */
|
|
244
|
+
hold(elements) {
|
|
245
|
+
clearTimeout(this.timer);
|
|
246
|
+
this.done = undefined;
|
|
247
|
+
for (const element of elements) {
|
|
248
|
+
if (element) {
|
|
249
|
+
this.take(element);
|
|
250
|
+
element.style.transition = 'none';
|
|
251
|
+
}
|
|
168
252
|
}
|
|
169
|
-
|
|
170
|
-
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Let go, each slides on to its target as `motion` says; once there and `ready()`, they are their styles'
|
|
256
|
+
* again and `done` runs.
|
|
257
|
+
*/
|
|
258
|
+
run(motion, targets, ready, done) {
|
|
259
|
+
clearTimeout(this.timer);
|
|
260
|
+
const transition = motion.ms > 0 ? `transform ${motion.ms}ms ${motion.easing}, opacity ${motion.ms}ms ${motion.easing}` : 'none';
|
|
261
|
+
for (const { element, transform, opacity } of targets) {
|
|
262
|
+
if (!element) {
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
this.take(element);
|
|
266
|
+
element.style.transition = transition;
|
|
267
|
+
if (transform !== undefined) {
|
|
268
|
+
element.style.transform = transform;
|
|
269
|
+
}
|
|
270
|
+
if (opacity !== undefined) {
|
|
271
|
+
element.style.opacity = String(opacity);
|
|
272
|
+
}
|
|
171
273
|
}
|
|
172
|
-
this.
|
|
274
|
+
this.done = done;
|
|
275
|
+
const until = Date.now() + motion.ms + SwipeSettle.READY_MS;
|
|
276
|
+
const check = () => {
|
|
277
|
+
if (ready() || Date.now() > until) {
|
|
278
|
+
this.finish();
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
this.timer = setTimeout(check, 32);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
this.timer = setTimeout(check, motion.ms + 16);
|
|
173
285
|
}
|
|
174
|
-
|
|
286
|
+
/** They are their styles' again at once, where those say they rest, without sliding there. */
|
|
287
|
+
finish() {
|
|
288
|
+
this.giveBack(false);
|
|
289
|
+
}
|
|
290
|
+
/** They are their styles' again from where they are now: the styles slide them on to where they rest. */
|
|
291
|
+
release() {
|
|
292
|
+
this.giveBack(true);
|
|
293
|
+
}
|
|
294
|
+
giveBack(slide) {
|
|
175
295
|
clearTimeout(this.timer);
|
|
176
|
-
|
|
296
|
+
const elements = [...this.elements];
|
|
297
|
+
this.elements.clear();
|
|
298
|
+
const done = this.done;
|
|
299
|
+
this.done = undefined;
|
|
300
|
+
if (slide) {
|
|
301
|
+
for (const element of elements) {
|
|
302
|
+
this.freeze(element);
|
|
303
|
+
}
|
|
304
|
+
// Where they are now is where the styles slide them from.
|
|
305
|
+
if (elements.length) {
|
|
306
|
+
void getComputedStyle(elements[0]).transform;
|
|
307
|
+
}
|
|
308
|
+
done === null || done === void 0 ? void 0 : done();
|
|
309
|
+
for (const element of elements) {
|
|
310
|
+
SwipeSettle.clean(element, this);
|
|
311
|
+
element.style.removeProperty('transition');
|
|
312
|
+
}
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
for (const element of elements) {
|
|
316
|
+
element.style.transition = 'none';
|
|
317
|
+
SwipeSettle.clean(element, this);
|
|
318
|
+
}
|
|
319
|
+
done === null || done === void 0 ? void 0 : done();
|
|
320
|
+
// Where they rest is drawn with no transition, then theirs are the styles' again.
|
|
321
|
+
if (elements.length) {
|
|
322
|
+
void getComputedStyle(elements[0]).transform;
|
|
323
|
+
}
|
|
324
|
+
for (const element of elements) {
|
|
177
325
|
element.style.removeProperty('transition');
|
|
178
326
|
}
|
|
179
|
-
this.elements = [];
|
|
180
327
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
328
|
+
static clean(element, holder) {
|
|
329
|
+
if (holders.get(element) === holder) {
|
|
330
|
+
holders.delete(element);
|
|
331
|
+
}
|
|
332
|
+
element.style.removeProperty('transform');
|
|
333
|
+
element.style.removeProperty('opacity');
|
|
334
|
+
element.style.removeProperty('visibility');
|
|
335
|
+
}
|
|
336
|
+
/** Takes `element` from the settle that has it, stopped where it is. */
|
|
337
|
+
take(element) {
|
|
338
|
+
const holder = holders.get(element);
|
|
339
|
+
if (holder && holder !== this) {
|
|
340
|
+
holder.elements.delete(element);
|
|
341
|
+
}
|
|
342
|
+
if (holder) {
|
|
343
|
+
this.freeze(element);
|
|
344
|
+
}
|
|
345
|
+
holders.set(element, this);
|
|
346
|
+
this.elements.add(element);
|
|
347
|
+
}
|
|
348
|
+
/** What slides stops where it is now. */
|
|
349
|
+
freeze(element) {
|
|
350
|
+
const transition = element.style.transition;
|
|
351
|
+
if (!transition || transition === 'none') {
|
|
184
352
|
return;
|
|
185
353
|
}
|
|
186
|
-
|
|
187
|
-
|
|
354
|
+
const style = getComputedStyle(element);
|
|
355
|
+
if (element.style.transform) {
|
|
356
|
+
element.style.transform = style.transform;
|
|
188
357
|
}
|
|
189
|
-
|
|
190
|
-
element.style.
|
|
191
|
-
this.elements.push(element);
|
|
358
|
+
if (element.style.opacity) {
|
|
359
|
+
element.style.opacity = style.opacity;
|
|
192
360
|
}
|
|
361
|
+
element.style.transition = 'none';
|
|
193
362
|
}
|
|
194
363
|
}
|
|
195
364
|
exports.SwipeSettle = SwipeSettle;
|
|
365
|
+
/** How long it waits for the state, past the slide, before giving the elements back anyway. */
|
|
366
|
+
SwipeSettle.READY_MS = 1000;
|
|
367
|
+
/**
|
|
368
|
+
* What a swipe let go changes in the state of the page, once the frame it was let go in is drawn and its slide
|
|
369
|
+
* set off (FrameUtil.painted), or after a while where frames are not drawn (a page out of sight); only if it
|
|
370
|
+
* changes something: the workbench is put away by the same call that brings it out.
|
|
371
|
+
*/
|
|
372
|
+
function afterLetGo(open, current) {
|
|
373
|
+
let called = false;
|
|
374
|
+
const call = () => {
|
|
375
|
+
if (!called) {
|
|
376
|
+
called = true;
|
|
377
|
+
if (current().open !== open) {
|
|
378
|
+
current().setOpen(open);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
void frame_1.FrameUtil.painted().then(call);
|
|
383
|
+
setTimeout(call, 100);
|
|
384
|
+
}
|
|
385
|
+
/** Where `element` is moved along `axis` now, by its transform: wherever a style or a slide has it. */
|
|
386
|
+
function translated(element, axis = 'x') {
|
|
387
|
+
const transform = getComputedStyle(element).transform;
|
|
388
|
+
if (!transform || transform === 'none') {
|
|
389
|
+
return 0;
|
|
390
|
+
}
|
|
391
|
+
const matrix = new DOMMatrixReadOnly(transform);
|
|
392
|
+
return axis === 'x' ? matrix.m41 : matrix.m42;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* The one finger a swipe follows, from its touchstart. Its moves and its end are listened to on the element
|
|
396
|
+
* it was put down on, which keeps getting them when it leaves the page (a row or a message drawn again under
|
|
397
|
+
* the finger) while the document no longer does, and on the document too, each event once. Another finger put
|
|
398
|
+
* down or lifted beside it is not its own; its end never seen, the next finger put down ends it.
|
|
399
|
+
*/
|
|
400
|
+
class SwipeFinger {
|
|
401
|
+
/** `blocking`: its moves may be held back (preventDefault), so their listener is not passive. */
|
|
402
|
+
constructor(on, blocking = false) {
|
|
403
|
+
this.on = on;
|
|
404
|
+
this.blocking = blocking;
|
|
405
|
+
this.targets = [];
|
|
406
|
+
this.onMove = (event) => {
|
|
407
|
+
if (event === this.last) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
this.last = event;
|
|
411
|
+
const touch = this.find(event.touches);
|
|
412
|
+
if (touch) {
|
|
413
|
+
this.on.move(event, touch);
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
this.onEnd = (event) => {
|
|
417
|
+
if (event === this.last) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
this.last = event;
|
|
421
|
+
const touch = this.find(event.changedTouches);
|
|
422
|
+
if (touch) {
|
|
423
|
+
this.stop();
|
|
424
|
+
this.on.end(event, touch);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
get down() {
|
|
429
|
+
return this.id !== undefined;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Follows the finger `event` (a touchstart in `doc`) put down, alone on the screen; false while it follows
|
|
433
|
+
* another, which is still down, or when several are.
|
|
434
|
+
*/
|
|
435
|
+
follow(event, doc) {
|
|
436
|
+
if (this.down) {
|
|
437
|
+
if (this.find(event.touches)) {
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
const lost = event;
|
|
441
|
+
this.stop();
|
|
442
|
+
this.on.end(lost, undefined);
|
|
443
|
+
}
|
|
444
|
+
const touch = event.changedTouches[0];
|
|
445
|
+
if (event.touches.length !== 1 || !touch) {
|
|
446
|
+
return false;
|
|
447
|
+
}
|
|
448
|
+
this.id = touch.identifier;
|
|
449
|
+
const target = event.target;
|
|
450
|
+
this.targets = target && target !== doc ? [target, doc] : [doc];
|
|
451
|
+
for (const element of this.targets) {
|
|
452
|
+
element.addEventListener('touchmove', this.onMove, { passive: !this.blocking });
|
|
453
|
+
element.addEventListener('touchend', this.onEnd, { passive: true });
|
|
454
|
+
element.addEventListener('touchcancel', this.onEnd, { passive: true });
|
|
455
|
+
}
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
stop() {
|
|
459
|
+
for (const element of this.targets) {
|
|
460
|
+
element.removeEventListener('touchmove', this.onMove);
|
|
461
|
+
element.removeEventListener('touchend', this.onEnd);
|
|
462
|
+
element.removeEventListener('touchcancel', this.onEnd);
|
|
463
|
+
}
|
|
464
|
+
this.targets = [];
|
|
465
|
+
this.id = undefined;
|
|
466
|
+
}
|
|
467
|
+
find(touches) {
|
|
468
|
+
for (let i = 0; i < touches.length; i++) {
|
|
469
|
+
if (touches[i].identifier === this.id) {
|
|
470
|
+
return touches[i];
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return undefined;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
exports.SwipeFinger = SwipeFinger;
|
|
196
477
|
/** How far what the sheet covers moves, of the width of the sheet (as the styles of the phone, style/phone.ts). */
|
|
197
478
|
const UNDER = 0.3;
|
|
198
479
|
/** How long the styles of the phone slide a sheet (style/phone.ts). */
|
|
@@ -268,8 +549,10 @@ class TouchSources {
|
|
|
268
549
|
* Lets the finger move a sheet while `enabled`, then `setOpen` says where it ended; its style says where it
|
|
269
550
|
* rests. Smooth on a long conversation: each move only sets transforms and an opacity, which the compositor
|
|
270
551
|
* draws, never a style the page inherits; the page keeps scrolling on the compositor too, as the listener that
|
|
271
|
-
* may hold a move back is only there while a touch may be the sheet's.
|
|
272
|
-
*
|
|
552
|
+
* may hold a move back is only there while a touch may be the sheet's. Let go, it slides on at once, as on a
|
|
553
|
+
* spring (SwipeSettle, SwipeSpring), and the state changes in the frames after, so that what the page draws
|
|
554
|
+
* for it never holds the sheet still half way. A sheet still sliding, the finger takes it where it is. A touch
|
|
555
|
+
* in a frame the page may read moves it as well (TouchSources).
|
|
273
556
|
*/
|
|
274
557
|
function useSheetSwipe(options) {
|
|
275
558
|
const latest = React.useRef(options);
|
|
@@ -281,53 +564,63 @@ function useSheetSwipe(options) {
|
|
|
281
564
|
}
|
|
282
565
|
const root = document.documentElement;
|
|
283
566
|
let start;
|
|
567
|
+
let last;
|
|
284
568
|
let claimed;
|
|
285
569
|
let moved;
|
|
286
570
|
let source;
|
|
287
571
|
const velocity = new SwipeVelocity();
|
|
288
572
|
const settle = new SwipeSettle();
|
|
289
|
-
const point = (event, touch
|
|
573
|
+
const point = (event, touch) => {
|
|
290
574
|
var _a;
|
|
291
|
-
var _b, _c
|
|
575
|
+
var _b, _c;
|
|
292
576
|
const box = (_a = source === null || source === void 0 ? void 0 : source.frame) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
293
|
-
return { x:
|
|
577
|
+
return { x: touch.clientX + ((_b = box === null || box === void 0 ? void 0 : box.left) !== null && _b !== void 0 ? _b : 0), y: touch.clientY + ((_c = box === null || box === void 0 ? void 0 : box.top) !== null && _c !== void 0 ? _c : 0), t: event.timeStamp };
|
|
294
578
|
};
|
|
295
579
|
const find = (selector) => (selector ? document.querySelector(selector) : null);
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
580
|
+
/** Where each is with the sheet at `x`. */
|
|
581
|
+
const targets = (elements, x) => {
|
|
582
|
+
const out = 1 - Math.abs(x) / elements.width;
|
|
583
|
+
return [
|
|
584
|
+
{ element: elements.sheet, transform: `translate3d(${x}px, 0, 0)` },
|
|
585
|
+
{ element: elements.under, transform: `translate3d(${SwipeUtil.outward(latest.current) * UNDER * elements.width * out}px, 0, 0)` },
|
|
586
|
+
{ element: elements.scrim, opacity: out },
|
|
587
|
+
];
|
|
303
588
|
};
|
|
304
|
-
const
|
|
305
|
-
source === null || source === void 0 ? void 0 : source.doc.removeEventListener('touchmove', onMove);
|
|
589
|
+
const reset = () => {
|
|
306
590
|
start = undefined;
|
|
591
|
+
last = undefined;
|
|
592
|
+
claimed = undefined;
|
|
593
|
+
moved = undefined;
|
|
307
594
|
source = undefined;
|
|
308
595
|
};
|
|
309
|
-
const onMove = (event) => {
|
|
596
|
+
const onMove = (event, touch) => {
|
|
310
597
|
var _a;
|
|
598
|
+
var _b;
|
|
311
599
|
const current = latest.current;
|
|
312
600
|
if (!start || claimed === false) {
|
|
313
601
|
return;
|
|
314
602
|
}
|
|
315
|
-
const now = point(event);
|
|
603
|
+
const now = point(event, touch);
|
|
316
604
|
if (claimed === undefined) {
|
|
317
605
|
claimed = SwipeUtil.takes(current, start, now, current.open, () => scrollsSideways(event.target));
|
|
318
606
|
if (claimed === undefined) {
|
|
319
607
|
return;
|
|
320
608
|
}
|
|
321
609
|
if (!claimed) {
|
|
322
|
-
stop();
|
|
610
|
+
finger.stop();
|
|
611
|
+
reset();
|
|
323
612
|
return;
|
|
324
613
|
}
|
|
325
|
-
settle.clear();
|
|
326
614
|
const sheet = find(current.sheet);
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
615
|
+
const width = (sheet === null || sheet === void 0 ? void 0 : sheet.getBoundingClientRect().width) || window.innerWidth;
|
|
616
|
+
// From where it is: at rest, or still sliding.
|
|
617
|
+
const from = sheet ? translated(sheet) : current.open ? 0 : SwipeUtil.away(current, width);
|
|
618
|
+
moved = { sheet, under: find(current.under), scrim: find(current.scrim), width, from };
|
|
619
|
+
settle.hold([moved.sheet, moved.under, moved.scrim]);
|
|
620
|
+
root.dataset.sheetDrag = (_b = current.name) !== null && _b !== void 0 ? _b : '';
|
|
621
|
+
// Seen while it moves, and while it slides on, whatever the styles say of where they rest.
|
|
330
622
|
sheet === null || sheet === void 0 ? void 0 : sheet.style.setProperty('visibility', 'visible');
|
|
623
|
+
(_a = moved.under) === null || _a === void 0 ? void 0 : _a.style.setProperty('visibility', 'visible');
|
|
331
624
|
}
|
|
332
625
|
if (!moved) {
|
|
333
626
|
return;
|
|
@@ -335,71 +628,76 @@ function useSheetSwipe(options) {
|
|
|
335
628
|
// The page does not scroll under a sheet being dragged.
|
|
336
629
|
event.preventDefault();
|
|
337
630
|
velocity.add(now);
|
|
338
|
-
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
631
|
+
last = now;
|
|
632
|
+
const x = SwipeUtil.position(current, moved.from, now.x - start.x, moved.width);
|
|
633
|
+
for (const { element, transform, opacity } of targets(moved, x)) {
|
|
634
|
+
if (element && transform) {
|
|
635
|
+
element.style.transform = transform;
|
|
636
|
+
}
|
|
637
|
+
if (element && opacity !== undefined) {
|
|
638
|
+
element.style.opacity = String(opacity);
|
|
639
|
+
}
|
|
345
640
|
}
|
|
346
|
-
|
|
347
|
-
|
|
641
|
+
};
|
|
642
|
+
const onEnd = (event, touch) => {
|
|
643
|
+
var _a;
|
|
644
|
+
if (start && claimed && moved) {
|
|
645
|
+
const current = latest.current;
|
|
646
|
+
const end = touch ? point(event, touch) : (last !== null && last !== void 0 ? last : start);
|
|
647
|
+
if (touch) {
|
|
648
|
+
velocity.add(end);
|
|
649
|
+
}
|
|
650
|
+
const speed = touch ? velocity.speed : 0;
|
|
651
|
+
const x = SwipeUtil.position(current, moved.from, end.x - start.x, moved.width);
|
|
652
|
+
const out = SwipeUtil.settle(current, x, moved.width, speed);
|
|
653
|
+
const away = SwipeUtil.away(current, moved.width);
|
|
654
|
+
const rest = out ? 0 : away;
|
|
655
|
+
const motion = SwipeUtil.motion(x, rest, speed, (_a = current.settleMs) !== null && _a !== void 0 ? _a : SETTLE_MS, [Math.min(0, away), Math.max(0, away)]);
|
|
656
|
+
delete root.dataset.sheetDrag;
|
|
657
|
+
// It slides on now; the state follows once that is drawn, so that what it changes never holds it still.
|
|
658
|
+
settle.run(motion, targets(moved, rest), () => latest.current.open === out);
|
|
659
|
+
afterLetGo(out, () => latest.current);
|
|
348
660
|
}
|
|
661
|
+
reset();
|
|
349
662
|
};
|
|
663
|
+
const finger = new SwipeFinger({ move: onMove, end: onEnd }, true);
|
|
350
664
|
const onStart = (event, from) => {
|
|
351
665
|
var _a;
|
|
352
666
|
const current = latest.current;
|
|
353
|
-
|
|
354
|
-
|
|
667
|
+
// Another finger beside the one that moves it changes nothing; the end of that one never seen, it ends now.
|
|
668
|
+
if (finger.down) {
|
|
669
|
+
if (!finger.follow(event, from.doc)) {
|
|
670
|
+
// A second finger before the swipe was told from a scroll pinches (a picture): it is not the sheet's.
|
|
671
|
+
if (claimed === undefined && event.touches.length > 1) {
|
|
672
|
+
finger.stop();
|
|
673
|
+
reset();
|
|
674
|
+
}
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
finger.stop();
|
|
678
|
+
}
|
|
679
|
+
reset();
|
|
355
680
|
source = from;
|
|
356
|
-
const
|
|
681
|
+
const touch = event.touches[0];
|
|
357
682
|
const target = ((_a = event.target) === null || _a === void 0 ? void 0 : _a.nodeType) === Node.ELEMENT_NODE ? event.target : null;
|
|
358
683
|
const fromEdge = !current.open && !!current.edgeOver && !!(target === null || target === void 0 ? void 0 : target.closest(current.edgeOver));
|
|
359
684
|
const sheet = fromEdge ? { ...current, opensFrom: 'edge' } : current;
|
|
360
|
-
if (event.touches.length
|
|
685
|
+
if (event.touches.length !== 1 || !touch) {
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
const at = point(event, touch);
|
|
689
|
+
if (SwipeUtil.starts(sheet, at, current.open, window.innerWidth) && finger.follow(event, from.doc)) {
|
|
361
690
|
start = at;
|
|
362
691
|
velocity.start(at);
|
|
363
|
-
from.doc.addEventListener('touchmove', onMove, { passive: false });
|
|
364
692
|
}
|
|
365
693
|
else {
|
|
366
|
-
|
|
694
|
+
source = undefined;
|
|
367
695
|
}
|
|
368
696
|
};
|
|
369
|
-
const onEnd = (event) => {
|
|
370
|
-
var _a;
|
|
371
|
-
if (start && claimed && moved) {
|
|
372
|
-
const current = latest.current;
|
|
373
|
-
const end = point(event, event.changedTouches[0]);
|
|
374
|
-
const dx = end.x - start.x;
|
|
375
|
-
velocity.add(end);
|
|
376
|
-
const speed = velocity.speed;
|
|
377
|
-
const out = SwipeUtil.settle(current, dx, moved.width, current.open, speed);
|
|
378
|
-
const x = SwipeUtil.offset(current, dx, moved.width, current.open);
|
|
379
|
-
const rest = out ? 0 : -SwipeUtil.outward(current) * moved.width;
|
|
380
|
-
const ms = SwipeUtil.duration(rest - x, speed, (_a = current.settleMs) !== null && _a !== void 0 ? _a : SETTLE_MS);
|
|
381
|
-
current.setOpen(out);
|
|
382
|
-
// Released in the frame the sheet takes its place, so that it slides on from where the finger left it, at its speed.
|
|
383
|
-
const elements = moved;
|
|
384
|
-
requestAnimationFrame(() => {
|
|
385
|
-
settle.run(ms, [elements.sheet, elements.under], [elements.scrim]);
|
|
386
|
-
release(elements);
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
moved = undefined;
|
|
390
|
-
stop();
|
|
391
|
-
claimed = undefined;
|
|
392
|
-
};
|
|
393
697
|
const sources = new TouchSources(from => {
|
|
394
698
|
const begin = (event) => onStart(event, from);
|
|
395
699
|
from.doc.addEventListener('touchstart', begin, { passive: true });
|
|
396
|
-
from.doc.
|
|
397
|
-
from.doc.addEventListener('touchcancel', onEnd, { passive: true });
|
|
398
|
-
return () => {
|
|
399
|
-
from.doc.removeEventListener('touchstart', begin);
|
|
400
|
-
from.doc.removeEventListener('touchend', onEnd);
|
|
401
|
-
from.doc.removeEventListener('touchcancel', onEnd);
|
|
402
|
-
};
|
|
700
|
+
return () => from.doc.removeEventListener('touchstart', begin);
|
|
403
701
|
});
|
|
404
702
|
const edge = !!latest.current.edgeOver;
|
|
405
703
|
if (edge) {
|
|
@@ -410,9 +708,13 @@ function useSheetSwipe(options) {
|
|
|
410
708
|
delete root.dataset.edgeSwipe;
|
|
411
709
|
}
|
|
412
710
|
sources.dispose();
|
|
413
|
-
stop();
|
|
414
|
-
|
|
415
|
-
|
|
711
|
+
finger.stop();
|
|
712
|
+
// A sheet still under the finger goes back to where it rests; one sliding on finishes its slide.
|
|
713
|
+
if (moved) {
|
|
714
|
+
delete root.dataset.sheetDrag;
|
|
715
|
+
settle.finish();
|
|
716
|
+
}
|
|
717
|
+
reset();
|
|
416
718
|
};
|
|
417
719
|
}, [enabled]);
|
|
418
720
|
}
|