@celljs/ta-web 4.9.1 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/README.en.md +4 -3
  2. package/README.md +4 -3
  3. package/esm/browser/assistant/assistant-chat-list.js +8 -2
  4. package/esm/browser/assistant/assistant-extension.d.ts +8 -1
  5. package/esm/browser/assistant/assistant-extension.js +20 -0
  6. package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
  7. package/esm/browser/assistant/assistant-task-util.d.ts +2 -0
  8. package/esm/browser/assistant/assistant-task-util.js +5 -3
  9. package/esm/browser/assistant/assistant-view.js +81 -56
  10. package/esm/browser/assistant/assistant.d.ts +10 -1
  11. package/esm/browser/assistant/assistant.js +44 -5
  12. package/esm/browser/chat/chat-packages.d.ts +39 -0
  13. package/esm/browser/chat/chat-packages.js +70 -0
  14. package/esm/browser/chat/chat-protocol.d.ts +23 -1
  15. package/esm/browser/chat/chat-stores.d.ts +59 -0
  16. package/esm/browser/chat/chat-stores.js +121 -0
  17. package/esm/browser/chat/chat-util.d.ts +17 -0
  18. package/esm/browser/chat/chat-util.js +61 -0
  19. package/esm/browser/chat/chat-view.js +33 -12
  20. package/esm/browser/chat/chat.d.ts +31 -39
  21. package/esm/browser/chat/chat.js +226 -175
  22. package/esm/browser/components/app-nav.d.ts +6 -3
  23. package/esm/browser/components/app-nav.js +19 -10
  24. package/esm/browser/components/app-shell-hooks.d.ts +2 -2
  25. package/esm/browser/components/app-shell-hooks.js +7 -3
  26. package/esm/browser/components/app-view.js +75 -21
  27. package/esm/browser/components/chat-list.d.ts +20 -2
  28. package/esm/browser/components/chat-list.js +138 -22
  29. package/esm/browser/components/composer-box.d.ts +5 -5
  30. package/esm/browser/components/composer-box.js +111 -4
  31. package/esm/browser/components/composer.d.ts +7 -0
  32. package/esm/browser/components/composer.js +5 -4
  33. package/esm/browser/components/connection-bar.js +50 -17
  34. package/esm/browser/components/context-menu.d.ts +30 -4
  35. package/esm/browser/components/context-menu.js +199 -37
  36. package/esm/browser/components/conversation-scroll.d.ts +129 -6
  37. package/esm/browser/components/conversation-scroll.js +429 -109
  38. package/esm/browser/components/earlier-messages.d.ts +2 -1
  39. package/esm/browser/components/earlier-messages.js +2 -17
  40. package/esm/browser/components/editor-area.d.ts +3 -1
  41. package/esm/browser/components/editor-area.js +6 -5
  42. package/esm/browser/components/empty-pictures.d.ts +0 -2
  43. package/esm/browser/components/empty-pictures.js +0 -16
  44. package/esm/browser/components/folder-picker.d.ts +5 -2
  45. package/esm/browser/components/folder-picker.js +26 -8
  46. package/esm/browser/components/held-talk.d.ts +28 -0
  47. package/esm/browser/components/held-talk.js +76 -0
  48. package/esm/browser/components/host-view.d.ts +1 -1
  49. package/esm/browser/components/icon.d.ts +2 -2
  50. package/esm/browser/components/icon.js +5 -6
  51. package/esm/browser/components/image-viewer.d.ts +124 -0
  52. package/esm/browser/components/image-viewer.js +397 -0
  53. package/esm/browser/components/lightbox.d.ts +11 -0
  54. package/esm/browser/components/lightbox.js +24 -0
  55. package/esm/browser/components/markdown.d.ts +6 -2
  56. package/esm/browser/components/markdown.js +24 -10
  57. package/esm/browser/components/media.js +1 -10
  58. package/esm/browser/components/message-footer.d.ts +16 -2
  59. package/esm/browser/components/message-footer.js +29 -12
  60. package/esm/browser/components/message-list.d.ts +24 -3
  61. package/esm/browser/components/message-list.js +149 -20
  62. package/esm/browser/components/message-menu.d.ts +3 -1
  63. package/esm/browser/components/message-menu.js +18 -3
  64. package/esm/browser/components/nav-places.d.ts +16 -1
  65. package/esm/browser/components/nav-places.js +12 -3
  66. package/esm/browser/components/phone-shell.d.ts +4 -1
  67. package/esm/browser/components/phone-shell.js +3 -1
  68. package/esm/browser/components/run-status.js +3 -3
  69. package/esm/browser/components/session-settings.d.ts +6 -0
  70. package/esm/browser/components/session-settings.js +14 -1
  71. package/esm/browser/components/session-view.js +8 -4
  72. package/esm/browser/components/settings-parts.d.ts +2 -2
  73. package/esm/browser/components/settings-parts.js +24 -1
  74. package/esm/browser/components/swipe-row.d.ts +2 -2
  75. package/esm/browser/components/swipe-row.js +7 -3
  76. package/esm/browser/components/tool-view.js +14 -12
  77. package/esm/browser/components/voice-button.d.ts +1 -1
  78. package/esm/browser/components/voice-button.js +1 -1
  79. package/esm/browser/components/voice-talk.d.ts +43 -0
  80. package/esm/browser/components/voice-talk.js +222 -0
  81. package/esm/browser/device/device.d.ts +3 -0
  82. package/esm/browser/device/device.js +11 -1
  83. package/esm/browser/device/hold.d.ts +42 -0
  84. package/esm/browser/device/hold.js +136 -0
  85. package/esm/browser/device/launch-screen.d.ts +1 -1
  86. package/esm/browser/device/launch-screen.js +1 -1
  87. package/esm/browser/device/long-press.d.ts +2 -0
  88. package/esm/browser/device/long-press.js +16 -1
  89. package/esm/browser/device/pull-down.d.ts +4 -2
  90. package/esm/browser/device/pull-down.js +64 -76
  91. package/esm/browser/device/row-swipe.d.ts +35 -10
  92. package/esm/browser/device/row-swipe.js +149 -71
  93. package/esm/browser/device/shake-undo.d.ts +16 -0
  94. package/esm/browser/device/shake-undo.js +59 -0
  95. package/esm/browser/device/sheet-swipe.d.ts +118 -18
  96. package/esm/browser/device/sheet-swipe.js +406 -107
  97. package/esm/browser/extension/web-extension-api.d.ts +97 -1
  98. package/esm/browser/extension/web-extension-code.d.ts +6 -0
  99. package/esm/browser/extension/web-extension-code.js +24 -0
  100. package/esm/browser/extension/web-extension-protocol.d.ts +23 -1
  101. package/esm/browser/extension/web-extension-protocol.js +8 -0
  102. package/esm/browser/extension/web-extensions.d.ts +14 -1
  103. package/esm/browser/extension/web-extensions.js +122 -23
  104. package/esm/browser/files/files-protocol.d.ts +25 -0
  105. package/esm/browser/files/files-protocol.js +2 -0
  106. package/esm/browser/files/files.d.ts +35 -0
  107. package/esm/browser/files/files.js +119 -0
  108. package/esm/browser/i18n/locales.d.ts +24 -2
  109. package/esm/browser/i18n/messages.d.ts +23 -1
  110. package/esm/browser/i18n/messages.js +48 -4
  111. package/esm/browser/index.d.ts +6 -0
  112. package/esm/browser/index.js +6 -0
  113. package/esm/browser/notices/notices-protocol.d.ts +9 -1
  114. package/esm/browser/notices/notices.d.ts +2 -0
  115. package/esm/browser/notices/notices.js +20 -10
  116. package/esm/browser/offline/device-values.d.ts +55 -0
  117. package/esm/browser/offline/device-values.js +142 -0
  118. package/esm/browser/offline/kept-chats-protocol.d.ts +17 -0
  119. package/esm/browser/offline/kept-chats-protocol.js +2 -0
  120. package/esm/browser/offline/kept-chats.d.ts +47 -0
  121. package/esm/browser/offline/kept-chats.js +146 -0
  122. package/esm/browser/offline/offline-reads.d.ts +44 -0
  123. package/esm/browser/offline/offline-reads.js +107 -0
  124. package/esm/browser/settings/settings-protocol.d.ts +2 -0
  125. package/esm/browser/settings/settings-protocol.js +2 -0
  126. package/esm/browser/style/conversation.d.ts +1 -1
  127. package/esm/browser/style/conversation.js +57 -17
  128. package/esm/browser/style/device.js +27 -4
  129. package/esm/browser/style/layout.d.ts +1 -1
  130. package/esm/browser/style/layout.js +67 -15
  131. package/esm/browser/style/pages.d.ts +1 -1
  132. package/esm/browser/style/pages.js +2 -1
  133. package/esm/browser/style/shell.d.ts +1 -1
  134. package/esm/browser/style/shell.js +46 -3
  135. package/esm/browser/util/frame.d.ts +5 -4
  136. package/esm/browser/util/frame.js +5 -4
  137. package/esm/browser/util/markdown.d.ts +18 -1
  138. package/esm/browser/util/markdown.js +119 -5
  139. package/esm/browser/util/process.d.ts +21 -0
  140. package/esm/browser/util/process.js +45 -1
  141. package/esm/browser/util/voice.d.ts +5 -2
  142. package/esm/browser/util/voice.js +6 -3
  143. package/esm/browser/util/zoom.d.ts +46 -0
  144. package/esm/browser/util/zoom.js +96 -0
  145. package/esm/browser/workbench-calls.d.ts +59 -0
  146. package/esm/browser/workbench-calls.js +141 -0
  147. package/esm/browser/workbench-protocol.d.ts +5 -1
  148. package/esm/browser/workbench-util.d.ts +7 -0
  149. package/esm/browser/workbench-util.js +9 -2
  150. package/esm/browser/workbench.d.ts +14 -5
  151. package/esm/browser/workbench.js +51 -31
  152. package/lib/browser/assistant/assistant-chat-list.js +8 -2
  153. package/lib/browser/assistant/assistant-extension.d.ts +8 -1
  154. package/lib/browser/assistant/assistant-extension.js +20 -0
  155. package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
  156. package/lib/browser/assistant/assistant-task-util.d.ts +2 -0
  157. package/lib/browser/assistant/assistant-task-util.js +5 -3
  158. package/lib/browser/assistant/assistant-view.js +78 -53
  159. package/lib/browser/assistant/assistant.d.ts +10 -1
  160. package/lib/browser/assistant/assistant.js +44 -5
  161. package/lib/browser/chat/chat-packages.d.ts +40 -0
  162. package/lib/browser/chat/chat-packages.js +74 -0
  163. package/lib/browser/chat/chat-protocol.d.ts +23 -1
  164. package/lib/browser/chat/chat-stores.d.ts +60 -0
  165. package/lib/browser/chat/chat-stores.js +125 -0
  166. package/lib/browser/chat/chat-util.d.ts +18 -0
  167. package/lib/browser/chat/chat-util.js +64 -0
  168. package/lib/browser/chat/chat-view.js +33 -12
  169. package/lib/browser/chat/chat.d.ts +31 -39
  170. package/lib/browser/chat/chat.js +227 -176
  171. package/lib/browser/components/app-nav.d.ts +6 -3
  172. package/lib/browser/components/app-nav.js +17 -8
  173. package/lib/browser/components/app-shell-hooks.d.ts +2 -2
  174. package/lib/browser/components/app-shell-hooks.js +7 -3
  175. package/lib/browser/components/app-view.js +74 -20
  176. package/lib/browser/components/chat-list.d.ts +20 -2
  177. package/lib/browser/components/chat-list.js +137 -21
  178. package/lib/browser/components/composer-box.d.ts +5 -5
  179. package/lib/browser/components/composer-box.js +111 -4
  180. package/lib/browser/components/composer.d.ts +7 -0
  181. package/lib/browser/components/composer.js +5 -4
  182. package/lib/browser/components/connection-bar.js +48 -15
  183. package/lib/browser/components/context-menu.d.ts +30 -4
  184. package/lib/browser/components/context-menu.js +198 -36
  185. package/lib/browser/components/conversation-scroll.d.ts +129 -6
  186. package/lib/browser/components/conversation-scroll.js +431 -110
  187. package/lib/browser/components/earlier-messages.d.ts +2 -1
  188. package/lib/browser/components/earlier-messages.js +2 -17
  189. package/lib/browser/components/editor-area.d.ts +3 -1
  190. package/lib/browser/components/editor-area.js +5 -4
  191. package/lib/browser/components/empty-pictures.d.ts +0 -2
  192. package/lib/browser/components/empty-pictures.js +0 -17
  193. package/lib/browser/components/folder-picker.d.ts +5 -2
  194. package/lib/browser/components/folder-picker.js +26 -8
  195. package/lib/browser/components/held-talk.d.ts +29 -0
  196. package/lib/browser/components/held-talk.js +79 -0
  197. package/lib/browser/components/host-view.d.ts +1 -1
  198. package/lib/browser/components/icon.d.ts +2 -2
  199. package/lib/browser/components/icon.js +7 -6
  200. package/lib/browser/components/image-viewer.d.ts +125 -0
  201. package/lib/browser/components/image-viewer.js +435 -0
  202. package/lib/browser/components/lightbox.d.ts +12 -0
  203. package/lib/browser/components/lightbox.js +60 -0
  204. package/lib/browser/components/markdown.d.ts +6 -2
  205. package/lib/browser/components/markdown.js +24 -10
  206. package/lib/browser/components/media.js +2 -11
  207. package/lib/browser/components/message-footer.d.ts +16 -2
  208. package/lib/browser/components/message-footer.js +31 -12
  209. package/lib/browser/components/message-list.d.ts +24 -3
  210. package/lib/browser/components/message-list.js +146 -16
  211. package/lib/browser/components/message-menu.d.ts +3 -1
  212. package/lib/browser/components/message-menu.js +17 -2
  213. package/lib/browser/components/nav-places.d.ts +16 -1
  214. package/lib/browser/components/nav-places.js +13 -3
  215. package/lib/browser/components/phone-shell.d.ts +4 -1
  216. package/lib/browser/components/phone-shell.js +3 -1
  217. package/lib/browser/components/run-status.js +3 -3
  218. package/lib/browser/components/session-settings.d.ts +6 -0
  219. package/lib/browser/components/session-settings.js +14 -1
  220. package/lib/browser/components/session-view.js +7 -3
  221. package/lib/browser/components/settings-parts.d.ts +2 -2
  222. package/lib/browser/components/settings-parts.js +24 -1
  223. package/lib/browser/components/swipe-row.d.ts +2 -2
  224. package/lib/browser/components/swipe-row.js +7 -3
  225. package/lib/browser/components/tool-view.js +14 -12
  226. package/lib/browser/components/voice-button.d.ts +1 -1
  227. package/lib/browser/components/voice-button.js +1 -1
  228. package/lib/browser/components/voice-talk.d.ts +44 -0
  229. package/lib/browser/components/voice-talk.js +260 -0
  230. package/lib/browser/device/device.d.ts +3 -0
  231. package/lib/browser/device/device.js +11 -1
  232. package/lib/browser/device/hold.d.ts +43 -0
  233. package/lib/browser/device/hold.js +173 -0
  234. package/lib/browser/device/launch-screen.d.ts +1 -1
  235. package/lib/browser/device/launch-screen.js +1 -1
  236. package/lib/browser/device/long-press.d.ts +2 -0
  237. package/lib/browser/device/long-press.js +16 -1
  238. package/lib/browser/device/pull-down.d.ts +4 -2
  239. package/lib/browser/device/pull-down.js +63 -75
  240. package/lib/browser/device/row-swipe.d.ts +35 -10
  241. package/lib/browser/device/row-swipe.js +148 -70
  242. package/lib/browser/device/shake-undo.d.ts +17 -0
  243. package/lib/browser/device/shake-undo.js +63 -0
  244. package/lib/browser/device/sheet-swipe.d.ts +118 -18
  245. package/lib/browser/device/sheet-swipe.js +410 -108
  246. package/lib/browser/extension/web-extension-api.d.ts +97 -1
  247. package/lib/browser/extension/web-extension-code.d.ts +6 -0
  248. package/lib/browser/extension/web-extension-code.js +24 -0
  249. package/lib/browser/extension/web-extension-protocol.d.ts +23 -1
  250. package/lib/browser/extension/web-extension-protocol.js +9 -1
  251. package/lib/browser/extension/web-extensions.d.ts +14 -1
  252. package/lib/browser/extension/web-extensions.js +120 -21
  253. package/lib/browser/files/files-protocol.d.ts +26 -0
  254. package/lib/browser/files/files-protocol.js +5 -0
  255. package/lib/browser/files/files.d.ts +36 -0
  256. package/lib/browser/files/files.js +122 -0
  257. package/lib/browser/i18n/locales.d.ts +24 -2
  258. package/lib/browser/i18n/messages.d.ts +23 -1
  259. package/lib/browser/i18n/messages.js +48 -4
  260. package/lib/browser/index.d.ts +6 -0
  261. package/lib/browser/index.js +6 -0
  262. package/lib/browser/notices/notices-protocol.d.ts +9 -1
  263. package/lib/browser/notices/notices.d.ts +2 -0
  264. package/lib/browser/notices/notices.js +20 -10
  265. package/lib/browser/offline/device-values.d.ts +56 -0
  266. package/lib/browser/offline/device-values.js +148 -0
  267. package/lib/browser/offline/kept-chats-protocol.d.ts +18 -0
  268. package/lib/browser/offline/kept-chats-protocol.js +5 -0
  269. package/lib/browser/offline/kept-chats.d.ts +48 -0
  270. package/lib/browser/offline/kept-chats.js +149 -0
  271. package/lib/browser/offline/offline-reads.d.ts +45 -0
  272. package/lib/browser/offline/offline-reads.js +111 -0
  273. package/lib/browser/settings/settings-protocol.d.ts +2 -0
  274. package/lib/browser/settings/settings-protocol.js +2 -0
  275. package/lib/browser/style/conversation.d.ts +1 -1
  276. package/lib/browser/style/conversation.js +57 -17
  277. package/lib/browser/style/device.js +27 -4
  278. package/lib/browser/style/layout.d.ts +1 -1
  279. package/lib/browser/style/layout.js +67 -15
  280. package/lib/browser/style/pages.d.ts +1 -1
  281. package/lib/browser/style/pages.js +2 -1
  282. package/lib/browser/style/shell.d.ts +1 -1
  283. package/lib/browser/style/shell.js +46 -3
  284. package/lib/browser/util/frame.d.ts +5 -4
  285. package/lib/browser/util/frame.js +5 -4
  286. package/lib/browser/util/markdown.d.ts +18 -1
  287. package/lib/browser/util/markdown.js +119 -5
  288. package/lib/browser/util/process.d.ts +21 -0
  289. package/lib/browser/util/process.js +46 -2
  290. package/lib/browser/util/voice.d.ts +5 -2
  291. package/lib/browser/util/voice.js +6 -3
  292. package/lib/browser/util/zoom.d.ts +47 -0
  293. package/lib/browser/util/zoom.js +99 -0
  294. package/lib/browser/workbench-calls.d.ts +60 -0
  295. package/lib/browser/workbench-calls.js +145 -0
  296. package/lib/browser/workbench-protocol.d.ts +5 -1
  297. package/lib/browser/workbench-util.d.ts +7 -0
  298. package/lib/browser/workbench-util.js +10 -3
  299. package/lib/browser/workbench.d.ts +14 -5
  300. package/lib/browser/workbench.js +51 -31
  301. package/package.json +10 -10
  302. 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 is, from 0 (out) to `∓width` (away on its side), when the finger moved `dx`. */
