@celljs/ta-web 4.9.0 → 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 +33 -5
- package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
- package/esm/browser/assistant/assistant-task-source.d.ts +2 -0
- package/esm/browser/assistant/assistant-task-source.js +2 -0
- package/esm/browser/assistant/assistant-task-util.d.ts +8 -0
- package/esm/browser/assistant/assistant-task-util.js +13 -3
- package/esm/browser/assistant/assistant-tasks.js +3 -2
- package/esm/browser/assistant/assistant-view.js +81 -56
- package/esm/browser/assistant/assistant.d.ts +30 -1
- package/esm/browser/assistant/assistant.js +89 -6
- package/esm/browser/assistant/task-views.d.ts +40 -6
- package/esm/browser/assistant/task-views.js +73 -21
- package/esm/browser/avatar/dino-avatar.d.ts +3 -4
- package/esm/browser/avatar/dino-avatar.js +4 -178
- package/esm/browser/avatar/dino-face.d.ts +19 -0
- package/esm/browser/avatar/dino-face.js +142 -0
- package/esm/browser/avatar/dino-geometry.d.ts +11 -0
- package/esm/browser/avatar/dino-geometry.js +38 -0
- package/esm/browser/avatar/dino-kinds.d.ts +15 -0
- package/esm/browser/avatar/dino-kinds.js +544 -0
- package/esm/browser/avatar/dino-motion.js +1 -1
- package/esm/browser/avatar/dino-shape.d.ts +80 -0
- package/esm/browser/avatar/dino-shape.js +113 -0
- package/esm/browser/avatar/dino-species.d.ts +1 -61
- package/esm/browser/avatar/dino-species.js +2 -653
- 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/access-view.js +1 -1
- package/esm/browser/components/account-menu.js +1 -1
- 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 +47 -0
- package/esm/browser/components/app-shell-hooks.js +169 -0
- package/esm/browser/components/app-view.js +81 -172
- package/esm/browser/components/auth-view.js +1 -1
- 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 +22 -14
- 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/dino.js +1 -1
- 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 +30 -9
- 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/host-view.js +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/select-bar.d.ts +9 -0
- package/esm/browser/components/select-bar.js +24 -0
- 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-choices.d.ts +35 -0
- package/esm/browser/components/settings-choices.js +117 -0
- package/esm/browser/components/settings-parts.d.ts +21 -0
- package/esm/browser/components/settings-parts.js +323 -0
- package/esm/browser/components/settings-view.d.ts +0 -6
- package/esm/browser/components/settings-view.js +4 -406
- 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/components/workbench-view.js +1 -1
- 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/icons.js +2 -1
- package/esm/browser/extension/web-extension-api.d.ts +135 -2
- 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 +128 -24
- package/esm/browser/extension/web-tasks.d.ts +9 -1
- package/esm/browser/extension/web-tasks.js +24 -0
- 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/hooks.d.ts +3 -1
- package/esm/browser/hooks.js +8 -0
- package/esm/browser/i18n/locales.d.ts +29 -2
- package/esm/browser/i18n/messages.d.ts +28 -1
- package/esm/browser/i18n/messages.js +58 -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 +43 -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 +47 -3
- package/esm/browser/style/tasks.d.ts +1 -1
- package/esm/browser/style/tasks.js +2 -0
- 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 +68 -0
- package/esm/browser/workbench-util.js +145 -0
- package/esm/browser/workbench.d.ts +15 -42
- package/esm/browser/workbench.js +53 -167
- 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 +33 -5
- package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
- package/lib/browser/assistant/assistant-task-source.d.ts +2 -0
- package/lib/browser/assistant/assistant-task-source.js +2 -0
- package/lib/browser/assistant/assistant-task-util.d.ts +8 -0
- package/lib/browser/assistant/assistant-task-util.js +13 -3
- package/lib/browser/assistant/assistant-tasks.js +2 -1
- package/lib/browser/assistant/assistant-view.js +78 -53
- package/lib/browser/assistant/assistant.d.ts +30 -1
- package/lib/browser/assistant/assistant.js +89 -6
- package/lib/browser/assistant/task-views.d.ts +40 -6
- package/lib/browser/assistant/task-views.js +74 -21
- package/lib/browser/avatar/dino-avatar.d.ts +3 -4
- package/lib/browser/avatar/dino-avatar.js +27 -202
- package/lib/browser/avatar/dino-face.d.ts +20 -0
- package/lib/browser/avatar/dino-face.js +148 -0
- package/lib/browser/avatar/dino-geometry.d.ts +12 -0
- package/lib/browser/avatar/dino-geometry.js +47 -0
- package/lib/browser/avatar/dino-kinds.d.ts +16 -0
- package/lib/browser/avatar/dino-kinds.js +547 -0
- package/lib/browser/avatar/dino-motion.js +2 -2
- package/lib/browser/avatar/dino-shape.d.ts +81 -0
- package/lib/browser/avatar/dino-shape.js +126 -0
- package/lib/browser/avatar/dino-species.d.ts +1 -61
- package/lib/browser/avatar/dino-species.js +34 -687
- 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/access-view.js +2 -2
- package/lib/browser/components/account-menu.js +2 -2
- 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 +48 -0
- package/lib/browser/components/app-shell-hooks.js +211 -0
- package/lib/browser/components/app-view.js +89 -180
- package/lib/browser/components/auth-view.js +3 -3
- 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 +22 -14
- 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/dino.js +3 -3
- 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 +30 -9
- 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/host-view.js +5 -5
- 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/select-bar.d.ts +10 -0
- package/lib/browser/components/select-bar.js +61 -0
- 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-choices.d.ts +36 -0
- package/lib/browser/components/settings-choices.js +156 -0
- package/lib/browser/components/settings-parts.d.ts +22 -0
- package/lib/browser/components/settings-parts.js +359 -0
- package/lib/browser/components/settings-view.d.ts +0 -6
- package/lib/browser/components/settings-view.js +2 -405
- 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/components/workbench-view.js +3 -3
- 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/icons.js +1 -0
- package/lib/browser/extension/web-extension-api.d.ts +135 -2
- 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 +125 -21
- package/lib/browser/extension/web-tasks.d.ts +9 -1
- package/lib/browser/extension/web-tasks.js +24 -0
- 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/hooks.d.ts +3 -1
- package/lib/browser/hooks.js +9 -0
- package/lib/browser/i18n/locales.d.ts +29 -2
- package/lib/browser/i18n/messages.d.ts +28 -1
- package/lib/browser/i18n/messages.js +58 -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 +43 -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 +47 -3
- package/lib/browser/style/tasks.d.ts +1 -1
- package/lib/browser/style/tasks.js +2 -0
- 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 +69 -0
- package/lib/browser/workbench-util.js +151 -0
- package/lib/browser/workbench.d.ts +15 -42
- package/lib/browser/workbench.js +74 -189
- package/package.json +10 -10
- package/public/launch.svg +46 -42
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { FrameUtil } from '../util/frame.js';
|
|
2
3
|
import { DeviceMotion } from './device-protocol.js';
|
|
3
4
|
/** It follows the finger and, let go, ends where it was flicked to, or the nearer side. Pure, for the tests. */
|
|
4
5
|
export var SwipeUtil;
|
|
@@ -55,24 +56,29 @@ export var SwipeUtil;
|
|
|
55
56
|
return claimed === undefined ? undefined : claimed && !sideways();
|
|
56
57
|
}
|
|
57
58
|
SwipeUtil.takes = takes;
|
|
58
|
-
/** Where the sheet
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
/** Where the sheet rests away: `∓width`, on its side; out, it rests at 0. */
|
|
60
|
+
function away(sheet, width) {
|
|
61
|
+
return -outward(sheet) * width;
|
|
62
|
+
}
|
|
63
|
+
SwipeUtil.away = away;
|
|
64
|
+
/** Where the sheet is, between 0 (out) and away, when the finger moved `dx` from where it took it (`from`). */
|
|
65
|
+
function position(sheet, from, dx, width) {
|
|
66
|
+
const rest = away(sheet, width);
|
|
67
|
+
return Math.min(Math.max(rest, 0), Math.max(Math.min(rest, 0), from + dx));
|
|
68
|
+
}
|
|
69
|
+
SwipeUtil.position = position;
|
|
70
|
+
/** Whether it ends out, let go at `x` at `speed` (pixels a millisecond, SwipeVelocity): the way it was flicked, or the nearer side. */
|
|
71
|
+
function settle(sheet, x, width, speed) {
|
|
66
72
|
if (Math.abs(speed) > SwipeUtil.FLICK) {
|
|
67
73
|
return speed * outward(sheet) > 0;
|
|
68
74
|
}
|
|
69
|
-
return Math.abs(
|
|
75
|
+
return Math.abs(x) < width / 2;
|
|
70
76
|
}
|
|
71
77
|
SwipeUtil.settle = settle;
|
|
72
78
|
/**
|
|
73
|
-
* How long it slides on to where it rests, `distance` away (signed), let go at `speed
|
|
74
|
-
*
|
|
75
|
-
*
|
|
79
|
+
* How long it slides on to where it rests, `distance` away (signed), let go at `speed`, where the curves of
|
|
80
|
+
* `linear()` are not (SwipeSpring): on CURVE, as fast at first as the finger was; `longest` (the style's)
|
|
81
|
+
* when the finger was slow, or going the other way.
|
|
76
82
|
*/
|
|
77
83
|
function duration(distance, speed, longest) {
|
|
78
84
|
const toward = Math.sign(distance) * speed;
|
|
@@ -82,12 +88,73 @@ export var SwipeUtil;
|
|
|
82
88
|
return Math.round(Math.min(longest, Math.max(SwipeUtil.SHORTEST_MS, (CURVE_START * Math.abs(distance)) / toward)));
|
|
83
89
|
}
|
|
84
90
|
SwipeUtil.duration = duration;
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
/** Whether the page draws the curves of `linear()` (iOS 17.2, Chrome 113 on): a spring then, else CURVE. */
|
|
92
|
+
SwipeUtil.springs = (() => {
|
|
93
|
+
try {
|
|
94
|
+
return typeof CSS !== 'undefined' && CSS.supports('transition-timing-function', 'linear(0, 1)');
|
|
95
|
+
}
|
|
96
|
+
catch (_a) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
})();
|
|
100
|
+
/**
|
|
101
|
+
* How what the finger let go at `from` at `speed` slides on to `to`, never past `bounds`: a spring that starts at
|
|
102
|
+
* the speed of the finger where the page draws it (SwipeSpring), else CURVE for `duration`. `longest` is how long
|
|
103
|
+
* its style slides it.
|
|
104
|
+
*/
|
|
105
|
+
function motion(from, to, speed, longest, bounds = [-Infinity, Infinity]) {
|
|
106
|
+
if (SwipeUtil.springs) {
|
|
107
|
+
return SwipeSpring.motion(from, to, speed, longest, bounds);
|
|
108
|
+
}
|
|
109
|
+
return { ms: Math.abs(to - from) < SwipeSpring.REST_PX ? 0 : duration(to - from, speed, longest), easing: SwipeUtil.CURVE };
|
|
88
110
|
}
|
|
89
|
-
SwipeUtil.
|
|
111
|
+
SwipeUtil.motion = motion;
|
|
90
112
|
})(SwipeUtil || (SwipeUtil = {}));
|
|
113
|
+
/**
|
|
114
|
+
* What a finger lets go slides on as on a spring, as the sheets of iOS: at the speed the finger had, slowing
|
|
115
|
+
* down to where it rests, never past it; going the other way, it goes on a little that way first, as far as it
|
|
116
|
+
* may. A sheet let go near where it rests settles there quickly, one let go far away takes its time. Drawn by
|
|
117
|
+
* the compositor as a CSS transition, its curve a `linear()` of the spring's points. Pure, for the tests.
|
|
118
|
+
*/
|
|
119
|
+
export var SwipeSpring;
|
|
120
|
+
(function (SwipeSpring) {
|
|
121
|
+
/** How stiff, for what its style slides in `longest` ms: ω = STIFFNESS / longest, 95% of the way in about 0.6 × longest from rest. */
|
|
122
|
+
SwipeSpring.STIFFNESS = 8;
|
|
123
|
+
/** It rests once nearer than this, in pixels. */
|
|
124
|
+
SwipeSpring.REST_PX = 0.5;
|
|
125
|
+
/** A point of its curve this often, in milliseconds. */
|
|
126
|
+
const STEP_MS = 12;
|
|
127
|
+
/** 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. */
|
|
128
|
+
function left(t, omega, speed) {
|
|
129
|
+
return (1 + (omega - speed) * t) * Math.exp(-omega * t);
|
|
130
|
+
}
|
|
131
|
+
SwipeSpring.left = left;
|
|
132
|
+
function motion(from, to, speed, longest, bounds = [-Infinity, Infinity]) {
|
|
133
|
+
const distance = to - from;
|
|
134
|
+
const span = Math.abs(distance);
|
|
135
|
+
if (span < SwipeSpring.REST_PX) {
|
|
136
|
+
return { ms: 0, easing: 'linear' };
|
|
137
|
+
}
|
|
138
|
+
const toward = (Math.sign(distance) * speed) / span;
|
|
139
|
+
// Flicked faster than the spring goes, it is stiffer: it goes on at the finger's speed, and never past where it rests.
|
|
140
|
+
const omega = Math.max(SwipeSpring.STIFFNESS / longest, toward);
|
|
141
|
+
let ms = STEP_MS;
|
|
142
|
+
while (ms < longest * 2 && Math.abs(left(ms, omega, toward)) * span > SwipeSpring.REST_PX) {
|
|
143
|
+
ms += 4;
|
|
144
|
+
}
|
|
145
|
+
// The other way, it goes on only as far as it may.
|
|
146
|
+
const behind = distance > 0 ? from - bounds[0] : bounds[1] - from;
|
|
147
|
+
const lowest = -Math.max(0, behind) / span;
|
|
148
|
+
const count = Math.max(8, Math.ceil(ms / STEP_MS));
|
|
149
|
+
const points = [];
|
|
150
|
+
for (let i = 0; i <= count; i++) {
|
|
151
|
+
const progress = i === count ? 1 : Math.max(lowest, 1 - left((ms * i) / count, omega, toward));
|
|
152
|
+
points.push(String(Math.round(progress * 1000) / 1000));
|
|
153
|
+
}
|
|
154
|
+
return { ms, easing: `linear(${points.join(', ')})` };
|
|
155
|
+
}
|
|
156
|
+
SwipeSpring.motion = motion;
|
|
157
|
+
})(SwipeSpring || (SwipeSpring = {}));
|
|
91
158
|
/**
|
|
92
159
|
* The speed of a finger along x, in pixels a millisecond, of its last moves (SwipeUtil.VELOCITY_MS): let go
|
|
93
160
|
* after a slow drag and a flick it is the flick's, held still a moment it is none.
|
|
@@ -115,43 +182,254 @@ export class SwipeVelocity {
|
|
|
115
182
|
return ms > 0 ? (last[this.axis] - first[this.axis]) / ms : 0;
|
|
116
183
|
}
|
|
117
184
|
}
|
|
185
|
+
/** The settle that holds an element now: one at a time, so that a finger that takes it stops whatever slid it. */
|
|
186
|
+
const holders = new WeakMap();
|
|
118
187
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
188
|
+
* The elements a finger moves, then lets go (SwipeMotion): while it moves them their styles do not slide
|
|
189
|
+
* them; let go, they slide on to where they rest with transitions of their own, and only once they are there,
|
|
190
|
+
* and the state has them there too (`ready`), they are their styles' again. So the slide starts in the frame
|
|
191
|
+
* the finger lets go, before the page draws what the state changed (which may take a while: a long
|
|
192
|
+
* conversation), and never jumps if it takes longer than the slide. A finger that takes one of them again, or
|
|
193
|
+
* another swipe that moves it, stops it where it is now.
|
|
121
194
|
*/
|
|
122
195
|
export class SwipeSettle {
|
|
123
196
|
constructor() {
|
|
124
|
-
this.elements =
|
|
197
|
+
this.elements = new Set();
|
|
125
198
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
199
|
+
/** Whether some of its elements are still its own: moved, or sliding on. */
|
|
200
|
+
get busy() {
|
|
201
|
+
return this.elements.size > 0;
|
|
202
|
+
}
|
|
203
|
+
/** A finger moves these: each stops where it is, whatever slid it, and its style no longer slides it. */
|
|
204
|
+
hold(elements) {
|
|
205
|
+
clearTimeout(this.timer);
|
|
206
|
+
this.done = undefined;
|
|
207
|
+
for (const element of elements) {
|
|
208
|
+
if (element) {
|
|
209
|
+
this.take(element);
|
|
210
|
+
element.style.transition = 'none';
|
|
211
|
+
}
|
|
130
212
|
}
|
|
131
|
-
|
|
132
|
-
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Let go, each slides on to its target as `motion` says; once there and `ready()`, they are their styles'
|
|
216
|
+
* again and `done` runs.
|
|
217
|
+
*/
|
|
218
|
+
run(motion, targets, ready, done) {
|
|
219
|
+
clearTimeout(this.timer);
|
|
220
|
+
const transition = motion.ms > 0 ? `transform ${motion.ms}ms ${motion.easing}, opacity ${motion.ms}ms ${motion.easing}` : 'none';
|
|
221
|
+
for (const { element, transform, opacity } of targets) {
|
|
222
|
+
if (!element) {
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
this.take(element);
|
|
226
|
+
element.style.transition = transition;
|
|
227
|
+
if (transform !== undefined) {
|
|
228
|
+
element.style.transform = transform;
|
|
229
|
+
}
|
|
230
|
+
if (opacity !== undefined) {
|
|
231
|
+
element.style.opacity = String(opacity);
|
|
232
|
+
}
|
|
133
233
|
}
|
|
134
|
-
this.
|
|
234
|
+
this.done = done;
|
|
235
|
+
const until = Date.now() + motion.ms + SwipeSettle.READY_MS;
|
|
236
|
+
const check = () => {
|
|
237
|
+
if (ready() || Date.now() > until) {
|
|
238
|
+
this.finish();
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
this.timer = setTimeout(check, 32);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
this.timer = setTimeout(check, motion.ms + 16);
|
|
135
245
|
}
|
|
136
|
-
|
|
246
|
+
/** They are their styles' again at once, where those say they rest, without sliding there. */
|
|
247
|
+
finish() {
|
|
248
|
+
this.giveBack(false);
|
|
249
|
+
}
|
|
250
|
+
/** They are their styles' again from where they are now: the styles slide them on to where they rest. */
|
|
251
|
+
release() {
|
|
252
|
+
this.giveBack(true);
|
|
253
|
+
}
|
|
254
|
+
giveBack(slide) {
|
|
137
255
|
clearTimeout(this.timer);
|
|
138
|
-
|
|
256
|
+
const elements = [...this.elements];
|
|
257
|
+
this.elements.clear();
|
|
258
|
+
const done = this.done;
|
|
259
|
+
this.done = undefined;
|
|
260
|
+
if (slide) {
|
|
261
|
+
for (const element of elements) {
|
|
262
|
+
this.freeze(element);
|
|
263
|
+
}
|
|
264
|
+
// Where they are now is where the styles slide them from.
|
|
265
|
+
if (elements.length) {
|
|
266
|
+
void getComputedStyle(elements[0]).transform;
|
|
267
|
+
}
|
|
268
|
+
done === null || done === void 0 ? void 0 : done();
|
|
269
|
+
for (const element of elements) {
|
|
270
|
+
SwipeSettle.clean(element, this);
|
|
271
|
+
element.style.removeProperty('transition');
|
|
272
|
+
}
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
for (const element of elements) {
|
|
276
|
+
element.style.transition = 'none';
|
|
277
|
+
SwipeSettle.clean(element, this);
|
|
278
|
+
}
|
|
279
|
+
done === null || done === void 0 ? void 0 : done();
|
|
280
|
+
// Where they rest is drawn with no transition, then theirs are the styles' again.
|
|
281
|
+
if (elements.length) {
|
|
282
|
+
void getComputedStyle(elements[0]).transform;
|
|
283
|
+
}
|
|
284
|
+
for (const element of elements) {
|
|
139
285
|
element.style.removeProperty('transition');
|
|
140
286
|
}
|
|
141
|
-
this.elements = [];
|
|
142
287
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
288
|
+
static clean(element, holder) {
|
|
289
|
+
if (holders.get(element) === holder) {
|
|
290
|
+
holders.delete(element);
|
|
291
|
+
}
|
|
292
|
+
element.style.removeProperty('transform');
|
|
293
|
+
element.style.removeProperty('opacity');
|
|
294
|
+
element.style.removeProperty('visibility');
|
|
295
|
+
}
|
|
296
|
+
/** Takes `element` from the settle that has it, stopped where it is. */
|
|
297
|
+
take(element) {
|
|
298
|
+
const holder = holders.get(element);
|
|
299
|
+
if (holder && holder !== this) {
|
|
300
|
+
holder.elements.delete(element);
|
|
301
|
+
}
|
|
302
|
+
if (holder) {
|
|
303
|
+
this.freeze(element);
|
|
304
|
+
}
|
|
305
|
+
holders.set(element, this);
|
|
306
|
+
this.elements.add(element);
|
|
307
|
+
}
|
|
308
|
+
/** What slides stops where it is now. */
|
|
309
|
+
freeze(element) {
|
|
310
|
+
const transition = element.style.transition;
|
|
311
|
+
if (!transition || transition === 'none') {
|
|
146
312
|
return;
|
|
147
313
|
}
|
|
148
|
-
|
|
149
|
-
|
|
314
|
+
const style = getComputedStyle(element);
|
|
315
|
+
if (element.style.transform) {
|
|
316
|
+
element.style.transform = style.transform;
|
|
150
317
|
}
|
|
151
|
-
|
|
152
|
-
element.style.
|
|
153
|
-
|
|
318
|
+
if (element.style.opacity) {
|
|
319
|
+
element.style.opacity = style.opacity;
|
|
320
|
+
}
|
|
321
|
+
element.style.transition = 'none';
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/** How long it waits for the state, past the slide, before giving the elements back anyway. */
|
|
325
|
+
SwipeSettle.READY_MS = 1000;
|
|
326
|
+
/**
|
|
327
|
+
* 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
|
|
328
|
+
* set off (FrameUtil.painted), or after a while where frames are not drawn (a page out of sight); only if it
|
|
329
|
+
* changes something: the workbench is put away by the same call that brings it out.
|
|
330
|
+
*/
|
|
331
|
+
export function afterLetGo(open, current) {
|
|
332
|
+
let called = false;
|
|
333
|
+
const call = () => {
|
|
334
|
+
if (!called) {
|
|
335
|
+
called = true;
|
|
336
|
+
if (current().open !== open) {
|
|
337
|
+
current().setOpen(open);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
void FrameUtil.painted().then(call);
|
|
342
|
+
setTimeout(call, 100);
|
|
343
|
+
}
|
|
344
|
+
/** Where `element` is moved along `axis` now, by its transform: wherever a style or a slide has it. */
|
|
345
|
+
export function translated(element, axis = 'x') {
|
|
346
|
+
const transform = getComputedStyle(element).transform;
|
|
347
|
+
if (!transform || transform === 'none') {
|
|
348
|
+
return 0;
|
|
349
|
+
}
|
|
350
|
+
const matrix = new DOMMatrixReadOnly(transform);
|
|
351
|
+
return axis === 'x' ? matrix.m41 : matrix.m42;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* The one finger a swipe follows, from its touchstart. Its moves and its end are listened to on the element
|
|
355
|
+
* it was put down on, which keeps getting them when it leaves the page (a row or a message drawn again under
|
|
356
|
+
* the finger) while the document no longer does, and on the document too, each event once. Another finger put
|
|
357
|
+
* down or lifted beside it is not its own; its end never seen, the next finger put down ends it.
|
|
358
|
+
*/
|
|
359
|
+
export class SwipeFinger {
|
|
360
|
+
/** `blocking`: its moves may be held back (preventDefault), so their listener is not passive. */
|
|
361
|
+
constructor(on, blocking = false) {
|
|
362
|
+
this.on = on;
|
|
363
|
+
this.blocking = blocking;
|
|
364
|
+
this.targets = [];
|
|
365
|
+
this.onMove = (event) => {
|
|
366
|
+
if (event === this.last) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
this.last = event;
|
|
370
|
+
const touch = this.find(event.touches);
|
|
371
|
+
if (touch) {
|
|
372
|
+
this.on.move(event, touch);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
this.onEnd = (event) => {
|
|
376
|
+
if (event === this.last) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
this.last = event;
|
|
380
|
+
const touch = this.find(event.changedTouches);
|
|
381
|
+
if (touch) {
|
|
382
|
+
this.stop();
|
|
383
|
+
this.on.end(event, touch);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
get down() {
|
|
388
|
+
return this.id !== undefined;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Follows the finger `event` (a touchstart in `doc`) put down, alone on the screen; false while it follows
|
|
392
|
+
* another, which is still down, or when several are.
|
|
393
|
+
*/
|
|
394
|
+
follow(event, doc) {
|
|
395
|
+
if (this.down) {
|
|
396
|
+
if (this.find(event.touches)) {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
const lost = event;
|
|
400
|
+
this.stop();
|
|
401
|
+
this.on.end(lost, undefined);
|
|
154
402
|
}
|
|
403
|
+
const touch = event.changedTouches[0];
|
|
404
|
+
if (event.touches.length !== 1 || !touch) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
this.id = touch.identifier;
|
|
408
|
+
const target = event.target;
|
|
409
|
+
this.targets = target && target !== doc ? [target, doc] : [doc];
|
|
410
|
+
for (const element of this.targets) {
|
|
411
|
+
element.addEventListener('touchmove', this.onMove, { passive: !this.blocking });
|
|
412
|
+
element.addEventListener('touchend', this.onEnd, { passive: true });
|
|
413
|
+
element.addEventListener('touchcancel', this.onEnd, { passive: true });
|
|
414
|
+
}
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
stop() {
|
|
418
|
+
for (const element of this.targets) {
|
|
419
|
+
element.removeEventListener('touchmove', this.onMove);
|
|
420
|
+
element.removeEventListener('touchend', this.onEnd);
|
|
421
|
+
element.removeEventListener('touchcancel', this.onEnd);
|
|
422
|
+
}
|
|
423
|
+
this.targets = [];
|
|
424
|
+
this.id = undefined;
|
|
425
|
+
}
|
|
426
|
+
find(touches) {
|
|
427
|
+
for (let i = 0; i < touches.length; i++) {
|
|
428
|
+
if (touches[i].identifier === this.id) {
|
|
429
|
+
return touches[i];
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return undefined;
|
|
155
433
|
}
|
|
156
434
|
}
|
|
157
435
|
/** How far what the sheet covers moves, of the width of the sheet (as the styles of the phone, style/phone.ts). */
|
|
@@ -229,8 +507,10 @@ class TouchSources {
|
|
|
229
507
|
* Lets the finger move a sheet while `enabled`, then `setOpen` says where it ended; its style says where it
|
|
230
508
|
* rests. Smooth on a long conversation: each move only sets transforms and an opacity, which the compositor
|
|
231
509
|
* draws, never a style the page inherits; the page keeps scrolling on the compositor too, as the listener that
|
|
232
|
-
* may hold a move back is only there while a touch may be the sheet's.
|
|
233
|
-
*
|
|
510
|
+
* 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
|
|
511
|
+
* spring (SwipeSettle, SwipeSpring), and the state changes in the frames after, so that what the page draws
|
|
512
|
+
* for it never holds the sheet still half way. A sheet still sliding, the finger takes it where it is. A touch
|
|
513
|
+
* in a frame the page may read moves it as well (TouchSources).
|
|
234
514
|
*/
|
|
235
515
|
export function useSheetSwipe(options) {
|
|
236
516
|
const latest = React.useRef(options);
|
|
@@ -242,53 +522,63 @@ export function useSheetSwipe(options) {
|
|
|
242
522
|
}
|
|
243
523
|
const root = document.documentElement;
|
|
244
524
|
let start;
|
|
525
|
+
let last;
|
|
245
526
|
let claimed;
|
|
246
527
|
let moved;
|
|
247
528
|
let source;
|
|
248
529
|
const velocity = new SwipeVelocity();
|
|
249
530
|
const settle = new SwipeSettle();
|
|
250
|
-
const point = (event, touch
|
|
531
|
+
const point = (event, touch) => {
|
|
251
532
|
var _a;
|
|
252
|
-
var _b, _c
|
|
533
|
+
var _b, _c;
|
|
253
534
|
const box = (_a = source === null || source === void 0 ? void 0 : source.frame) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
254
|
-
return { x:
|
|
535
|
+
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 };
|
|
255
536
|
};
|
|
256
537
|
const find = (selector) => (selector ? document.querySelector(selector) : null);
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
538
|
+
/** Where each is with the sheet at `x`. */
|
|
539
|
+
const targets = (elements, x) => {
|
|
540
|
+
const out = 1 - Math.abs(x) / elements.width;
|
|
541
|
+
return [
|
|
542
|
+
{ element: elements.sheet, transform: `translate3d(${x}px, 0, 0)` },
|
|
543
|
+
{ element: elements.under, transform: `translate3d(${SwipeUtil.outward(latest.current) * UNDER * elements.width * out}px, 0, 0)` },
|
|
544
|
+
{ element: elements.scrim, opacity: out },
|
|
545
|
+
];
|
|
264
546
|
};
|
|
265
|
-
const
|
|
266
|
-
source === null || source === void 0 ? void 0 : source.doc.removeEventListener('touchmove', onMove);
|
|
547
|
+
const reset = () => {
|
|
267
548
|
start = undefined;
|
|
549
|
+
last = undefined;
|
|
550
|
+
claimed = undefined;
|
|
551
|
+
moved = undefined;
|
|
268
552
|
source = undefined;
|
|
269
553
|
};
|
|
270
|
-
const onMove = (event) => {
|
|
554
|
+
const onMove = (event, touch) => {
|
|
271
555
|
var _a;
|
|
556
|
+
var _b;
|
|
272
557
|
const current = latest.current;
|
|
273
558
|
if (!start || claimed === false) {
|
|
274
559
|
return;
|
|
275
560
|
}
|
|
276
|
-
const now = point(event);
|
|
561
|
+
const now = point(event, touch);
|
|
277
562
|
if (claimed === undefined) {
|
|
278
563
|
claimed = SwipeUtil.takes(current, start, now, current.open, () => scrollsSideways(event.target));
|
|
279
564
|
if (claimed === undefined) {
|
|
280
565
|
return;
|
|
281
566
|
}
|
|
282
567
|
if (!claimed) {
|
|
283
|
-
stop();
|
|
568
|
+
finger.stop();
|
|
569
|
+
reset();
|
|
284
570
|
return;
|
|
285
571
|
}
|
|
286
|
-
settle.clear();
|
|
287
572
|
const sheet = find(current.sheet);
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
573
|
+
const width = (sheet === null || sheet === void 0 ? void 0 : sheet.getBoundingClientRect().width) || window.innerWidth;
|
|
574
|
+
// From where it is: at rest, or still sliding.
|
|
575
|
+
const from = sheet ? translated(sheet) : current.open ? 0 : SwipeUtil.away(current, width);
|
|
576
|
+
moved = { sheet, under: find(current.under), scrim: find(current.scrim), width, from };
|
|
577
|
+
settle.hold([moved.sheet, moved.under, moved.scrim]);
|
|
578
|
+
root.dataset.sheetDrag = (_b = current.name) !== null && _b !== void 0 ? _b : '';
|
|
579
|
+
// Seen while it moves, and while it slides on, whatever the styles say of where they rest.
|
|
291
580
|
sheet === null || sheet === void 0 ? void 0 : sheet.style.setProperty('visibility', 'visible');
|
|
581
|
+
(_a = moved.under) === null || _a === void 0 ? void 0 : _a.style.setProperty('visibility', 'visible');
|
|
292
582
|
}
|
|
293
583
|
if (!moved) {
|
|
294
584
|
return;
|
|
@@ -296,71 +586,76 @@ export function useSheetSwipe(options) {
|
|
|
296
586
|
// The page does not scroll under a sheet being dragged.
|
|
297
587
|
event.preventDefault();
|
|
298
588
|
velocity.add(now);
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
589
|
+
last = now;
|
|
590
|
+
const x = SwipeUtil.position(current, moved.from, now.x - start.x, moved.width);
|
|
591
|
+
for (const { element, transform, opacity } of targets(moved, x)) {
|
|
592
|
+
if (element && transform) {
|
|
593
|
+
element.style.transform = transform;
|
|
594
|
+
}
|
|
595
|
+
if (element && opacity !== undefined) {
|
|
596
|
+
element.style.opacity = String(opacity);
|
|
597
|
+
}
|
|
306
598
|
}
|
|
307
|
-
|
|
308
|
-
|
|
599
|
+
};
|
|
600
|
+
const onEnd = (event, touch) => {
|
|
601
|
+
var _a;
|
|
602
|
+
if (start && claimed && moved) {
|
|
603
|
+
const current = latest.current;
|
|
604
|
+
const end = touch ? point(event, touch) : (last !== null && last !== void 0 ? last : start);
|
|
605
|
+
if (touch) {
|
|
606
|
+
velocity.add(end);
|
|
607
|
+
}
|
|
608
|
+
const speed = touch ? velocity.speed : 0;
|
|
609
|
+
const x = SwipeUtil.position(current, moved.from, end.x - start.x, moved.width);
|
|
610
|
+
const out = SwipeUtil.settle(current, x, moved.width, speed);
|
|
611
|
+
const away = SwipeUtil.away(current, moved.width);
|
|
612
|
+
const rest = out ? 0 : away;
|
|
613
|
+
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)]);
|
|
614
|
+
delete root.dataset.sheetDrag;
|
|
615
|
+
// It slides on now; the state follows once that is drawn, so that what it changes never holds it still.
|
|
616
|
+
settle.run(motion, targets(moved, rest), () => latest.current.open === out);
|
|
617
|
+
afterLetGo(out, () => latest.current);
|
|
309
618
|
}
|
|
619
|
+
reset();
|
|
310
620
|
};
|
|
621
|
+
const finger = new SwipeFinger({ move: onMove, end: onEnd }, true);
|
|
311
622
|
const onStart = (event, from) => {
|
|
312
623
|
var _a;
|
|
313
624
|
const current = latest.current;
|
|
314
|
-
|
|
315
|
-
|
|
625
|
+
// Another finger beside the one that moves it changes nothing; the end of that one never seen, it ends now.
|
|
626
|
+
if (finger.down) {
|
|
627
|
+
if (!finger.follow(event, from.doc)) {
|
|
628
|
+
// A second finger before the swipe was told from a scroll pinches (a picture): it is not the sheet's.
|
|
629
|
+
if (claimed === undefined && event.touches.length > 1) {
|
|
630
|
+
finger.stop();
|
|
631
|
+
reset();
|
|
632
|
+
}
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
finger.stop();
|
|
636
|
+
}
|
|
637
|
+
reset();
|
|
316
638
|
source = from;
|
|
317
|
-
const
|
|
639
|
+
const touch = event.touches[0];
|
|
318
640
|
const target = ((_a = event.target) === null || _a === void 0 ? void 0 : _a.nodeType) === Node.ELEMENT_NODE ? event.target : null;
|
|
319
641
|
const fromEdge = !current.open && !!current.edgeOver && !!(target === null || target === void 0 ? void 0 : target.closest(current.edgeOver));
|
|
320
642
|
const sheet = fromEdge ? { ...current, opensFrom: 'edge' } : current;
|
|
321
|
-
if (event.touches.length
|
|
643
|
+
if (event.touches.length !== 1 || !touch) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
const at = point(event, touch);
|
|
647
|
+
if (SwipeUtil.starts(sheet, at, current.open, window.innerWidth) && finger.follow(event, from.doc)) {
|
|
322
648
|
start = at;
|
|
323
649
|
velocity.start(at);
|
|
324
|
-
from.doc.addEventListener('touchmove', onMove, { passive: false });
|
|
325
650
|
}
|
|
326
651
|
else {
|
|
327
|
-
|
|
652
|
+
source = undefined;
|
|
328
653
|
}
|
|
329
654
|
};
|
|
330
|
-
const onEnd = (event) => {
|
|
331
|
-
var _a;
|
|
332
|
-
if (start && claimed && moved) {
|
|
333
|
-
const current = latest.current;
|
|
334
|
-
const end = point(event, event.changedTouches[0]);
|
|
335
|
-
const dx = end.x - start.x;
|
|
336
|
-
velocity.add(end);
|
|
337
|
-
const speed = velocity.speed;
|
|
338
|
-
const out = SwipeUtil.settle(current, dx, moved.width, current.open, speed);
|
|
339
|
-
const x = SwipeUtil.offset(current, dx, moved.width, current.open);
|
|
340
|
-
const rest = out ? 0 : -SwipeUtil.outward(current) * moved.width;
|
|
341
|
-
const ms = SwipeUtil.duration(rest - x, speed, (_a = current.settleMs) !== null && _a !== void 0 ? _a : SETTLE_MS);
|
|
342
|
-
current.setOpen(out);
|
|
343
|
-
// Released in the frame the sheet takes its place, so that it slides on from where the finger left it, at its speed.
|
|
344
|
-
const elements = moved;
|
|
345
|
-
requestAnimationFrame(() => {
|
|
346
|
-
settle.run(ms, [elements.sheet, elements.under], [elements.scrim]);
|
|
347
|
-
release(elements);
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
moved = undefined;
|
|
351
|
-
stop();
|
|
352
|
-
claimed = undefined;
|
|
353
|
-
};
|
|
354
655
|
const sources = new TouchSources(from => {
|
|
355
656
|
const begin = (event) => onStart(event, from);
|
|
356
657
|
from.doc.addEventListener('touchstart', begin, { passive: true });
|
|
357
|
-
from.doc.
|
|
358
|
-
from.doc.addEventListener('touchcancel', onEnd, { passive: true });
|
|
359
|
-
return () => {
|
|
360
|
-
from.doc.removeEventListener('touchstart', begin);
|
|
361
|
-
from.doc.removeEventListener('touchend', onEnd);
|
|
362
|
-
from.doc.removeEventListener('touchcancel', onEnd);
|
|
363
|
-
};
|
|
658
|
+
return () => from.doc.removeEventListener('touchstart', begin);
|
|
364
659
|
});
|
|
365
660
|
const edge = !!latest.current.edgeOver;
|
|
366
661
|
if (edge) {
|
|
@@ -371,9 +666,13 @@ export function useSheetSwipe(options) {
|
|
|
371
666
|
delete root.dataset.edgeSwipe;
|
|
372
667
|
}
|
|
373
668
|
sources.dispose();
|
|
374
|
-
stop();
|
|
375
|
-
|
|
376
|
-
|
|
669
|
+
finger.stop();
|
|
670
|
+
// A sheet still under the finger goes back to where it rests; one sliding on finishes its slide.
|
|
671
|
+
if (moved) {
|
|
672
|
+
delete root.dataset.sheetDrag;
|
|
673
|
+
settle.finish();
|
|
674
|
+
}
|
|
675
|
+
reset();
|
|
377
676
|
};
|
|
378
677
|
}, [enabled]);
|
|
379
678
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlarmClock, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, BellOff, Bot, Building2, CaseSensitive, Check, ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown, CircleAlert, Clipboard, Clock, Code, Columns2, Copy, CopyMinus, CornerUpLeft, Crown, Download, Ellipsis, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, Folder, FolderInput, FolderOpen, FolderPlus, FolderSearch, FolderTree, GitBranch, GitCommitHorizontal, Globe, Grip, Hash, House, Image, LayoutDashboard, Link, List, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minus, MousePointerClick, PackageOpen, Paperclip, Pencil, Pin, PinOff, Play, Plus, Power, Puzzle, QrCode, RefreshCw, Regex, Replace, ReplaceAll, RotateCcw, Rows2, Save, ScanLine, ScrollText, Search, Server, Share2, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, Text, Trash2, Undo2, Unplug, Upload, User, UserPlus, Users, WholeWord, X, } from 'lucide-react';
|
|
1
|
+
import { AlarmClock, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, BellOff, Bot, Building2, CaseSensitive, Check, ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown, CircleAlert, Clipboard, Clock, Code, Columns2, Copy, CopyMinus, CornerUpLeft, Crown, Download, Ellipsis, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, Folder, FolderInput, FolderOpen, FolderPlus, FolderSearch, FolderTree, GitBranch, GitCommitHorizontal, Globe, Grip, Hash, House, Image, LayoutDashboard, Link, List, ListChecks, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minus, MousePointerClick, PackageOpen, Paperclip, Pencil, Pin, PinOff, Play, Plus, Power, Puzzle, QrCode, RefreshCw, Regex, Replace, ReplaceAll, RotateCcw, Rows2, Save, ScanLine, ScrollText, Search, Server, Share2, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, Text, Trash2, Undo2, Unplug, Upload, User, UserPlus, Users, WholeWord, X, } from 'lucide-react';
|
|
2
2
|
/** The icons a web extension gets as `pi.ui.icons`; names are lucide's. Only add: removing one breaks extensions. */
|
|
3
3
|
export const WEB_ICONS = Object.freeze({
|
|
4
4
|
AlarmClock,
|
|
@@ -52,6 +52,7 @@ export const WEB_ICONS = Object.freeze({
|
|
|
52
52
|
LayoutDashboard,
|
|
53
53
|
Link,
|
|
54
54
|
List,
|
|
55
|
+
ListChecks,
|
|
55
56
|
ListTodo,
|
|
56
57
|
ListTree,
|
|
57
58
|
ListX,
|