@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,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { nativePlugin } from './device.js';
|
|
3
|
-
import { SwipeSettle, SwipeUtil, SwipeVelocity } from './sheet-swipe.js';
|
|
3
|
+
import { afterLetGo, SwipeFinger, SwipeSettle, SwipeUtil, SwipeVelocity } from './sheet-swipe.js';
|
|
4
4
|
/**
|
|
5
5
|
* What a finger pulls down from the top of a list, as the launcher of WeChat over its chats (ta-launcher.md):
|
|
6
6
|
* the list follows the finger, the launcher shows behind it, and let go far or fast enough the list goes down
|
|
@@ -84,8 +84,10 @@ function tick() {
|
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Lets a finger pull the launcher down over the first tab while `enabled`. As useSheetSwipe: transforms and
|
|
87
|
-
* opacities only,
|
|
88
|
-
*
|
|
87
|
+
* opacities only, the listener that may hold a move back there only for a touch that may be a pull, the finger
|
|
88
|
+
* followed on what it touched (SwipeFinger), and let go it slides on at once as on a spring (SwipeSettle), the
|
|
89
|
+
* state following. A pull down is decided on the first move (iOS lets a scroll that started go on), only at
|
|
90
|
+
* the top of the list.
|
|
89
91
|
*/
|
|
90
92
|
export function usePullDown(options) {
|
|
91
93
|
const latest = React.useRef(options);
|
|
@@ -103,51 +105,18 @@ export function usePullDown(options) {
|
|
|
103
105
|
const settle = new SwipeSettle();
|
|
104
106
|
// The strip that shows while open, with the safe area under it, as the style sizes it.
|
|
105
107
|
const peekOf = () => { var _a; return ((_a = document.querySelector(latest.current.peek)) === null || _a === void 0 ? void 0 : _a.offsetHeight) || PullUtil.PEEK_PX; };
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
const p = PullUtil.progress(offset, moved.height, moved.peek);
|
|
111
|
-
moved.sheet.style.transform = `translate3d(0, ${offset}px, 0)`;
|
|
112
|
-
if (moved.reveal) {
|
|
113
|
-
moved.reveal.style.opacity = String(p);
|
|
114
|
-
moved.reveal.style.transform = `translate3d(0, ${(p - 1) * 36}px, 0) scale(${0.94 + 0.06 * p})`;
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
const release = (elements) => {
|
|
118
|
-
var _a, _b;
|
|
119
|
-
delete root.dataset.pull;
|
|
120
|
-
elements === null || elements === void 0 ? void 0 : elements.sheet.style.removeProperty('transform');
|
|
121
|
-
(_a = elements === null || elements === void 0 ? void 0 : elements.reveal) === null || _a === void 0 ? void 0 : _a.style.removeProperty('transform');
|
|
122
|
-
(_b = elements === null || elements === void 0 ? void 0 : elements.reveal) === null || _b === void 0 ? void 0 : _b.style.removeProperty('opacity');
|
|
108
|
+
const reveal = (offset, height, peek) => {
|
|
109
|
+
const p = PullUtil.progress(offset, height, peek);
|
|
110
|
+
return { opacity: p, transform: `translate3d(0, ${(p - 1) * 36}px, 0) scale(${0.94 + 0.06 * p})` };
|
|
123
111
|
};
|
|
124
|
-
const
|
|
125
|
-
document.removeEventListener('touchmove', onMove);
|
|
112
|
+
const reset = () => {
|
|
126
113
|
start = undefined;
|
|
127
|
-
};
|
|
128
|
-
const onStart = (event) => {
|
|
129
|
-
const current = latest.current;
|
|
130
114
|
claimed = undefined;
|
|
131
|
-
|
|
132
|
-
const target = event.target instanceof Node ? event.target : null;
|
|
133
|
-
const area = target
|
|
134
|
-
? [...document.querySelectorAll(current.open ? current.closeArea : current.area)].find(element => element.contains(target))
|
|
135
|
-
: undefined;
|
|
136
|
-
const inside = !!area;
|
|
137
|
-
const free = inside && !editable(event.target) && (current.open ? atEnd(event.target, area) : atTop(event.target, area));
|
|
138
|
-
if (event.touches.length === 1 && touch && free) {
|
|
139
|
-
start = { x: touch.clientX, y: touch.clientY, t: event.timeStamp };
|
|
140
|
-
velocity.start(start);
|
|
141
|
-
document.addEventListener('touchmove', onMove, { passive: false });
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
stop();
|
|
145
|
-
}
|
|
115
|
+
moved = undefined;
|
|
146
116
|
};
|
|
147
|
-
const onMove = (event) => {
|
|
117
|
+
const onMove = (event, touch) => {
|
|
148
118
|
const current = latest.current;
|
|
149
|
-
|
|
150
|
-
if (!start || !touch || claimed === false) {
|
|
119
|
+
if (!start || claimed === false) {
|
|
151
120
|
return;
|
|
152
121
|
}
|
|
153
122
|
const dy = touch.clientY - start.y;
|
|
@@ -160,17 +129,12 @@ export function usePullDown(options) {
|
|
|
160
129
|
}
|
|
161
130
|
return;
|
|
162
131
|
}
|
|
163
|
-
|
|
164
|
-
stop();
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
const sheet = document.querySelector(current.sheet);
|
|
132
|
+
const sheet = claimed ? document.querySelector(current.sheet) : null;
|
|
168
133
|
if (!sheet) {
|
|
169
134
|
claimed = false;
|
|
170
|
-
stop();
|
|
135
|
+
finger.stop();
|
|
171
136
|
return;
|
|
172
137
|
}
|
|
173
|
-
settle.clear();
|
|
174
138
|
moved = {
|
|
175
139
|
sheet,
|
|
176
140
|
reveal: document.querySelector(current.reveal),
|
|
@@ -179,6 +143,7 @@ export function usePullDown(options) {
|
|
|
179
143
|
passed: current.open,
|
|
180
144
|
offset: 0,
|
|
181
145
|
};
|
|
146
|
+
settle.hold([moved.sheet, moved.reveal]);
|
|
182
147
|
// Not data-sheet-drag: the sheets off the screen (the screen, the board) stay hidden.
|
|
183
148
|
root.dataset.pull = '';
|
|
184
149
|
}
|
|
@@ -193,39 +158,62 @@ export function usePullDown(options) {
|
|
|
193
158
|
tick();
|
|
194
159
|
}
|
|
195
160
|
moved.passed = passed || current.open;
|
|
196
|
-
|
|
161
|
+
moved.sheet.style.transform = `translate3d(0, ${moved.offset}px, 0)`;
|
|
162
|
+
if (moved.reveal) {
|
|
163
|
+
const { opacity, transform } = reveal(moved.offset, moved.height, moved.peek);
|
|
164
|
+
moved.reveal.style.opacity = String(opacity);
|
|
165
|
+
moved.reveal.style.transform = transform;
|
|
166
|
+
}
|
|
197
167
|
};
|
|
198
|
-
const onEnd = (event) => {
|
|
199
|
-
var _a, _b;
|
|
200
|
-
const current = latest.current;
|
|
168
|
+
const onEnd = (event, touch) => {
|
|
201
169
|
if (start && claimed && moved) {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
const
|
|
208
|
-
current.
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
170
|
+
const current = latest.current;
|
|
171
|
+
if (touch) {
|
|
172
|
+
velocity.add({ x: touch.clientX, y: touch.clientY, t: event.timeStamp });
|
|
173
|
+
}
|
|
174
|
+
const speed = touch ? velocity.speed : 0;
|
|
175
|
+
const { sheet, height, peek, offset } = moved;
|
|
176
|
+
const open = PullUtil.settle(offset, height, current.open, speed, peek);
|
|
177
|
+
const rest = open ? height - peek : 0;
|
|
178
|
+
const motion = SwipeUtil.motion(offset, rest, speed, PullUtil.SETTLE_MS, [0, height - peek]);
|
|
179
|
+
settle.run(motion, [
|
|
180
|
+
{ element: sheet, transform: `translate3d(0, ${rest}px, 0)` },
|
|
181
|
+
{ element: moved.reveal, ...reveal(rest, height, peek) },
|
|
182
|
+
], () => latest.current.open === open, () => delete root.dataset.pull);
|
|
183
|
+
afterLetGo(open, () => latest.current);
|
|
184
|
+
}
|
|
185
|
+
reset();
|
|
186
|
+
};
|
|
187
|
+
const finger = new SwipeFinger({ move: onMove, end: onEnd }, true);
|
|
188
|
+
const onStart = (event) => {
|
|
189
|
+
const current = latest.current;
|
|
190
|
+
// Another finger beside the one that pulls changes nothing.
|
|
191
|
+
if (finger.down && !finger.follow(event, document)) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
finger.stop();
|
|
195
|
+
reset();
|
|
196
|
+
const touch = event.touches[0];
|
|
197
|
+
const target = event.target instanceof Node ? event.target : null;
|
|
198
|
+
const area = target
|
|
199
|
+
? [...document.querySelectorAll(current.open ? current.closeArea : current.area)].find(element => element.contains(target))
|
|
200
|
+
: undefined;
|
|
201
|
+
const free = !!area && !editable(event.target) && (current.open ? atEnd(event.target, area) : atTop(event.target, area));
|
|
202
|
+
if (touch && free && finger.follow(event, document)) {
|
|
203
|
+
start = { x: touch.clientX, y: touch.clientY, t: event.timeStamp };
|
|
204
|
+
velocity.start(start);
|
|
214
205
|
}
|
|
215
|
-
moved = undefined;
|
|
216
|
-
claimed = undefined;
|
|
217
|
-
stop();
|
|
218
206
|
};
|
|
219
207
|
document.addEventListener('touchstart', onStart, { passive: true });
|
|
220
|
-
document.addEventListener('touchend', onEnd, { passive: true });
|
|
221
|
-
document.addEventListener('touchcancel', onEnd, { passive: true });
|
|
222
208
|
return () => {
|
|
223
209
|
document.removeEventListener('touchstart', onStart);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
210
|
+
finger.stop();
|
|
211
|
+
// A list still under the finger goes back to where it rests; one sliding on finishes its slide.
|
|
212
|
+
if (moved) {
|
|
213
|
+
delete root.dataset.pull;
|
|
214
|
+
settle.finish();
|
|
215
|
+
}
|
|
216
|
+
reset();
|
|
229
217
|
};
|
|
230
218
|
}, [enabled]);
|
|
231
219
|
}
|
|
@@ -5,22 +5,47 @@ import * as React from 'react';
|
|
|
5
5
|
* anywhere else, or another row opened. Pure, for the tests.
|
|
6
6
|
*/
|
|
7
7
|
export declare namespace RowSwipeUtil {
|
|
8
|
-
/** Past the actions, the row follows the finger this much, as a list pulled past its end. */
|
|
9
|
-
const
|
|
8
|
+
/** Past the actions, the row follows the finger this much at first, then less and less, as a list of iOS pulled past its end. */
|
|
9
|
+
const RUBBER = 0.55;
|
|
10
10
|
/** How long its style slides the row (style/device.ts). */
|
|
11
11
|
const SETTLE_MS = 300;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
|
|
12
|
+
/** How far past its actions it ever goes, however far the finger: less than what the actions fill past their edge (style/device.ts). */
|
|
13
|
+
const BEYOND_PX = 100;
|
|
14
|
+
/** Told a swipe, the row catches up with the finger over this much of its way, not at once. */
|
|
15
|
+
const CATCH_PX = 40;
|
|
16
|
+
/** Let go, where it is headed is where it would be this much later at the finger's speed: a short quick swipe opens it too. */
|
|
17
|
+
const PROJECT_MS = 150;
|
|
18
|
+
/** Where the row is, from 0 (closed) to `-width` (its actions shown) and a little past, the finger at `x` (where it took the row, and how far it moved since). */
|
|
19
|
+
function offset(x: number, width: number): number;
|
|
20
|
+
/** Where the finger would be for the row at `offset`: the other way from `offset`, so that a row taken past its actions does not jump. */
|
|
21
|
+
function finger(offset: number, width: number): number;
|
|
22
|
+
/** Whether it stays open, let go at `offset` at `speed` (pixels a millisecond, SwipeVelocity): flicked, the way it was; else where it is headed. */
|
|
23
|
+
function settle(offset: number, width: number, speed: number): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* How far the finger has moved the row, `dx` since the move was told a swipe, `lag` before (the few pixels
|
|
26
|
+
* that told it): from where it was, without a jump, a little faster than the finger until it is where the
|
|
27
|
+
* finger says (CATCH_PX), as if it had followed it from the start.
|
|
28
|
+
*/
|
|
29
|
+
function follow(dx: number, lag: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* How far each action is pushed to the right of where it rests, the row at `offset`: they come out with the
|
|
32
|
+
* row's edge, as iOS's, the first one at it, the others spread over what is shown (`share`, 1 - its index
|
|
33
|
+
* of how many there are: 1 for the first, less for those after).
|
|
34
|
+
*/
|
|
35
|
+
function shift(offset: number, width: number, share: number): number;
|
|
16
36
|
/** Whether the move so far is the row's (more sideways than down, to the left unless open); undefined until it is told. */
|
|
17
37
|
function claims(dx: number, dy: number, open: boolean): boolean | undefined;
|
|
18
38
|
}
|
|
19
39
|
/**
|
|
20
40
|
* Lets a finger swipe the row of `ref` (a SwipeRow) while `enabled`: its content moves over its actions, whose
|
|
21
|
-
* width is the way to go, and
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
41
|
+
* width is the way to go, and they come out with its edge (RowSwipeUtil.shift); let go, all slide on as on a
|
|
42
|
+
* spring from the speed the finger left them (SwipeSettle). The row sets off from where the move is told a swipe
|
|
43
|
+
* and catches up with the finger (RowSwipeUtil.follow), so it never jumps under it; past its actions it stretches less and
|
|
44
|
+
* less. Open, it closes when the finger scrolls the list from it, or holds it for its menu. Its
|
|
45
|
+
* listeners are passive (the row has `touch-action: pan-y`), so the list scrolls on the compositor; each move
|
|
46
|
+
* only sets a transform. The finger is followed on what it touched (SwipeFinger), so that a row drawn again
|
|
47
|
+
* under it does not stop half way. The style says where an open row rests (`data-swiped`); the row clips
|
|
48
|
+
* what slides out of it only while it is moved, open or on its way back (`data-swipe-clip`), so that a menu
|
|
49
|
+
* of the row is not cut at its edges.
|
|
25
50
|
*/
|
|
26
51
|
export declare function useRowSwipe(ref: React.RefObject<HTMLElement | null>, enabled: boolean): [boolean, () => void];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { SwipeSettle, SwipeUtil, SwipeVelocity } from './sheet-swipe.js';
|
|
2
|
+
import { SwipeFinger, SwipeSettle, SwipeUtil, SwipeVelocity, translated } from './sheet-swipe.js';
|
|
3
3
|
/**
|
|
4
4
|
* A row of a list a finger swipes to the left to show its actions behind it, as the chats of WeChat: it
|
|
5
5
|
* follows the finger, stays open past half of them or flicked, and closes on a swipe back, a tap on it or
|
|
@@ -7,27 +7,64 @@ import { SwipeSettle, SwipeUtil, SwipeVelocity } from './sheet-swipe.js';
|
|
|
7
7
|
*/
|
|
8
8
|
export var RowSwipeUtil;
|
|
9
9
|
(function (RowSwipeUtil) {
|
|
10
|
-
/** Past the actions, the row follows the finger this much, as a list pulled past its end. */
|
|
11
|
-
RowSwipeUtil.
|
|
10
|
+
/** Past the actions, the row follows the finger this much at first, then less and less, as a list of iOS pulled past its end. */
|
|
11
|
+
RowSwipeUtil.RUBBER = 0.55;
|
|
12
12
|
/** How long its style slides the row (style/device.ts). */
|
|
13
13
|
RowSwipeUtil.SETTLE_MS = 300;
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
/** How far past its actions it ever goes, however far the finger: less than what the actions fill past their edge (style/device.ts). */
|
|
15
|
+
RowSwipeUtil.BEYOND_PX = 100;
|
|
16
|
+
/** Told a swipe, the row catches up with the finger over this much of its way, not at once. */
|
|
17
|
+
RowSwipeUtil.CATCH_PX = 40;
|
|
18
|
+
/** Let go, where it is headed is where it would be this much later at the finger's speed: a short quick swipe opens it too. */
|
|
19
|
+
RowSwipeUtil.PROJECT_MS = 150;
|
|
20
|
+
/** Where the row is, from 0 (closed) to `-width` (its actions shown) and a little past, the finger at `x` (where it took the row, and how far it moved since). */
|
|
21
|
+
function offset(x, width) {
|
|
17
22
|
if (x > 0) {
|
|
18
23
|
return 0;
|
|
19
24
|
}
|
|
20
|
-
|
|
25
|
+
if (x >= -width) {
|
|
26
|
+
return x;
|
|
27
|
+
}
|
|
28
|
+
// The rubber band of iOS: as fast as RUBBER at first, never as far as BEYOND_PX; its slope has no kink past the start.
|
|
29
|
+
const past = -width - x;
|
|
30
|
+
return -width - RowSwipeUtil.BEYOND_PX * (1 - 1 / ((past * RowSwipeUtil.RUBBER) / RowSwipeUtil.BEYOND_PX + 1));
|
|
21
31
|
}
|
|
22
32
|
RowSwipeUtil.offset = offset;
|
|
23
|
-
/**
|
|
24
|
-
function
|
|
33
|
+
/** Where the finger would be for the row at `offset`: the other way from `offset`, so that a row taken past its actions does not jump. */
|
|
34
|
+
function finger(offset, width) {
|
|
35
|
+
if (offset >= -width) {
|
|
36
|
+
return offset;
|
|
37
|
+
}
|
|
38
|
+
const past = Math.min(-width - offset, RowSwipeUtil.BEYOND_PX - 0.01);
|
|
39
|
+
return -width - (RowSwipeUtil.BEYOND_PX / RowSwipeUtil.RUBBER) * (1 / (1 - past / RowSwipeUtil.BEYOND_PX) - 1);
|
|
40
|
+
}
|
|
41
|
+
RowSwipeUtil.finger = finger;
|
|
42
|
+
/** Whether it stays open, let go at `offset` at `speed` (pixels a millisecond, SwipeVelocity): flicked, the way it was; else where it is headed. */
|
|
43
|
+
function settle(offset, width, speed) {
|
|
25
44
|
if (Math.abs(speed) > SwipeUtil.FLICK) {
|
|
26
45
|
return speed < 0;
|
|
27
46
|
}
|
|
28
|
-
return offset
|
|
47
|
+
return offset + speed * RowSwipeUtil.PROJECT_MS < -width / 2;
|
|
29
48
|
}
|
|
30
49
|
RowSwipeUtil.settle = settle;
|
|
50
|
+
/**
|
|
51
|
+
* How far the finger has moved the row, `dx` since the move was told a swipe, `lag` before (the few pixels
|
|
52
|
+
* that told it): from where it was, without a jump, a little faster than the finger until it is where the
|
|
53
|
+
* finger says (CATCH_PX), as if it had followed it from the start.
|
|
54
|
+
*/
|
|
55
|
+
function follow(dx, lag) {
|
|
56
|
+
return dx + lag * Math.min(1, Math.abs(dx) / RowSwipeUtil.CATCH_PX);
|
|
57
|
+
}
|
|
58
|
+
RowSwipeUtil.follow = follow;
|
|
59
|
+
/**
|
|
60
|
+
* How far each action is pushed to the right of where it rests, the row at `offset`: they come out with the
|
|
61
|
+
* row's edge, as iOS's, the first one at it, the others spread over what is shown (`share`, 1 - its index
|
|
62
|
+
* of how many there are: 1 for the first, less for those after).
|
|
63
|
+
*/
|
|
64
|
+
function shift(offset, width, share) {
|
|
65
|
+
return (width + offset) * share;
|
|
66
|
+
}
|
|
67
|
+
RowSwipeUtil.shift = shift;
|
|
31
68
|
/** Whether the move so far is the row's (more sideways than down, to the left unless open); undefined until it is told. */
|
|
32
69
|
function claims(dx, dy, open) {
|
|
33
70
|
if (Math.hypot(dx, dy) < SwipeUtil.SLOP_PX) {
|
|
@@ -41,15 +78,27 @@ export var RowSwipeUtil;
|
|
|
41
78
|
let opened;
|
|
42
79
|
/** What slides in a row (SwipeRow): its content, over its actions. */
|
|
43
80
|
const CONTENT = ':scope > .ta-swipe-content';
|
|
44
|
-
const
|
|
81
|
+
const ACTION = ':scope > .ta-swipe-actions > .ta-swipe-action';
|
|
45
82
|
/** A tap: from the finger down to its click, at most. */
|
|
46
83
|
const TAP_MS = 600;
|
|
84
|
+
/** Where each of `buttons` is, the row at `offset` (RowSwipeUtil.shift). */
|
|
85
|
+
function actionTargets(buttons, offset, width) {
|
|
86
|
+
return buttons.map((element, index) => ({
|
|
87
|
+
element,
|
|
88
|
+
transform: `translate3d(${RowSwipeUtil.shift(offset, width, 1 - index / buttons.length)}px, 0, 0)`,
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
47
91
|
/**
|
|
48
92
|
* Lets a finger swipe the row of `ref` (a SwipeRow) while `enabled`: its content moves over its actions, whose
|
|
49
|
-
* width is the way to go, and
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
93
|
+
* width is the way to go, and they come out with its edge (RowSwipeUtil.shift); let go, all slide on as on a
|
|
94
|
+
* spring from the speed the finger left them (SwipeSettle). The row sets off from where the move is told a swipe
|
|
95
|
+
* and catches up with the finger (RowSwipeUtil.follow), so it never jumps under it; past its actions it stretches less and
|
|
96
|
+
* less. Open, it closes when the finger scrolls the list from it, or holds it for its menu. Its
|
|
97
|
+
* listeners are passive (the row has `touch-action: pan-y`), so the list scrolls on the compositor; each move
|
|
98
|
+
* only sets a transform. The finger is followed on what it touched (SwipeFinger), so that a row drawn again
|
|
99
|
+
* under it does not stop half way. The style says where an open row rests (`data-swiped`); the row clips
|
|
100
|
+
* what slides out of it only while it is moved, open or on its way back (`data-swipe-clip`), so that a menu
|
|
101
|
+
* of the row is not cut at its edges.
|
|
53
102
|
*/
|
|
54
103
|
export function useRowSwipe(ref, enabled) {
|
|
55
104
|
const [open, setOpen] = React.useState(false);
|
|
@@ -62,15 +111,12 @@ export function useRowSwipe(ref, enabled) {
|
|
|
62
111
|
return;
|
|
63
112
|
}
|
|
64
113
|
let start;
|
|
114
|
+
let last;
|
|
65
115
|
let claimed;
|
|
66
116
|
let moved;
|
|
67
117
|
let unclip;
|
|
68
118
|
const velocity = new SwipeVelocity();
|
|
69
119
|
const settle = new SwipeSettle();
|
|
70
|
-
const release = (element) => {
|
|
71
|
-
delete row.dataset.swiping;
|
|
72
|
-
element === null || element === void 0 ? void 0 : element.style.removeProperty('transform');
|
|
73
|
-
};
|
|
74
120
|
const clip = (on, after = 0) => {
|
|
75
121
|
clearTimeout(unclip);
|
|
76
122
|
if (on) {
|
|
@@ -80,38 +126,38 @@ export function useRowSwipe(ref, enabled) {
|
|
|
80
126
|
unclip = setTimeout(() => delete row.dataset.swipeClip, after);
|
|
81
127
|
}
|
|
82
128
|
};
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
claimed = undefined;
|
|
86
|
-
// A swipe from the edge a sheet comes from is the sheet's (useSheetSwipe's edgeOver), not the row's.
|
|
87
|
-
const side = document.documentElement.dataset.edgeSwipe;
|
|
88
|
-
const edge = !!touch && (side === 'right' ? touch.clientX >= window.innerWidth - SwipeUtil.EDGE_PX : side === 'left' && touch.clientX <= SwipeUtil.EDGE_PX);
|
|
89
|
-
start = event.touches.length === 1 && touch && !edge ? { x: touch.clientX, y: touch.clientY, t: event.timeStamp } : undefined;
|
|
90
|
-
if (start) {
|
|
91
|
-
velocity.start(start);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
const onMove = (event) => {
|
|
95
|
-
var _a;
|
|
96
|
-
var _b;
|
|
97
|
-
const touch = event.touches[0];
|
|
98
|
-
if (!start || !touch || claimed === false) {
|
|
129
|
+
const onMove = (event, touch) => {
|
|
130
|
+
if (!start || claimed === false) {
|
|
99
131
|
return;
|
|
100
132
|
}
|
|
101
|
-
const dx = touch.clientX - start.x;
|
|
102
133
|
if (claimed === undefined) {
|
|
103
|
-
claimed = RowSwipeUtil.claims(
|
|
104
|
-
if (
|
|
134
|
+
claimed = RowSwipeUtil.claims(touch.clientX - start.x, touch.clientY - start.y, state.current);
|
|
135
|
+
if (claimed === undefined) {
|
|
105
136
|
return;
|
|
106
137
|
}
|
|
107
138
|
const element = row.querySelector(CONTENT);
|
|
108
|
-
const
|
|
109
|
-
|
|
139
|
+
const buttons = [...row.querySelectorAll(ACTION)];
|
|
140
|
+
// The way to go is what the actions fill (their box spans the row, to clip them: style/device.ts).
|
|
141
|
+
const width = buttons.reduce((sum, button) => sum + button.offsetWidth, 0);
|
|
142
|
+
if (!claimed || !element || !width) {
|
|
110
143
|
claimed = false;
|
|
144
|
+
finger.stop();
|
|
145
|
+
// Open, a scroll from it closes it, as a touch elsewhere does.
|
|
146
|
+
if (state.current) {
|
|
147
|
+
close();
|
|
148
|
+
}
|
|
111
149
|
return;
|
|
112
150
|
}
|
|
113
|
-
|
|
114
|
-
|
|
151
|
+
// From where it is (at rest, or still sliding), and from where the finger is now.
|
|
152
|
+
moved = {
|
|
153
|
+
content: element,
|
|
154
|
+
buttons,
|
|
155
|
+
width,
|
|
156
|
+
from: RowSwipeUtil.finger(translated(element), width),
|
|
157
|
+
x: touch.clientX,
|
|
158
|
+
lag: touch.clientX - start.x,
|
|
159
|
+
};
|
|
160
|
+
settle.hold([element, ...buttons]);
|
|
115
161
|
clip(true);
|
|
116
162
|
row.dataset.swiping = '';
|
|
117
163
|
if (opened && opened !== handle) {
|
|
@@ -119,38 +165,73 @@ export function useRowSwipe(ref, enabled) {
|
|
|
119
165
|
}
|
|
120
166
|
}
|
|
121
167
|
if (moved) {
|
|
122
|
-
|
|
123
|
-
|
|
168
|
+
last = { x: touch.clientX, y: touch.clientY, t: event.timeStamp };
|
|
169
|
+
velocity.add(last);
|
|
170
|
+
const x = RowSwipeUtil.offset(moved.from + RowSwipeUtil.follow(touch.clientX - moved.x, moved.lag), moved.width);
|
|
171
|
+
moved.content.style.transform = `translate3d(${x}px, 0, 0)`;
|
|
172
|
+
for (const { element, transform } of actionTargets(moved.buttons, x, moved.width)) {
|
|
173
|
+
element.style.transform = transform;
|
|
174
|
+
}
|
|
124
175
|
}
|
|
125
176
|
};
|
|
126
|
-
const onEnd = (event) => {
|
|
127
|
-
var _a, _b;
|
|
177
|
+
const onEnd = (event, touch) => {
|
|
128
178
|
if (start && moved) {
|
|
129
|
-
const end = event.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
//
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
179
|
+
const end = touch ? { x: touch.clientX, y: touch.clientY, t: event.timeStamp } : (last !== null && last !== void 0 ? last : start);
|
|
180
|
+
if (touch) {
|
|
181
|
+
velocity.add(end);
|
|
182
|
+
}
|
|
183
|
+
// Taken by the system (a call, the app put away), it goes to the nearer side, not the way it was going.
|
|
184
|
+
const speed = touch && event.type !== 'touchcancel' ? velocity.speed : 0;
|
|
185
|
+
const { content, buttons, width } = moved;
|
|
186
|
+
const from = RowSwipeUtil.offset(moved.from + RowSwipeUtil.follow(end.x - moved.x, moved.lag), width);
|
|
187
|
+
// Where it ends is told by where the finger is, which the row may not have caught up with yet.
|
|
188
|
+
const next = RowSwipeUtil.settle(RowSwipeUtil.offset(moved.from + end.x - start.x, width), width, speed);
|
|
189
|
+
const rest = next ? -width : 0;
|
|
190
|
+
// Stretched past its actions, the row went slower than the finger: it goes back as fast as it went.
|
|
191
|
+
const along = from < -width ? speed * RowSwipeUtil.RUBBER : speed;
|
|
192
|
+
const motion = SwipeUtil.motion(from, rest, along, RowSwipeUtil.SETTLE_MS, [-width - RowSwipeUtil.BEYOND_PX, 0]);
|
|
193
|
+
settle.run(motion, [{ element: content, transform: `translate3d(${rest}px, 0, 0)` }, ...actionTargets(buttons, rest, width)], () => state.current === next, () => delete row.dataset.swiping);
|
|
194
|
+
show(next, motion.ms);
|
|
143
195
|
}
|
|
144
196
|
start = undefined;
|
|
197
|
+
last = undefined;
|
|
145
198
|
moved = undefined;
|
|
146
199
|
};
|
|
147
|
-
const
|
|
148
|
-
|
|
200
|
+
const finger = new SwipeFinger({ move: onMove, end: onEnd });
|
|
201
|
+
const onStart = (event) => {
|
|
202
|
+
// Another finger beside the one that swipes it changes nothing.
|
|
203
|
+
if (finger.down && !finger.follow(event, row)) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
finger.stop();
|
|
207
|
+
const touch = event.touches[0];
|
|
208
|
+
claimed = undefined;
|
|
209
|
+
// A swipe from the edge a sheet comes from is the sheet's (useSheetSwipe's edgeOver), not the row's.
|
|
210
|
+
const side = document.documentElement.dataset.edgeSwipe;
|
|
211
|
+
const edge = !!touch && (side === 'right' ? touch.clientX >= window.innerWidth - SwipeUtil.EDGE_PX : side === 'left' && touch.clientX <= SwipeUtil.EDGE_PX);
|
|
212
|
+
start = touch && !edge && finger.follow(event, row) ? { x: touch.clientX, y: touch.clientY, t: event.timeStamp } : undefined;
|
|
213
|
+
if (start) {
|
|
214
|
+
velocity.start(start);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
// Closed while it still slides (a tap on it, or elsewhere), it goes back from where it is.
|
|
218
|
+
const close = () => {
|
|
219
|
+
settle.release();
|
|
220
|
+
show(false);
|
|
221
|
+
};
|
|
222
|
+
// Held for its menu (LongPress), it closes first, as the menu is of the row, not of its actions.
|
|
223
|
+
const onMenu = () => {
|
|
224
|
+
if (state.current) {
|
|
225
|
+
close();
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
const handle = { close };
|
|
229
|
+
closer.current = close;
|
|
149
230
|
// Open, a touch anywhere else closes it, and that is all the tap does, as in WeChat; a tap on the row too (SwipeRow).
|
|
150
231
|
let swallowUntil = 0;
|
|
151
232
|
const onOutside = (event) => {
|
|
152
233
|
if (!row.contains(event.target)) {
|
|
153
|
-
|
|
234
|
+
close();
|
|
154
235
|
swallowUntil = event.timeStamp + TAP_MS;
|
|
155
236
|
document.addEventListener('click', swallow, true);
|
|
156
237
|
}
|
|
@@ -178,14 +259,11 @@ export function useRowSwipe(ref, enabled) {
|
|
|
178
259
|
}
|
|
179
260
|
};
|
|
180
261
|
row.addEventListener('touchstart', onStart, { passive: true });
|
|
181
|
-
row.addEventListener('
|
|
182
|
-
row.addEventListener('touchend', onEnd, { passive: true });
|
|
183
|
-
row.addEventListener('touchcancel', onEnd, { passive: true });
|
|
262
|
+
row.addEventListener('contextmenu', onMenu);
|
|
184
263
|
return () => {
|
|
185
264
|
row.removeEventListener('touchstart', onStart);
|
|
186
|
-
row.removeEventListener('
|
|
187
|
-
|
|
188
|
-
row.removeEventListener('touchcancel', onEnd);
|
|
265
|
+
row.removeEventListener('contextmenu', onMenu);
|
|
266
|
+
finger.stop();
|
|
189
267
|
document.removeEventListener('touchstart', onOutside);
|
|
190
268
|
document.removeEventListener('click', swallow, true);
|
|
191
269
|
if (opened === handle) {
|
|
@@ -193,8 +271,8 @@ export function useRowSwipe(ref, enabled) {
|
|
|
193
271
|
}
|
|
194
272
|
clearTimeout(unclip);
|
|
195
273
|
delete row.dataset.swipeClip;
|
|
196
|
-
|
|
197
|
-
|
|
274
|
+
delete row.dataset.swiping;
|
|
275
|
+
settle.finish();
|
|
198
276
|
closer.current = () => setOpen(false);
|
|
199
277
|
};
|
|
200
278
|
}, [ref, enabled]);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** What the app's web view gives the page to tell it whether a shake may offer to undo (TaBridgeViewController of apps/ta-mobile). */
|
|
2
|
+
export interface ShakeUndoBridge {
|
|
3
|
+
postMessage(undo: boolean): void;
|
|
4
|
+
}
|
|
5
|
+
export declare namespace ShakeUndoUtil {
|
|
6
|
+
/** A field of text being edited that has text in it: what a shake may undo is there to see. */
|
|
7
|
+
function hasText(element: Element | null): boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Shake to Undo in the Ta app on iOS only while a field being edited has text in it. The web view keeps what
|
|
11
|
+
* was typed and sent, or typed and put away, to undo: the system would offer to undo it with the field empty,
|
|
12
|
+
* or on a page without a field. The page tells the app when that changes: focus, typing, the selection, and
|
|
13
|
+
* after a key, a tap or a finger let go, which may have the page empty a field itself (a message sent) with no
|
|
14
|
+
* event of the field. Returns how to stop.
|
|
15
|
+
*/
|
|
16
|
+
export declare function startShakeUndo(doc: Document, bridge: ShakeUndoBridge): () => void;
|