59
- function offset(sheet, dx, width, open) {
60
- const away = -outward(sheet) * width;
61
- return Math.min(Math.max(away, 0), Math.max(Math.min(away, 0), (open ? 0 : away) + dx));
62
- }
63
- SwipeUtil.offset = offset;
64
- /** Whether it ends out, let go at `speed` (pixels a millisecond, SwipeVelocity) after moving `dx`. */
65
- function settle(sheet, dx, width, open, speed) {
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(offset(sheet, dx, width, open)) < width / 2;
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`: as fast at first as
74
- * the finger was, so that a flick goes on at its speed rather than at that of the style; `longest` (the
75
- * style's) when the finger was slow, or going the other way.
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
- /** The transitions of an element that slides on from where the finger left it, for `ms`; it hides at its end. */
86
- function transition(ms, property = 'transform') {
87
- return property === 'opacity' ? `opacity ${ms}ms ${SwipeUtil.CURVE}` : `transform ${ms}ms ${SwipeUtil.CURVE}, visibility 0s ${ms}ms`;
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.transition = transition;
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
- * What slides on, let go, at the speed of the finger (SwipeUtil.duration) rather than of its style; the
120
- * style's again once it rests, or as soon as a finger takes it again.
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
- run(ms, slides, fades = []) {
127
- this.clear();
128
- for (const element of slides) {
129
- this.set(element, SwipeUtil.transition(ms));
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
- for (const element of fades) {
132
- this.set(element, SwipeUtil.transition(ms, 'opacity'));
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.timer = setTimeout(() => this.clear(), ms + 50);
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
- clear() {
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
- for (const element of this.elements) {
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
- /** An element that both slides and fades takes both transitions. */
144
- set(element, transition) {
145
- if (!element) {
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
- if (this.elements.includes(element)) {
149
- element.style.transition = `${element.style.transition}, ${transition}`;
314
+ const style = getComputedStyle(element);
315
+ if (element.style.transform) {
316
+ element.style.transform = style.transform;
150
317
  }
151
- else {
152
- element.style.transition = transition;
153
- this.elements.push(element);
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. A touch in a frame the page may read
233
- * moves it as well (TouchSources).
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 = event.touches[0]) => {
531
+ const point = (event, touch) => {
251
532
  var _a;
252
- var _b, _c, _d, _e;
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: ((_b = touch === null || touch === void 0 ? void 0 : touch.clientX) !== null && _b !== void 0 ? _b : 0) + ((_c = box === null || box === void 0 ? void 0 : box.left) !== null && _c !== void 0 ? _c : 0), y: ((_d = touch === null || touch === void 0 ? void 0 : touch.clientY) !== null && _d !== void 0 ? _d : 0) + ((_e = box === null || box === void 0 ? void 0 : box.top) !== null && _e !== void 0 ? _e : 0), t: event.timeStamp };
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
- const release = (elements) => {
258
- var _a, _b, _c, _d;
259
- delete root.dataset.sheetDrag;
260
- (_a = elements === null || elements === void 0 ? void 0 : elements.sheet) === null || _a === void 0 ? void 0 : _a.style.removeProperty('transform');
261
- (_b = elements === null || elements === void 0 ? void 0 : elements.sheet) === null || _b === void 0 ? void 0 : _b.style.removeProperty('visibility');
262
- (_c = elements === null || elements === void 0 ? void 0 : elements.under) === null || _c === void 0 ? void 0 : _c.style.removeProperty('transform');
263
- (_d = elements === null || elements === void 0 ? void 0 : elements.scrim) === null || _d === void 0 ? void 0 : _d.style.removeProperty('opacity');
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 stop = () => {
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
- moved = { sheet, under: find(current.under), scrim: find(current.scrim), width: (sheet === null || sheet === void 0 ? void 0 : sheet.getBoundingClientRect().width) || window.innerWidth };
289
- root.dataset.sheetDrag = (_a = current.name) !== null && _a !== void 0 ? _a : '';
290
- // Seen while it moves, whatever the styles say of where it rests.
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
- const x = SwipeUtil.offset(current, now.x - start.x, moved.width, current.open);
300
- const out = 1 - Math.abs(x) / moved.width;
301
- if (moved.sheet) {
302
- moved.sheet.style.transform = `translate3d(${x}px, 0, 0)`;
303
- }
304
- if (moved.under) {
305
- moved.under.style.transform = `translate3d(${SwipeUtil.outward(current) * UNDER * moved.width * out}px, 0, 0)`;
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
- if (moved.scrim) {
308
- moved.scrim.style.opacity = String(out);
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
- stop();
315
- claimed = undefined;
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 at = point(event);
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 === 1 && SwipeUtil.starts(sheet, at, current.open, window.innerWidth)) {
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
- stop();
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.addEventListener('touchend', onEnd, { passive: true });
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
- release(moved);
376
- settle.clear();
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
  }