@rafaelaugusto/jolt 0.1.0-beta.9 → 0.1.0-rc.2

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 (576) hide show
  1. package/README.md +167 -21
  2. package/dist/animate.d.ts +25 -4
  3. package/dist/animate.d.ts.map +1 -1
  4. package/dist/animate.js +67 -26
  5. package/dist/animate.js.map +1 -1
  6. package/dist/blur/index.d.ts +6 -0
  7. package/dist/blur/index.d.ts.map +1 -0
  8. package/dist/blur/index.js +196 -0
  9. package/dist/blur/index.js.map +1 -0
  10. package/dist/blur/native.d.ts +17 -0
  11. package/dist/blur/native.d.ts.map +1 -0
  12. package/dist/blur/native.js +44 -0
  13. package/dist/blur/native.js.map +1 -0
  14. package/dist/blur/types.d.ts +32 -0
  15. package/dist/blur/types.d.ts.map +1 -0
  16. package/dist/blur/types.js +2 -0
  17. package/dist/blur/types.js.map +1 -0
  18. package/dist/bottom-sheet/geometry.d.ts +18 -0
  19. package/dist/bottom-sheet/geometry.d.ts.map +1 -0
  20. package/dist/bottom-sheet/geometry.js +51 -0
  21. package/dist/bottom-sheet/geometry.js.map +1 -0
  22. package/dist/bottom-sheet/index.d.ts +56 -0
  23. package/dist/bottom-sheet/index.d.ts.map +1 -0
  24. package/dist/bottom-sheet/index.js +462 -0
  25. package/dist/bottom-sheet/index.js.map +1 -0
  26. package/dist/bottom-sheet/native.d.ts +11 -0
  27. package/dist/bottom-sheet/native.d.ts.map +1 -0
  28. package/dist/bottom-sheet/native.js +173 -0
  29. package/dist/bottom-sheet/native.js.map +1 -0
  30. package/dist/config.d.ts +9 -0
  31. package/dist/config.d.ts.map +1 -1
  32. package/dist/config.js +40 -1
  33. package/dist/config.js.map +1 -1
  34. package/dist/decay.d.ts +1 -0
  35. package/dist/decay.d.ts.map +1 -1
  36. package/dist/decay.js +7 -0
  37. package/dist/decay.js.map +1 -1
  38. package/dist/drag-physics.d.ts +6 -1
  39. package/dist/drag-physics.d.ts.map +1 -1
  40. package/dist/drag.d.ts +17 -3
  41. package/dist/drag.d.ts.map +1 -1
  42. package/dist/drag.js +34 -11
  43. package/dist/drag.js.map +1 -1
  44. package/dist/driver/android-gradient.d.ts +5 -0
  45. package/dist/driver/android-gradient.d.ts.map +1 -0
  46. package/dist/driver/android-gradient.js +99 -0
  47. package/dist/driver/android-gradient.js.map +1 -0
  48. package/dist/driver/android-particles.d.ts +6 -0
  49. package/dist/driver/android-particles.d.ts.map +1 -0
  50. package/dist/driver/android-particles.js +93 -0
  51. package/dist/driver/android-particles.js.map +1 -0
  52. package/dist/driver/android.d.ts.map +1 -1
  53. package/dist/driver/android.js +27 -1
  54. package/dist/driver/android.js.map +1 -1
  55. package/dist/driver/frame.d.ts +3 -0
  56. package/dist/driver/frame.d.ts.map +1 -0
  57. package/dist/driver/frame.js +7 -0
  58. package/dist/driver/frame.js.map +1 -0
  59. package/dist/driver/index.d.ts +4 -0
  60. package/dist/driver/index.d.ts.map +1 -1
  61. package/dist/driver/index.js.map +1 -1
  62. package/dist/driver/ios-gradient.d.ts +5 -0
  63. package/dist/driver/ios-gradient.d.ts.map +1 -0
  64. package/dist/driver/ios-gradient.js +131 -0
  65. package/dist/driver/ios-gradient.js.map +1 -0
  66. package/dist/driver/ios-scroll-delegate.d.ts +4 -0
  67. package/dist/driver/ios-scroll-delegate.d.ts.map +1 -0
  68. package/dist/driver/ios-scroll-delegate.js +26 -0
  69. package/dist/driver/ios-scroll-delegate.js.map +1 -0
  70. package/dist/driver/ios.d.ts.map +1 -1
  71. package/dist/driver/ios.js +9 -0
  72. package/dist/driver/ios.js.map +1 -1
  73. package/dist/easing.d.ts +3 -1
  74. package/dist/easing.d.ts.map +1 -1
  75. package/dist/easing.js +18 -1
  76. package/dist/easing.js.map +1 -1
  77. package/dist/engine.d.ts +31 -2
  78. package/dist/engine.d.ts.map +1 -1
  79. package/dist/engine.js +194 -42
  80. package/dist/engine.js.map +1 -1
  81. package/dist/gesture-native.d.ts +28 -0
  82. package/dist/gesture-native.d.ts.map +1 -0
  83. package/dist/gesture-native.js +61 -0
  84. package/dist/gesture-native.js.map +1 -0
  85. package/dist/gestures/index.d.ts +69 -0
  86. package/dist/gestures/index.d.ts.map +1 -0
  87. package/dist/gestures/index.js +262 -0
  88. package/dist/gestures/index.js.map +1 -0
  89. package/dist/glass/index.d.ts +55 -0
  90. package/dist/glass/index.d.ts.map +1 -0
  91. package/dist/glass/index.js +205 -0
  92. package/dist/glass/index.js.map +1 -0
  93. package/dist/gradient-binding.d.ts +38 -0
  94. package/dist/gradient-binding.d.ts.map +1 -0
  95. package/dist/gradient-binding.js +128 -0
  96. package/dist/gradient-binding.js.map +1 -0
  97. package/dist/gradient.d.ts +105 -0
  98. package/dist/gradient.d.ts.map +1 -0
  99. package/dist/gradient.js +514 -0
  100. package/dist/gradient.js.map +1 -0
  101. package/dist/gravity.d.ts +13 -0
  102. package/dist/gravity.d.ts.map +1 -0
  103. package/dist/gravity.js +84 -0
  104. package/dist/gravity.js.map +1 -0
  105. package/dist/haptics.d.ts.map +1 -1
  106. package/dist/haptics.js +101 -28
  107. package/dist/haptics.js.map +1 -1
  108. package/dist/image-effect.d.ts +1 -0
  109. package/dist/image-effect.d.ts.map +1 -1
  110. package/dist/image-effect.js +10 -2
  111. package/dist/image-effect.js.map +1 -1
  112. package/dist/index.d.ts +19 -7
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +10 -4
  115. package/dist/index.js.map +1 -1
  116. package/dist/inspector/index.d.ts +86 -0
  117. package/dist/inspector/index.d.ts.map +1 -0
  118. package/dist/inspector/index.js +419 -0
  119. package/dist/inspector/index.js.map +1 -0
  120. package/dist/inspector/plot.d.ts +4 -0
  121. package/dist/inspector/plot.d.ts.map +1 -0
  122. package/dist/inspector/plot.js +23 -0
  123. package/dist/inspector/plot.js.map +1 -0
  124. package/dist/inspector/probe.d.ts +19 -0
  125. package/dist/inspector/probe.d.ts.map +1 -0
  126. package/dist/inspector/probe.js +37 -0
  127. package/dist/inspector/probe.js.map +1 -0
  128. package/dist/inspector/tuning.d.ts +19 -0
  129. package/dist/inspector/tuning.d.ts.map +1 -0
  130. package/dist/inspector/tuning.js +37 -0
  131. package/dist/inspector/tuning.js.map +1 -0
  132. package/dist/interactive-navigation/index.d.ts +44 -0
  133. package/dist/interactive-navigation/index.d.ts.map +1 -0
  134. package/dist/interactive-navigation/index.js +350 -0
  135. package/dist/interactive-navigation/index.js.map +1 -0
  136. package/dist/keyboard.d.ts +24 -0
  137. package/dist/keyboard.d.ts.map +1 -1
  138. package/dist/keyboard.js +199 -6
  139. package/dist/keyboard.js.map +1 -1
  140. package/dist/live-spring-driver.d.ts +52 -0
  141. package/dist/live-spring-driver.d.ts.map +1 -0
  142. package/dist/live-spring-driver.js +104 -0
  143. package/dist/live-spring-driver.js.map +1 -0
  144. package/dist/mixer.d.ts +55 -0
  145. package/dist/mixer.d.ts.map +1 -0
  146. package/dist/mixer.js +286 -0
  147. package/dist/mixer.js.map +1 -0
  148. package/dist/motion-scope.d.ts +8 -2
  149. package/dist/motion-scope.d.ts.map +1 -1
  150. package/dist/motion-scope.js +24 -3
  151. package/dist/motion-scope.js.map +1 -1
  152. package/dist/motion-states.d.ts +19 -7
  153. package/dist/motion-states.d.ts.map +1 -1
  154. package/dist/motion-states.js +116 -26
  155. package/dist/motion-states.js.map +1 -1
  156. package/dist/motion-value.d.ts +227 -0
  157. package/dist/motion-value.d.ts.map +1 -0
  158. package/dist/motion-value.js +1074 -0
  159. package/dist/motion-value.js.map +1 -0
  160. package/dist/native/index.d.ts +10 -0
  161. package/dist/native/index.d.ts.map +1 -0
  162. package/dist/native/index.js +6 -0
  163. package/dist/native/index.js.map +1 -0
  164. package/dist/native-properties.d.ts +28 -0
  165. package/dist/native-properties.d.ts.map +1 -0
  166. package/dist/native-properties.js +154 -0
  167. package/dist/native-properties.js.map +1 -0
  168. package/dist/native-property-driver.d.ts +19 -0
  169. package/dist/native-property-driver.d.ts.map +1 -0
  170. package/dist/native-property-driver.js +69 -0
  171. package/dist/native-property-driver.js.map +1 -0
  172. package/dist/native-property.d.ts +37 -0
  173. package/dist/native-property.d.ts.map +1 -0
  174. package/dist/native-property.js +285 -0
  175. package/dist/native-property.js.map +1 -0
  176. package/dist/particles.d.ts +5 -2
  177. package/dist/particles.d.ts.map +1 -1
  178. package/dist/particles.js +16 -10
  179. package/dist/particles.js.map +1 -1
  180. package/dist/path.d.ts.map +1 -1
  181. package/dist/path.js +2 -2
  182. package/dist/path.js.map +1 -1
  183. package/dist/physics/index.d.ts +139 -0
  184. package/dist/physics/index.d.ts.map +1 -0
  185. package/dist/physics/index.js +316 -0
  186. package/dist/physics/index.js.map +1 -0
  187. package/dist/physics/native.d.ts +54 -0
  188. package/dist/physics/native.d.ts.map +1 -0
  189. package/dist/physics/native.js +64 -0
  190. package/dist/physics/native.js.map +1 -0
  191. package/dist/playback-group.d.ts.map +1 -1
  192. package/dist/playback-group.js +17 -1
  193. package/dist/playback-group.js.map +1 -1
  194. package/dist/playback.d.ts +15 -0
  195. package/dist/playback.d.ts.map +1 -1
  196. package/dist/playback.js +23 -0
  197. package/dist/playback.js.map +1 -1
  198. package/dist/predictive-back/index.d.ts +45 -0
  199. package/dist/predictive-back/index.d.ts.map +1 -0
  200. package/dist/predictive-back/index.js +220 -0
  201. package/dist/predictive-back/index.js.map +1 -0
  202. package/dist/predictive-back/presentation.d.ts +4 -0
  203. package/dist/predictive-back/presentation.d.ts.map +1 -0
  204. package/dist/predictive-back/presentation.js +3 -0
  205. package/dist/predictive-back/presentation.js.map +1 -0
  206. package/dist/press.d.ts.map +1 -1
  207. package/dist/press.js +11 -2
  208. package/dist/press.js.map +1 -1
  209. package/dist/reorder/handle.d.ts +6 -0
  210. package/dist/reorder/handle.d.ts.map +1 -0
  211. package/dist/reorder/handle.js +10 -0
  212. package/dist/reorder/handle.js.map +1 -0
  213. package/dist/reorder/index.d.ts +10 -0
  214. package/dist/reorder/index.d.ts.map +1 -0
  215. package/dist/reorder/index.js +233 -0
  216. package/dist/reorder/index.js.map +1 -0
  217. package/dist/reorder/list-view.d.ts +5 -0
  218. package/dist/reorder/list-view.d.ts.map +1 -0
  219. package/dist/reorder/list-view.js +238 -0
  220. package/dist/reorder/list-view.js.map +1 -0
  221. package/dist/reorder/model.d.ts +6 -0
  222. package/dist/reorder/model.d.ts.map +1 -0
  223. package/dist/reorder/model.js +30 -0
  224. package/dist/reorder/model.js.map +1 -0
  225. package/dist/reorder/surface.d.ts +6 -0
  226. package/dist/reorder/surface.d.ts.map +1 -0
  227. package/dist/reorder/surface.js +10 -0
  228. package/dist/reorder/surface.js.map +1 -0
  229. package/dist/reorder/types.d.ts +92 -0
  230. package/dist/reorder/types.d.ts.map +1 -0
  231. package/dist/reorder/types.js +2 -0
  232. package/dist/reorder/types.js.map +1 -0
  233. package/dist/sampling.d.ts +35 -0
  234. package/dist/sampling.d.ts.map +1 -0
  235. package/dist/sampling.js +123 -0
  236. package/dist/sampling.js.map +1 -0
  237. package/dist/scene-appearance.d.ts +14 -0
  238. package/dist/scene-appearance.d.ts.map +1 -0
  239. package/dist/scene-appearance.js +68 -0
  240. package/dist/scene-appearance.js.map +1 -0
  241. package/dist/scene-camera.d.ts +5 -0
  242. package/dist/scene-camera.d.ts.map +1 -0
  243. package/dist/scene-camera.js +23 -0
  244. package/dist/scene-camera.js.map +1 -0
  245. package/dist/scene-shader.d.ts +18 -0
  246. package/dist/scene-shader.d.ts.map +1 -0
  247. package/dist/scene-shader.js +76 -0
  248. package/dist/scene-shader.js.map +1 -0
  249. package/dist/scroll-header/geometry.d.ts +18 -0
  250. package/dist/scroll-header/geometry.d.ts.map +1 -0
  251. package/dist/scroll-header/geometry.js +46 -0
  252. package/dist/scroll-header/geometry.js.map +1 -0
  253. package/dist/scroll-header/index.d.ts +48 -0
  254. package/dist/scroll-header/index.d.ts.map +1 -0
  255. package/dist/scroll-header/index.js +399 -0
  256. package/dist/scroll-header/index.js.map +1 -0
  257. package/dist/scroll-header/native.d.ts +28 -0
  258. package/dist/scroll-header/native.d.ts.map +1 -0
  259. package/dist/scroll-header/native.js +43 -0
  260. package/dist/scroll-header/native.js.map +1 -0
  261. package/dist/sensors/index.d.ts +69 -0
  262. package/dist/sensors/index.d.ts.map +1 -0
  263. package/dist/sensors/index.js +149 -0
  264. package/dist/sensors/index.js.map +1 -0
  265. package/dist/sensors/native.d.ts +20 -0
  266. package/dist/sensors/native.d.ts.map +1 -0
  267. package/dist/sensors/native.js +48 -0
  268. package/dist/sensors/native.js.map +1 -0
  269. package/dist/sequence.d.ts +24 -0
  270. package/dist/sequence.d.ts.map +1 -1
  271. package/dist/sequence.js +181 -19
  272. package/dist/sequence.js.map +1 -1
  273. package/dist/shapes/android.d.ts +3 -0
  274. package/dist/shapes/android.d.ts.map +1 -0
  275. package/dist/shapes/android.js +51 -0
  276. package/dist/shapes/android.js.map +1 -0
  277. package/dist/shapes/index.d.ts +6 -0
  278. package/dist/shapes/index.d.ts.map +1 -0
  279. package/dist/shapes/index.js +238 -0
  280. package/dist/shapes/index.js.map +1 -0
  281. package/dist/shapes/ios.d.ts +3 -0
  282. package/dist/shapes/ios.d.ts.map +1 -0
  283. package/dist/shapes/ios.js +164 -0
  284. package/dist/shapes/ios.js.map +1 -0
  285. package/dist/shapes/native.d.ts +18 -0
  286. package/dist/shapes/native.d.ts.map +1 -0
  287. package/dist/shapes/native.js +10 -0
  288. package/dist/shapes/native.js.map +1 -0
  289. package/dist/shapes/path.d.ts +10 -0
  290. package/dist/shapes/path.d.ts.map +1 -0
  291. package/dist/shapes/path.js +106 -0
  292. package/dist/shapes/path.js.map +1 -0
  293. package/dist/shapes/types.d.ts +55 -0
  294. package/dist/shapes/types.d.ts.map +1 -0
  295. package/dist/shapes/types.js +11 -0
  296. package/dist/shapes/types.js.map +1 -0
  297. package/dist/shared-layout/index.d.ts +40 -0
  298. package/dist/shared-layout/index.d.ts.map +1 -0
  299. package/dist/shared-layout/index.js +267 -0
  300. package/dist/shared-layout/index.js.map +1 -0
  301. package/dist/shared-layout/native.d.ts +15 -0
  302. package/dist/shared-layout/native.d.ts.map +1 -0
  303. package/dist/shared-layout/native.js +79 -0
  304. package/dist/shared-layout/native.js.map +1 -0
  305. package/dist/shared-layout/timing.d.ts +9 -0
  306. package/dist/shared-layout/timing.d.ts.map +1 -0
  307. package/dist/shared-layout/timing.js +68 -0
  308. package/dist/shared-layout/timing.js.map +1 -0
  309. package/dist/shared-navigation/entry.d.ts +51 -0
  310. package/dist/shared-navigation/entry.d.ts.map +1 -0
  311. package/dist/shared-navigation/entry.js +619 -0
  312. package/dist/shared-navigation/entry.js.map +1 -0
  313. package/dist/shared-navigation/index.d.ts +58 -0
  314. package/dist/shared-navigation/index.d.ts.map +1 -0
  315. package/dist/shared-navigation/index.js +318 -0
  316. package/dist/shared-navigation/index.js.map +1 -0
  317. package/dist/shared-navigation/return-signal.d.ts +16 -0
  318. package/dist/shared-navigation/return-signal.d.ts.map +1 -0
  319. package/dist/shared-navigation/return-signal.js +35 -0
  320. package/dist/shared-navigation/return-signal.js.map +1 -0
  321. package/dist/shared-navigation/return-target.d.ts +32 -0
  322. package/dist/shared-navigation/return-target.d.ts.map +1 -0
  323. package/dist/shared-navigation/return-target.js +168 -0
  324. package/dist/shared-navigation/return-target.js.map +1 -0
  325. package/dist/shared-navigation/scope.d.ts +4 -0
  326. package/dist/shared-navigation/scope.d.ts.map +1 -0
  327. package/dist/shared-navigation/scope.js +2 -0
  328. package/dist/shared-navigation/scope.js.map +1 -0
  329. package/dist/shared-navigation/targets.d.ts +6 -0
  330. package/dist/shared-navigation/targets.d.ts.map +1 -0
  331. package/dist/shared-navigation/targets.js +36 -0
  332. package/dist/shared-navigation/targets.js.map +1 -0
  333. package/dist/size-layout.d.ts +19 -0
  334. package/dist/size-layout.d.ts.map +1 -0
  335. package/dist/size-layout.js +216 -0
  336. package/dist/size-layout.js.map +1 -0
  337. package/dist/size.d.ts +19 -0
  338. package/dist/size.d.ts.map +1 -0
  339. package/dist/size.js +251 -0
  340. package/dist/size.js.map +1 -0
  341. package/dist/spring.d.ts +2 -0
  342. package/dist/spring.d.ts.map +1 -1
  343. package/dist/spring.js +11 -0
  344. package/dist/spring.js.map +1 -1
  345. package/dist/svg-path.d.ts +18 -0
  346. package/dist/svg-path.d.ts.map +1 -1
  347. package/dist/svg-path.js +3 -2
  348. package/dist/svg-path.js.map +1 -1
  349. package/dist/testing/clock.d.ts +40 -0
  350. package/dist/testing/clock.d.ts.map +1 -0
  351. package/dist/testing/clock.js +116 -0
  352. package/dist/testing/clock.js.map +1 -0
  353. package/dist/testing/handoff-recorder.d.ts +8 -0
  354. package/dist/testing/handoff-recorder.d.ts.map +1 -0
  355. package/dist/testing/handoff-recorder.js +77 -0
  356. package/dist/testing/handoff-recorder.js.map +1 -0
  357. package/dist/testing/index.d.ts +5 -0
  358. package/dist/testing/index.d.ts.map +1 -0
  359. package/dist/testing/index.js +5 -0
  360. package/dist/testing/index.js.map +1 -0
  361. package/dist/testing/native.d.ts +46 -0
  362. package/dist/testing/native.d.ts.map +1 -0
  363. package/dist/testing/native.js +313 -0
  364. package/dist/testing/native.js.map +1 -0
  365. package/dist/testing/presentation.d.ts +11 -0
  366. package/dist/testing/presentation.d.ts.map +1 -0
  367. package/dist/testing/presentation.js +45 -0
  368. package/dist/testing/presentation.js.map +1 -0
  369. package/dist/testing/replay.d.ts +39 -0
  370. package/dist/testing/replay.d.ts.map +1 -0
  371. package/dist/testing/replay.js +99 -0
  372. package/dist/testing/replay.js.map +1 -0
  373. package/dist/testing/scroll-handoff-native.d.ts +10 -0
  374. package/dist/testing/scroll-handoff-native.d.ts.map +1 -0
  375. package/dist/testing/scroll-handoff-native.js +151 -0
  376. package/dist/testing/scroll-handoff-native.js.map +1 -0
  377. package/dist/testing/scroll-handoff.d.ts +25 -0
  378. package/dist/testing/scroll-handoff.d.ts.map +1 -0
  379. package/dist/testing/scroll-handoff.js +127 -0
  380. package/dist/testing/scroll-handoff.js.map +1 -0
  381. package/dist/testing/sensors.d.ts +13 -0
  382. package/dist/testing/sensors.d.ts.map +1 -0
  383. package/dist/testing/sensors.js +26 -0
  384. package/dist/testing/sensors.js.map +1 -0
  385. package/dist/testing/trace.d.ts +101 -0
  386. package/dist/testing/trace.d.ts.map +1 -0
  387. package/dist/testing/trace.js +263 -0
  388. package/dist/testing/trace.js.map +1 -0
  389. package/dist/timed-animation.d.ts +38 -0
  390. package/dist/timed-animation.d.ts.map +1 -0
  391. package/dist/timed-animation.js +177 -0
  392. package/dist/timed-animation.js.map +1 -0
  393. package/dist/track.d.ts +3 -0
  394. package/dist/track.d.ts.map +1 -1
  395. package/dist/track.js +281 -40
  396. package/dist/track.js.map +1 -1
  397. package/dist/transition.d.ts +54 -2
  398. package/dist/transition.d.ts.map +1 -1
  399. package/dist/transition.js +128 -8
  400. package/dist/transition.js.map +1 -1
  401. package/dist/types.d.ts +10 -1
  402. package/dist/types.d.ts.map +1 -1
  403. package/dist/value-observers.d.ts +22 -0
  404. package/dist/value-observers.d.ts.map +1 -0
  405. package/dist/value-observers.js +122 -0
  406. package/dist/value-observers.js.map +1 -0
  407. package/dist/value-track.d.ts +13 -0
  408. package/dist/value-track.d.ts.map +1 -0
  409. package/dist/value-track.js +59 -0
  410. package/dist/value-track.js.map +1 -0
  411. package/dist/vue/index.d.ts +33 -3
  412. package/dist/vue/index.d.ts.map +1 -1
  413. package/dist/vue/index.js +118 -3
  414. package/dist/vue/index.js.map +1 -1
  415. package/dist/zoomable.d.ts +1 -1
  416. package/dist/zoomable.d.ts.map +1 -1
  417. package/package.json +68 -3
  418. package/platforms/android/include.gradle +10 -0
  419. package/platforms/android/java/org/rafaelaugusto/jolt/BlurEffect.java +89 -0
  420. package/platforms/android/java/org/rafaelaugusto/jolt/CircleMath.java +158 -0
  421. package/platforms/android/java/org/rafaelaugusto/jolt/CircleWorld.java +221 -0
  422. package/platforms/android/java/org/rafaelaugusto/jolt/GestureSession.java +227 -0
  423. package/platforms/android/java/org/rafaelaugusto/jolt/GestureSurface.java +54 -0
  424. package/platforms/android/java/org/rafaelaugusto/jolt/GradientLayer.java +224 -0
  425. package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardFrame.java +53 -0
  426. package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardFrameFollower.java +57 -0
  427. package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardObserver.java +97 -0
  428. package/platforms/android/java/org/rafaelaugusto/jolt/LiveSpring.java +277 -0
  429. package/platforms/android/java/org/rafaelaugusto/jolt/MotionProbe.java +70 -0
  430. package/platforms/android/java/org/rafaelaugusto/jolt/ParticleEmitter.java +192 -0
  431. package/platforms/android/java/org/rafaelaugusto/jolt/ParticleSimulation.java +114 -0
  432. package/platforms/android/java/org/rafaelaugusto/jolt/PredictiveBackSession.java +212 -0
  433. package/platforms/android/java/org/rafaelaugusto/jolt/ReorderHandle.java +25 -0
  434. package/platforms/android/java/org/rafaelaugusto/jolt/ReorderSession.java +213 -0
  435. package/platforms/android/java/org/rafaelaugusto/jolt/ReorderSurface.java +27 -0
  436. package/platforms/android/java/org/rafaelaugusto/jolt/ScrollHeader.java +84 -0
  437. package/platforms/android/java/org/rafaelaugusto/jolt/SensorMath.java +28 -0
  438. package/platforms/android/java/org/rafaelaugusto/jolt/SensorSource.java +217 -0
  439. package/platforms/android/java/org/rafaelaugusto/jolt/ShapeLayer.java +120 -0
  440. package/platforms/android/java/org/rafaelaugusto/jolt/SharedLayoutFlight.java +287 -0
  441. package/platforms/android/java/org/rafaelaugusto/jolt/SharedNavigationScene.java +115 -0
  442. package/platforms/android/java/org/rafaelaugusto/jolt/SpringState.java +39 -0
  443. package/platforms/android/proguard-rules.pro +20 -0
  444. package/platforms/ios/build.xcconfig +1 -1
  445. package/platforms/ios/src/JoltBlur.h +14 -0
  446. package/platforms/ios/src/JoltBlur.m +86 -0
  447. package/platforms/ios/src/JoltCircleMath.h +191 -0
  448. package/platforms/ios/src/JoltCircleWorld.h +18 -0
  449. package/platforms/ios/src/JoltCircleWorld.m +218 -0
  450. package/platforms/ios/src/JoltGestureSession.h +23 -0
  451. package/platforms/ios/src/JoltGestureSession.m +251 -0
  452. package/platforms/ios/src/JoltInteractiveNavigation.h +23 -0
  453. package/platforms/ios/src/JoltInteractiveNavigation.m +255 -0
  454. package/platforms/ios/src/JoltLiveSpring.h +29 -0
  455. package/platforms/ios/src/JoltLiveSpring.m +243 -0
  456. package/platforms/ios/src/JoltMotionProbe.h +9 -0
  457. package/platforms/ios/src/JoltMotionProbe.m +72 -0
  458. package/platforms/ios/src/JoltReorderSession.h +15 -0
  459. package/platforms/ios/src/JoltReorderSession.m +205 -0
  460. package/platforms/ios/src/JoltScrollHeader.h +13 -0
  461. package/platforms/ios/src/JoltScrollHeader.m +101 -0
  462. package/platforms/ios/src/JoltSensorMath.h +39 -0
  463. package/platforms/ios/src/JoltSensorSource.h +13 -0
  464. package/platforms/ios/src/JoltSensorSource.m +201 -0
  465. package/platforms/ios/src/JoltSharedLayoutFlight.h +19 -0
  466. package/platforms/ios/src/JoltSharedLayoutFlight.m +250 -0
  467. package/platforms/ios/src/JoltSpringState.h +35 -0
  468. package/platforms/ios/src/module.modulemap +10 -0
  469. package/src/android-plugin.d.ts +464 -0
  470. package/src/animate.ts +129 -15
  471. package/src/blur/index.ts +195 -0
  472. package/src/blur/native.ts +70 -0
  473. package/src/blur/types.ts +32 -0
  474. package/src/bottom-sheet/geometry.ts +84 -0
  475. package/src/bottom-sheet/index.ts +536 -0
  476. package/src/bottom-sheet/native.ts +214 -0
  477. package/src/config.ts +39 -1
  478. package/src/decay.ts +9 -0
  479. package/src/drag.ts +67 -21
  480. package/src/driver/android-gradient.ts +116 -0
  481. package/src/driver/android-particles.ts +118 -0
  482. package/src/driver/android.ts +31 -1
  483. package/src/driver/frame.ts +10 -0
  484. package/src/driver/index.ts +4 -0
  485. package/src/driver/ios-gradient.ts +136 -0
  486. package/src/driver/ios-scroll-delegate.ts +23 -0
  487. package/src/driver/ios.ts +10 -0
  488. package/src/easing.ts +21 -1
  489. package/src/engine.ts +209 -60
  490. package/src/gesture-native.ts +139 -0
  491. package/src/gestures/index.ts +365 -0
  492. package/src/glass/index.ts +218 -0
  493. package/src/gradient-binding.ts +158 -0
  494. package/src/gradient.ts +663 -0
  495. package/src/gravity.ts +107 -0
  496. package/src/haptics.ts +106 -28
  497. package/src/image-effect.ts +10 -2
  498. package/src/index.ts +56 -7
  499. package/src/inspector/index.ts +523 -0
  500. package/src/inspector/plot.ts +27 -0
  501. package/src/inspector/probe.ts +50 -0
  502. package/src/inspector/tuning.ts +51 -0
  503. package/src/interactive-navigation/index.ts +427 -0
  504. package/src/ios-plugin.d.ts +280 -0
  505. package/src/keyboard.ts +231 -7
  506. package/src/live-spring-driver.ts +181 -0
  507. package/src/mixer.ts +312 -0
  508. package/src/motion-scope.ts +39 -6
  509. package/src/motion-states.ts +149 -42
  510. package/src/motion-value.ts +1289 -0
  511. package/src/native/index.ts +30 -0
  512. package/src/native-properties.ts +188 -0
  513. package/src/native-property-driver.ts +123 -0
  514. package/src/native-property.ts +366 -0
  515. package/src/particles.ts +18 -17
  516. package/src/path.ts +2 -1
  517. package/src/physics/index.ts +476 -0
  518. package/src/physics/native.ts +121 -0
  519. package/src/playback-group.ts +17 -1
  520. package/src/playback.ts +41 -0
  521. package/src/predictive-back/index.ts +280 -0
  522. package/src/predictive-back/presentation.ts +6 -0
  523. package/src/press.ts +10 -2
  524. package/src/reorder/handle.ts +9 -0
  525. package/src/reorder/index.ts +243 -0
  526. package/src/reorder/list-view.ts +262 -0
  527. package/src/reorder/model.ts +47 -0
  528. package/src/reorder/surface.ts +10 -0
  529. package/src/reorder/types.ts +87 -0
  530. package/src/sampling.ts +173 -0
  531. package/src/scene-appearance.ts +92 -0
  532. package/src/scene-camera.ts +30 -0
  533. package/src/scene-shader.ts +139 -0
  534. package/src/scroll-header/geometry.ts +88 -0
  535. package/src/scroll-header/index.ts +530 -0
  536. package/src/scroll-header/native.ts +89 -0
  537. package/src/sensors/index.ts +246 -0
  538. package/src/sensors/native.ts +72 -0
  539. package/src/sequence.ts +209 -20
  540. package/src/shapes/android.ts +63 -0
  541. package/src/shapes/index.ts +267 -0
  542. package/src/shapes/ios.ts +194 -0
  543. package/src/shapes/native.ts +27 -0
  544. package/src/shapes/path.ts +127 -0
  545. package/src/shapes/types.ts +63 -0
  546. package/src/shared-layout/index.ts +343 -0
  547. package/src/shared-layout/native.ts +138 -0
  548. package/src/shared-layout/timing.ts +87 -0
  549. package/src/shared-navigation/entry.ts +695 -0
  550. package/src/shared-navigation/index.ts +414 -0
  551. package/src/shared-navigation/return-signal.ts +41 -0
  552. package/src/shared-navigation/return-target.ts +197 -0
  553. package/src/shared-navigation/scope.ts +3 -0
  554. package/src/shared-navigation/targets.ts +38 -0
  555. package/src/size-layout.ts +237 -0
  556. package/src/size.ts +302 -0
  557. package/src/spring.ts +18 -0
  558. package/src/svg-path.ts +8 -3
  559. package/src/testing/clock.ts +128 -0
  560. package/src/testing/handoff-recorder.ts +98 -0
  561. package/src/testing/index.ts +4 -0
  562. package/src/testing/native.ts +386 -0
  563. package/src/testing/presentation.ts +46 -0
  564. package/src/testing/replay.ts +149 -0
  565. package/src/testing/scroll-handoff-native.ts +201 -0
  566. package/src/testing/scroll-handoff.ts +140 -0
  567. package/src/testing/sensors.ts +41 -0
  568. package/src/testing/trace.ts +340 -0
  569. package/src/timed-animation.ts +192 -0
  570. package/src/track.ts +334 -38
  571. package/src/transition.ts +197 -9
  572. package/src/types.ts +11 -1
  573. package/src/value-observers.ts +147 -0
  574. package/src/value-track.ts +71 -0
  575. package/src/vue/index.ts +147 -1
  576. package/src/zoomable.ts +1 -1
@@ -0,0 +1,214 @@
1
+ import {
2
+ Application,
3
+ Screen,
4
+ Utils,
5
+ isIOS,
6
+ type ScrollView,
7
+ type View,
8
+ } from '@nativescript/core'
9
+
10
+ function firstResponder(view: UIView): UIView | undefined {
11
+ if (view.isFirstResponder) return view
12
+ for (let i = 0; i < view.subviews.count; i++) {
13
+ const found = firstResponder(view.subviews.objectAtIndex(i))
14
+ if (found) return found
15
+ }
16
+ return undefined
17
+ }
18
+
19
+ export function windowHeight(view: View): number {
20
+ if (isIOS)
21
+ return (
22
+ (view.nativeViewProtected as UIView)?.window?.bounds.size.height ??
23
+ Screen.mainScreen.heightDIPs
24
+ )
25
+ const activity =
26
+ Application.android.foregroundActivity ?? Application.android.startActivity
27
+ if (android.os.Build.VERSION.SDK_INT >= 30 && activity)
28
+ return (
29
+ activity.getWindowManager().getCurrentWindowMetrics().getBounds().height() /
30
+ Utils.layout.getDisplayDensity()
31
+ )
32
+ return Screen.mainScreen.heightDIPs
33
+ }
34
+
35
+ export function captureFocus(panel: View, returnFocus?: View): () => void {
36
+ if (returnFocus)
37
+ return () => {
38
+ if (!returnFocus.isLoaded) return
39
+ returnFocus.focus()
40
+ returnFocus.accessibilityScreenChanged()
41
+ }
42
+ if (isIOS) {
43
+ const window = (panel.nativeViewProtected as UIView)?.window
44
+ const responder = window ? firstResponder(window) : undefined
45
+ const accessible = UIAccessibilityFocusedElement(null)
46
+ return () => {
47
+ if (responder?.window) responder.becomeFirstResponder()
48
+ UIAccessibilityPostNotification(
49
+ UIAccessibilityLayoutChangedNotification,
50
+ accessible ?? responder ?? null,
51
+ )
52
+ }
53
+ }
54
+ const activity =
55
+ Application.android.foregroundActivity ?? Application.android.startActivity
56
+ const previous = activity?.getCurrentFocus()
57
+ return () => {
58
+ if (previous?.isAttachedToWindow()) {
59
+ previous.requestFocus()
60
+ previous.sendAccessibilityEvent(
61
+ android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED,
62
+ )
63
+ }
64
+ }
65
+ }
66
+
67
+ export function revealFocusedField(panel: View, scroll?: ScrollView): void {
68
+ if (!scroll?.nativeViewProtected || !panel.nativeViewProtected) return
69
+ if (isIOS) {
70
+ const focused = firstResponder(panel.nativeViewProtected as UIView)
71
+ const native = scroll.nativeViewProtected as UIScrollView
72
+ if (focused?.isDescendantOfView(native))
73
+ native.scrollRectToVisibleAnimated(
74
+ focused.convertRectToView(focused.bounds, native),
75
+ false,
76
+ )
77
+ } else {
78
+ const focused = (panel.nativeViewProtected as android.view.View).findFocus()
79
+ if (focused)
80
+ focused.requestRectangleOnScreen(
81
+ new android.graphics.Rect(0, 0, focused.getWidth(), focused.getHeight()),
82
+ true,
83
+ )
84
+ }
85
+ }
86
+
87
+ export function dismissKeyboard(panel: View): void {
88
+ if (!panel.nativeViewProtected) return
89
+ if (isIOS) (panel.nativeViewProtected as UIView).endEditing(true)
90
+ else {
91
+ const focused = (panel.nativeViewProtected as android.view.View).findFocus()
92
+ if (focused) {
93
+ const manager = focused
94
+ .getContext()
95
+ .getSystemService(
96
+ android.content.Context.INPUT_METHOD_SERVICE,
97
+ ) as android.view.inputmethod.InputMethodManager
98
+ manager.hideSoftInputFromWindow(focused.getWindowToken(), 0)
99
+ focused.clearFocus()
100
+ }
101
+ }
102
+ }
103
+
104
+ /** Add only our actions; preserve an application's existing native accessibility actions. */
105
+ export function sheetActions(
106
+ handle: View,
107
+ actions: readonly { label: string; run(): void }[],
108
+ ): () => void {
109
+ if (isIOS) {
110
+ const native = handle.nativeViewProtected as UIView
111
+ const previous = native.accessibilityCustomActions
112
+ const own = actions.map(({ label, run }) =>
113
+ UIAccessibilityCustomAction.alloc().initWithNameActionHandler(label, () => {
114
+ run()
115
+ return true
116
+ }),
117
+ )
118
+ const existing: UIAccessibilityCustomAction[] = []
119
+ if (previous)
120
+ for (let i = 0; i < previous.count; i++) existing.push(previous.objectAtIndex(i))
121
+ native.accessibilityCustomActions = NSArray.arrayWithArray([...existing, ...own])
122
+ return () => {
123
+ const current = native.accessibilityCustomActions
124
+ const retained: UIAccessibilityCustomAction[] = []
125
+ if (current)
126
+ for (let i = 0; i < current.count; i++) {
127
+ const action = current.objectAtIndex(i)
128
+ if (!own.includes(action)) retained.push(action)
129
+ }
130
+ native.accessibilityCustomActions = retained.length
131
+ ? NSArray.arrayWithArray(retained)
132
+ : null
133
+ }
134
+ }
135
+ const native = handle.nativeViewProtected as android.view.View
136
+ const compat = androidx.core.view.ViewCompat
137
+ const ids: number[] = []
138
+ let ended = false,
139
+ timer: ReturnType<typeof setTimeout> | undefined
140
+ // Core batches accessibility-style updates in a microtask and installs its delegate.
141
+ // Wrap that delegate afterwards, retaining its semantics and all existing actions.
142
+ const repair = () => {
143
+ if (ended || handle.nativeViewProtected !== native) return
144
+ compat.setAccessibilityDelegate(
145
+ native,
146
+ compat.getAccessibilityDelegate(native) ??
147
+ new androidx.core.view.AccessibilityDelegateCompat(),
148
+ )
149
+ if (ids.length) return
150
+ const node = native.createAccessibilityNodeInfo(),
151
+ existing = node.getActionList()
152
+ const used = new Set<number>()
153
+ for (let index = 0; index < existing.size(); index++)
154
+ used.add(existing.get(index).getId())
155
+ node.recycle()
156
+ const resources = native.getResources(),
157
+ packageName = native.getContext().getPackageName()
158
+ const available: number[] = []
159
+ for (let index = 0; index < 32; index++) {
160
+ const id = resources.getIdentifier(
161
+ `accessibility_custom_action_${index}`,
162
+ 'id',
163
+ packageName,
164
+ )
165
+ if (id && !used.has(id)) available.push(id)
166
+ }
167
+ if (available.length < actions.length)
168
+ throw new Error(
169
+ 'Not enough free Android accessibility actions for the sheet handle.',
170
+ )
171
+ for (let index = 0; index < actions.length; index++) {
172
+ const { label, run } = actions[index]!,
173
+ id = available[index]!
174
+ const action =
175
+ new androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat(
176
+ id,
177
+ label,
178
+ )
179
+ compat.replaceAccessibilityAction(
180
+ native,
181
+ action,
182
+ label,
183
+ new androidx.core.view.accessibility.AccessibilityViewCommand({
184
+ perform: () => {
185
+ run()
186
+ return true
187
+ },
188
+ }),
189
+ )
190
+ ids.push(id)
191
+ }
192
+ }
193
+ const schedule = () => {
194
+ if (ended || timer !== undefined) return
195
+ timer = setTimeout(() => {
196
+ timer = undefined
197
+ repair()
198
+ }, 0)
199
+ }
200
+ const changes = [
201
+ 'accessibleChange',
202
+ 'accessibilityRoleChange',
203
+ 'accessibilityStateChange',
204
+ 'accessibilityMediaSessionChange',
205
+ ]
206
+ for (const event of changes) handle.style.on(event, schedule)
207
+ schedule()
208
+ return () => {
209
+ ended = true
210
+ if (timer !== undefined) clearTimeout(timer)
211
+ for (const event of changes) handle.style.off(event, schedule)
212
+ ids.forEach((id) => compat.removeAccessibilityAction(native, id))
213
+ }
214
+ }
package/src/config.ts CHANGED
@@ -11,6 +11,9 @@ export interface JoltConfig {
11
11
  }
12
12
 
13
13
  const settings: Required<JoltConfig> = { timeScale: 1, reducedMotion: 'user' }
14
+ const listeners = new Set<(reduced: boolean) => void>()
15
+ let reported = false
16
+ let unwatch: (() => void) | undefined
14
17
  const preferences: readonly JoltConfig['reducedMotion'][] = ['user', 'always', 'never']
15
18
 
16
19
  /**
@@ -32,7 +35,10 @@ export function configure(options: JoltConfig): void {
32
35
  `Reduced motion must be 'user', 'always' or 'never', got ${String(reducedMotion)}.`,
33
36
  )
34
37
  if (timeScale !== undefined) settings.timeScale = timeScale
35
- if (reducedMotion !== undefined) settings.reducedMotion = reducedMotion
38
+ if (reducedMotion !== undefined) {
39
+ settings.reducedMotion = reducedMotion
40
+ changed()
41
+ }
36
42
  }
37
43
 
38
44
  export function timeScale(): number {
@@ -44,3 +50,35 @@ export function reducedMotion(): boolean {
44
50
  if (settings.reducedMotion === 'user') return getDriver().reducedMotion?.() ?? false
45
51
  return settings.reducedMotion === 'always'
46
52
  }
53
+
54
+ /**
55
+ * Calls back with the new value whenever `reducedMotion()` changes, from `configure()`
56
+ * or the platform setting. Returns a cleanup function.
57
+ *
58
+ * ```ts
59
+ * const off = onReducedMotion((reduced) => (illustration.visibility = reduced ? 'visible' : 'collapse'))
60
+ * ```
61
+ */
62
+ export function onReducedMotion(callback: (reduced: boolean) => void): () => void {
63
+ if (typeof callback !== 'function')
64
+ throw new TypeError('onReducedMotion() takes a callback.')
65
+ const listener = (reduced: boolean) => callback(reduced)
66
+ if (listeners.size === 0) {
67
+ reported = reducedMotion()
68
+ unwatch = getDriver().watchReducedMotion?.(changed)
69
+ }
70
+ listeners.add(listener)
71
+ return () => {
72
+ if (!listeners.delete(listener) || listeners.size > 0) return
73
+ unwatch?.()
74
+ unwatch = undefined
75
+ }
76
+ }
77
+
78
+ function changed() {
79
+ if (listeners.size === 0) return
80
+ const reduced = reducedMotion()
81
+ if (reduced === reported) return
82
+ reported = reduced
83
+ for (const listener of [...listeners]) listener(reduced)
84
+ }
package/src/decay.ts CHANGED
@@ -3,6 +3,7 @@ export interface DecayMotion {
3
3
  to: number
4
4
  position(time: number): number
5
5
  velocity(time: number): number
6
+ interpolationError(start: number, end: number): number
6
7
  }
7
8
 
8
9
  /** Velocity retains this fraction every millisecond, independently of the display's refresh rate. */
@@ -41,5 +42,13 @@ export function solveDecay(
41
42
  time >= duration ? to : from - distance * Math.expm1(-rate * Math.max(0, time)),
42
43
  velocity: (time) =>
43
44
  time >= duration ? 0 : velocity * Math.exp(-rate * Math.max(0, time)),
45
+ interpolationError: (start, end) =>
46
+ (Math.abs(distance) *
47
+ rate *
48
+ rate *
49
+ Math.exp(-rate * Math.max(0, start)) *
50
+ (end - start) ** 2) /
51
+ 8 +
52
+ (end >= duration ? Math.abs(distance) * Math.exp(-rate * duration) : 0),
44
53
  }
45
54
  }
package/src/drag.ts CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  type TouchGestureEventData,
6
6
  type View,
7
7
  } from '@nativescript/core'
8
- import { stop, toView } from './animate.js'
8
+ import { toView } from './animate.js'
9
9
  import { DEFAULT_FRICTION } from './decay.js'
10
10
  import { DragInput } from './drag-input.js'
11
11
  import {
@@ -15,9 +15,18 @@ import {
15
15
  solveDragRelease,
16
16
  type DragCurve,
17
17
  } from './drag-physics.js'
18
- import { currentValue, ViewAnimation, type Plan } from './engine.js'
18
+ import {
19
+ baseValue,
20
+ currentValue,
21
+ setBase,
22
+ stopBase,
23
+ ViewAnimation,
24
+ type Animation,
25
+ type Plan,
26
+ } from './engine.js'
27
+ import { asRoot, isMotionValue, type MotionValue } from './motion-value.js'
19
28
  import type { PlaybackAnimation } from './playback.js'
20
- import { readValue, writeValue } from './properties.js'
29
+ import { createTrack } from './track.js'
21
30
  import type { Target } from './types.js'
22
31
 
23
32
  export interface DragPoint {
@@ -29,10 +38,10 @@ export interface DragEvent extends DragPoint {
29
38
  readonly velocityX: number
30
39
  readonly velocityY: number
31
40
  }
32
- export interface DragRelease extends DragEvent {
41
+ export interface DragRelease<A extends Animation = PlaybackAnimation> extends DragEvent {
33
42
  readonly target: DragPoint
34
43
  /** False on interruption/cancellation. Check before applying completion effects. */
35
- readonly animation: PlaybackAnimation
44
+ readonly animation: A
36
45
  }
37
46
  export interface DragOptions {
38
47
  /** Defaults to both. One finger only. */
@@ -51,6 +60,17 @@ export interface DragOptions {
51
60
  onCancel?: (event: DragEvent) => void
52
61
  onSettle?: (position: DragPoint) => void
53
62
  }
63
+ /** Drags a motion value instead of the view. Bounds and snap points are in the value's units. */
64
+ export interface DragValueOptions extends Omit<
65
+ DragOptions,
66
+ 'axis' | 'snap' | 'onRelease'
67
+ > {
68
+ /** Takes the position on every move and plays the release; bind views to it to follow. */
69
+ value: MotionValue
70
+ axis: 'x' | 'y'
71
+ snap?: readonly number[]
72
+ onRelease?: (event: DragRelease<Animation>) => void
73
+ }
54
74
  export interface Drag {
55
75
  readonly dragging: boolean
56
76
  readonly settling: boolean
@@ -67,22 +87,28 @@ export interface Drag {
67
87
  }
68
88
 
69
89
  type Axis = 'x' | 'y'
90
+ type Root = ReturnType<typeof asRoot>
70
91
  interface Settings {
71
92
  axes: Axis[]
72
93
  curves: Record<Axis, DragCurve>
73
- callbacks: Pick<
74
- DragOptions,
75
- 'onStart' | 'onMove' | 'onRelease' | 'onCancel' | 'onSettle'
76
- >
94
+ value: Root | undefined
95
+ callbacks: Pick<DragOptions, 'onStart' | 'onMove' | 'onCancel' | 'onSettle'> & {
96
+ onRelease?: (event: DragRelease<Animation>) => void
97
+ }
77
98
  }
78
99
  const owners = new WeakMap<View, Drag>()
79
100
 
80
- function settings(options: DragOptions): Settings {
101
+ function settings(options: DragOptions | DragValueOptions): Settings {
81
102
  if (!options || typeof options !== 'object')
82
103
  throw new TypeError('Drag options must be an object.')
83
104
  const axis = options.axis ?? 'both'
84
105
  if (!['x', 'y', 'both'].includes(axis))
85
106
  throw new TypeError('Drag axis must be x, y or both.')
107
+ const value = 'value' in options ? options.value : undefined
108
+ if (value !== undefined && !isMotionValue(value))
109
+ throw new TypeError('Drag value must be a motion value.')
110
+ if (value !== undefined && axis === 'both')
111
+ throw new TypeError('Dragging a motion value needs axis "x" or "y".')
86
112
  const friction = options.friction ?? DEFAULT_FRICTION
87
113
  if (!Number.isFinite(friction) || friction <= 0 || friction >= 1)
88
114
  throw new RangeError('Drag friction must be between 0 and 1 exclusively.')
@@ -152,18 +178,23 @@ function settings(options: DragOptions): Settings {
152
178
  const callbacks = {
153
179
  onStart: options.onStart,
154
180
  onMove: options.onMove,
155
- onRelease: options.onRelease,
181
+ onRelease: options.onRelease as Settings['callbacks']['onRelease'],
156
182
  onCancel: options.onCancel,
157
183
  onSettle: options.onSettle,
158
184
  }
159
185
  for (const callback of Object.values(callbacks))
160
186
  if (callback !== undefined && typeof callback !== 'function')
161
187
  throw new TypeError('Drag callbacks must be functions.')
162
- return { axes, curves, callbacks }
188
+ return { axes, curves, value: value && asRoot(value), callbacks }
163
189
  }
164
190
 
165
- /** Main-thread pan updates; release physics play through Jolt's native animation drivers. */
166
- export function drag(target: Target, options: DragOptions = {}): Drag {
191
+ /**
192
+ * Main-thread pan updates; release physics play through Jolt's native animation drivers.
193
+ * With `value`, the gesture drives a motion value and the views bound to it.
194
+ */
195
+ export function drag(target: Target, options: DragValueOptions): Drag
196
+ export function drag(target: Target, options?: DragOptions): Drag
197
+ export function drag(target: Target, options: DragOptions | DragValueOptions = {}): Drag {
167
198
  const view = toView(target)
168
199
  const config = settings(options) // Invalid replacements leave the existing owner intact.
169
200
  const previous = owners.get(view)
@@ -187,7 +218,7 @@ class DragController implements Drag {
187
218
  private attached = false
188
219
  private blocked = false
189
220
  private generation = 0
190
- private release: PlaybackAnimation | undefined
221
+ private release: Animation | undefined
191
222
  private input = new DragInput()
192
223
  private origin = { x: 0, y: 0 }
193
224
  private last: DragEvent = { x: 0, y: 0, velocityX: 0, velocityY: 0 }
@@ -215,6 +246,8 @@ class DragController implements Drag {
215
246
  return this.destroyed
216
247
  }
217
248
  get position(): DragPoint {
249
+ const value = this.config.value
250
+ if (value) return { x: 0, y: 0, [this.config.axes[0]!]: value.base() }
218
251
  return { x: currentValue(this.view, 'x'), y: currentValue(this.view, 'y') }
219
252
  }
220
253
  cancel = () => {
@@ -303,9 +336,15 @@ class DragController implements Drag {
303
336
  this.cancel()
304
337
  if (!this.attached || this.destroyed || this.disabled) return
305
338
  this.blocked = false
306
- // Claim just the enabled axes, preserving the native presentation on takeover.
307
- stop(this.view, this.config.axes)
308
- this.origin = { x: readValue(this.view, 'x'), y: readValue(this.view, 'y') }
339
+ const value = this.config.value
340
+ if (value) {
341
+ value.stopBase()
342
+ this.origin = this.position
343
+ } else {
344
+ // Claim just the enabled axes, preserving the native presentation on takeover.
345
+ stopBase(this.view, this.config.axes)
346
+ this.origin = { x: baseValue(this.view, 'x'), y: baseValue(this.view, 'y') }
347
+ }
309
348
  const size =
310
349
  (this.view.parent as View | undefined)?.getActualSize() ??
311
350
  this.view.getActualSize()
@@ -346,8 +385,11 @@ class DragController implements Drag {
346
385
  : clampDrag(raw, curve.bounds)
347
386
  if (axis === 'x') vx = input.velocityX * resistance
348
387
  else vy = input.velocityY * resistance
349
- stop(this.view, [axis])
350
- writeValue(this.view, axis, position[axis])
388
+ if (this.config.value) this.config.value.setBase(position[axis])
389
+ else {
390
+ stopBase(this.view, [axis])
391
+ setBase(this.view, axis, position[axis])
392
+ }
351
393
  }
352
394
  this.last = { ...position, velocityX: vx, velocityY: vy }
353
395
  if (event.state !== 3)
@@ -383,7 +425,11 @@ class DragController implements Drag {
383
425
  transition: { curve, delay: 0, repeat: 0, reverse: false },
384
426
  }
385
427
  })
386
- const animation = new ViewAnimation(this.view, plans)
428
+ const [axis] = this.config.axes
429
+ const value = this.config.value
430
+ const animation = value
431
+ ? value.playTrack(createTrack(axis!, [event[axis!]], plans[0]!.transition, 0))
432
+ : new ViewAnimation(this.view, plans)
387
433
  this.release = animation
388
434
  void animation.finished.then((finished) => {
389
435
  if (generation !== this.generation || this.destroyed) return
@@ -0,0 +1,116 @@
1
+ import { Utils, type View } from '@nativescript/core'
2
+ import type { GradientFrame, GradientPainter, GradientType } from '../gradient.js'
3
+
4
+ const floats = (values: readonly number[]) => {
5
+ const array = Array.create('float', values.length)
6
+ values.forEach((value, i) => (array[i] = value))
7
+ return array
8
+ }
9
+ const ints = (values: readonly number[]) => {
10
+ const array = Array.create('int', values.length)
11
+ values.forEach((value, i) => (array[i] = value | 0))
12
+ return array
13
+ }
14
+
15
+ /** A gradient drawable stacked on the view's own background: above its color, below its children. */
16
+ export function androidGradient(
17
+ view: View,
18
+ type: GradientType,
19
+ ): GradientPainter | undefined {
20
+ let layer: org.rafaelaugusto.jolt.GradientLayer
21
+ try {
22
+ layer = new org.rafaelaugusto.jolt.GradientLayer(
23
+ type === 'linear' ? 0 : type === 'radial' ? 1 : 2,
24
+ )
25
+ } catch {
26
+ // A JS-only update cannot install the native plugin.
27
+ return undefined
28
+ }
29
+ let stack: android.graphics.drawable.LayerDrawable | undefined
30
+ let queued = false
31
+ let removed = false
32
+
33
+ const wrap = () => {
34
+ if (removed) return
35
+ const native = view.nativeViewProtected as android.view.View | undefined
36
+ if (!native) return
37
+ const corner = typeof view.borderRadius === 'number' ? view.borderRadius : 0
38
+ layer.setCorner(corner * Utils.layout.getDisplayDensity())
39
+ const background = native.getBackground()
40
+ if (stack && background === stack) return
41
+ const layers = Array.create(android.graphics.drawable.Drawable, 2)
42
+ layers[0] = background ?? new android.graphics.drawable.ColorDrawable(0)
43
+ layers[1] = layer
44
+ stack = new android.graphics.drawable.LayerDrawable(layers)
45
+ native.setBackground(stack)
46
+ }
47
+ // Core replaces the background drawable when its style changes; stack on the new one.
48
+ const rewrap = () => {
49
+ if (queued) return
50
+ queued = true
51
+ void Promise.resolve().then(() => {
52
+ queued = false
53
+ wrap()
54
+ })
55
+ }
56
+ view.on('loaded', wrap)
57
+ view.style.on('backgroundInternalChange', rewrap)
58
+ view.style.on('borderTopLeftRadiusChange', rewrap)
59
+ wrap()
60
+
61
+ return {
62
+ paint(frame: GradientFrame) {
63
+ layer.paint(
64
+ ints(frame.colors),
65
+ floats(frame.stops),
66
+ frame.angle,
67
+ frame.x,
68
+ frame.y,
69
+ frame.radius,
70
+ )
71
+ },
72
+ play(frames, times, timing, onEnd) {
73
+ let active = true
74
+ layer.play(
75
+ floats(times),
76
+ ints(frames.flatMap((frame) => frame.colors)),
77
+ floats(frames.flatMap((frame) => frame.stops)),
78
+ floats(frames.flatMap((frame) => [frame.angle, frame.x, frame.y, frame.radius])),
79
+ Math.round(timing.duration),
80
+ Math.round(timing.delay),
81
+ timing.repeat === Infinity ? -1 : timing.repeat,
82
+ timing.reverse,
83
+ new org.rafaelaugusto.jolt.GradientLayer.Listener({
84
+ onEnd: (finished: boolean) => {
85
+ if (!active) return
86
+ active = false
87
+ onEnd(finished)
88
+ },
89
+ }),
90
+ )
91
+ return {
92
+ control(elapsed, paused) {
93
+ if (active) layer.control(Math.round(elapsed), paused)
94
+ },
95
+ cancel() {
96
+ if (!active) return
97
+ active = false
98
+ layer.cancel()
99
+ onEnd(false)
100
+ },
101
+ }
102
+ },
103
+ remove() {
104
+ if (removed) return
105
+ removed = true
106
+ view.off('loaded', wrap)
107
+ view.style.off('backgroundInternalChange', rewrap)
108
+ view.style.off('borderTopLeftRadiusChange', rewrap)
109
+ layer.dispose()
110
+ const native = view.nativeViewProtected as android.view.View | undefined
111
+ if (native && stack && native.getBackground() === stack)
112
+ native.setBackground(stack.getDrawable(0))
113
+ stack = undefined
114
+ },
115
+ }
116
+ }