@rafaelaugusto/jolt 0.1.0-beta.8 → 0.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -15
- package/dist/animate.d.ts +25 -4
- package/dist/animate.d.ts.map +1 -1
- package/dist/animate.js +67 -26
- package/dist/animate.js.map +1 -1
- package/dist/blur/index.d.ts +6 -0
- package/dist/blur/index.d.ts.map +1 -0
- package/dist/blur/index.js +196 -0
- package/dist/blur/index.js.map +1 -0
- package/dist/blur/native.d.ts +17 -0
- package/dist/blur/native.d.ts.map +1 -0
- package/dist/blur/native.js +44 -0
- package/dist/blur/native.js.map +1 -0
- package/dist/blur/types.d.ts +32 -0
- package/dist/blur/types.d.ts.map +1 -0
- package/dist/blur/types.js +2 -0
- package/dist/blur/types.js.map +1 -0
- package/dist/bottom-sheet/geometry.d.ts +18 -0
- package/dist/bottom-sheet/geometry.d.ts.map +1 -0
- package/dist/bottom-sheet/geometry.js +51 -0
- package/dist/bottom-sheet/geometry.js.map +1 -0
- package/dist/bottom-sheet/index.d.ts +56 -0
- package/dist/bottom-sheet/index.d.ts.map +1 -0
- package/dist/bottom-sheet/index.js +462 -0
- package/dist/bottom-sheet/index.js.map +1 -0
- package/dist/bottom-sheet/native.d.ts +11 -0
- package/dist/bottom-sheet/native.d.ts.map +1 -0
- package/dist/bottom-sheet/native.js +173 -0
- package/dist/bottom-sheet/native.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +40 -1
- package/dist/config.js.map +1 -1
- package/dist/decay.d.ts +1 -0
- package/dist/decay.d.ts.map +1 -1
- package/dist/decay.js +7 -0
- package/dist/decay.js.map +1 -1
- package/dist/drag-physics.d.ts +6 -1
- package/dist/drag-physics.d.ts.map +1 -1
- package/dist/drag.d.ts +17 -3
- package/dist/drag.d.ts.map +1 -1
- package/dist/drag.js +34 -11
- package/dist/drag.js.map +1 -1
- package/dist/driver/android-gradient.d.ts +5 -0
- package/dist/driver/android-gradient.d.ts.map +1 -0
- package/dist/driver/android-gradient.js +99 -0
- package/dist/driver/android-gradient.js.map +1 -0
- package/dist/driver/android-particles.d.ts +6 -0
- package/dist/driver/android-particles.d.ts.map +1 -0
- package/dist/driver/android-particles.js +93 -0
- package/dist/driver/android-particles.js.map +1 -0
- package/dist/driver/android.d.ts.map +1 -1
- package/dist/driver/android.js +67 -1
- package/dist/driver/android.js.map +1 -1
- package/dist/driver/frame.d.ts +3 -0
- package/dist/driver/frame.d.ts.map +1 -0
- package/dist/driver/frame.js +7 -0
- package/dist/driver/frame.js.map +1 -0
- package/dist/driver/index.d.ts +14 -0
- package/dist/driver/index.d.ts.map +1 -1
- package/dist/driver/index.js.map +1 -1
- package/dist/driver/ios-gradient.d.ts +5 -0
- package/dist/driver/ios-gradient.d.ts.map +1 -0
- package/dist/driver/ios-gradient.js +131 -0
- package/dist/driver/ios-gradient.js.map +1 -0
- package/dist/driver/ios-layout.d.ts +9 -0
- package/dist/driver/ios-layout.d.ts.map +1 -0
- package/dist/driver/ios-layout.js +52 -0
- package/dist/driver/ios-layout.js.map +1 -0
- package/dist/driver/ios-scroll-delegate.d.ts +4 -0
- package/dist/driver/ios-scroll-delegate.d.ts.map +1 -0
- package/dist/driver/ios-scroll-delegate.js +26 -0
- package/dist/driver/ios-scroll-delegate.js.map +1 -0
- package/dist/driver/ios.d.ts.map +1 -1
- package/dist/driver/ios.js +57 -1
- package/dist/driver/ios.js.map +1 -1
- package/dist/easing.d.ts +3 -1
- package/dist/easing.d.ts.map +1 -1
- package/dist/easing.js +18 -1
- package/dist/easing.js.map +1 -1
- package/dist/engine.d.ts +35 -2
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +211 -42
- package/dist/engine.js.map +1 -1
- package/dist/gesture-native.d.ts +28 -0
- package/dist/gesture-native.d.ts.map +1 -0
- package/dist/gesture-native.js +61 -0
- package/dist/gesture-native.js.map +1 -0
- package/dist/gestures/index.d.ts +69 -0
- package/dist/gestures/index.d.ts.map +1 -0
- package/dist/gestures/index.js +262 -0
- package/dist/gestures/index.js.map +1 -0
- package/dist/glass/index.d.ts +55 -0
- package/dist/glass/index.d.ts.map +1 -0
- package/dist/glass/index.js +205 -0
- package/dist/glass/index.js.map +1 -0
- package/dist/gradient-binding.d.ts +38 -0
- package/dist/gradient-binding.d.ts.map +1 -0
- package/dist/gradient-binding.js +128 -0
- package/dist/gradient-binding.js.map +1 -0
- package/dist/gradient.d.ts +105 -0
- package/dist/gradient.d.ts.map +1 -0
- package/dist/gradient.js +514 -0
- package/dist/gradient.js.map +1 -0
- package/dist/gravity.d.ts +13 -0
- package/dist/gravity.d.ts.map +1 -0
- package/dist/gravity.js +84 -0
- package/dist/gravity.js.map +1 -0
- package/dist/haptics.d.ts.map +1 -1
- package/dist/haptics.js +101 -28
- package/dist/haptics.js.map +1 -1
- package/dist/image-effect.d.ts +1 -0
- package/dist/image-effect.d.ts.map +1 -1
- package/dist/image-effect.js +10 -2
- package/dist/image-effect.js.map +1 -1
- package/dist/index.d.ts +21 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/inspector/index.d.ts +86 -0
- package/dist/inspector/index.d.ts.map +1 -0
- package/dist/inspector/index.js +419 -0
- package/dist/inspector/index.js.map +1 -0
- package/dist/inspector/plot.d.ts +4 -0
- package/dist/inspector/plot.d.ts.map +1 -0
- package/dist/inspector/plot.js +23 -0
- package/dist/inspector/plot.js.map +1 -0
- package/dist/inspector/probe.d.ts +19 -0
- package/dist/inspector/probe.d.ts.map +1 -0
- package/dist/inspector/probe.js +37 -0
- package/dist/inspector/probe.js.map +1 -0
- package/dist/inspector/tuning.d.ts +19 -0
- package/dist/inspector/tuning.d.ts.map +1 -0
- package/dist/inspector/tuning.js +37 -0
- package/dist/inspector/tuning.js.map +1 -0
- package/dist/interactive-navigation/index.d.ts +44 -0
- package/dist/interactive-navigation/index.d.ts.map +1 -0
- package/dist/interactive-navigation/index.js +314 -0
- package/dist/interactive-navigation/index.js.map +1 -0
- package/dist/keyboard.d.ts +24 -0
- package/dist/keyboard.d.ts.map +1 -1
- package/dist/keyboard.js +199 -6
- package/dist/keyboard.js.map +1 -1
- package/dist/layout.d.ts +13 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +348 -0
- package/dist/layout.js.map +1 -0
- package/dist/live-spring-driver.d.ts +52 -0
- package/dist/live-spring-driver.d.ts.map +1 -0
- package/dist/live-spring-driver.js +104 -0
- package/dist/live-spring-driver.js.map +1 -0
- package/dist/mixer.d.ts +55 -0
- package/dist/mixer.d.ts.map +1 -0
- package/dist/mixer.js +278 -0
- package/dist/mixer.js.map +1 -0
- package/dist/motion-scope.d.ts +10 -2
- package/dist/motion-scope.d.ts.map +1 -1
- package/dist/motion-scope.js +30 -3
- package/dist/motion-scope.js.map +1 -1
- package/dist/motion-states.d.ts +19 -7
- package/dist/motion-states.d.ts.map +1 -1
- package/dist/motion-states.js +116 -26
- package/dist/motion-states.js.map +1 -1
- package/dist/motion-value.d.ts +227 -0
- package/dist/motion-value.d.ts.map +1 -0
- package/dist/motion-value.js +1074 -0
- package/dist/motion-value.js.map +1 -0
- package/dist/native/index.d.ts +10 -0
- package/dist/native/index.d.ts.map +1 -0
- package/dist/native/index.js +6 -0
- package/dist/native/index.js.map +1 -0
- package/dist/native-properties.d.ts +28 -0
- package/dist/native-properties.d.ts.map +1 -0
- package/dist/native-properties.js +154 -0
- package/dist/native-properties.js.map +1 -0
- package/dist/native-property-driver.d.ts +19 -0
- package/dist/native-property-driver.d.ts.map +1 -0
- package/dist/native-property-driver.js +69 -0
- package/dist/native-property-driver.js.map +1 -0
- package/dist/native-property.d.ts +37 -0
- package/dist/native-property.d.ts.map +1 -0
- package/dist/native-property.js +285 -0
- package/dist/native-property.js.map +1 -0
- package/dist/particles.d.ts +5 -2
- package/dist/particles.d.ts.map +1 -1
- package/dist/particles.js +16 -10
- package/dist/particles.js.map +1 -1
- package/dist/path.d.ts.map +1 -1
- package/dist/path.js +2 -2
- package/dist/path.js.map +1 -1
- package/dist/physics/index.d.ts +116 -0
- package/dist/physics/index.d.ts.map +1 -0
- package/dist/physics/index.js +306 -0
- package/dist/physics/index.js.map +1 -0
- package/dist/physics/native.d.ts +53 -0
- package/dist/physics/native.d.ts.map +1 -0
- package/dist/physics/native.js +58 -0
- package/dist/physics/native.js.map +1 -0
- package/dist/playback-group.d.ts.map +1 -1
- package/dist/playback-group.js +17 -1
- package/dist/playback-group.js.map +1 -1
- package/dist/playback.d.ts +15 -0
- package/dist/playback.d.ts.map +1 -1
- package/dist/playback.js +23 -0
- package/dist/playback.js.map +1 -1
- package/dist/predictive-back/index.d.ts +45 -0
- package/dist/predictive-back/index.d.ts.map +1 -0
- package/dist/predictive-back/index.js +220 -0
- package/dist/predictive-back/index.js.map +1 -0
- package/dist/predictive-back/presentation.d.ts +4 -0
- package/dist/predictive-back/presentation.d.ts.map +1 -0
- package/dist/predictive-back/presentation.js +3 -0
- package/dist/predictive-back/presentation.js.map +1 -0
- package/dist/reorder/handle.d.ts +6 -0
- package/dist/reorder/handle.d.ts.map +1 -0
- package/dist/reorder/handle.js +10 -0
- package/dist/reorder/handle.js.map +1 -0
- package/dist/reorder/index.d.ts +10 -0
- package/dist/reorder/index.d.ts.map +1 -0
- package/dist/reorder/index.js +233 -0
- package/dist/reorder/index.js.map +1 -0
- package/dist/reorder/list-view.d.ts +5 -0
- package/dist/reorder/list-view.d.ts.map +1 -0
- package/dist/reorder/list-view.js +238 -0
- package/dist/reorder/list-view.js.map +1 -0
- package/dist/reorder/model.d.ts +6 -0
- package/dist/reorder/model.d.ts.map +1 -0
- package/dist/reorder/model.js +30 -0
- package/dist/reorder/model.js.map +1 -0
- package/dist/reorder/surface.d.ts +6 -0
- package/dist/reorder/surface.d.ts.map +1 -0
- package/dist/reorder/surface.js +10 -0
- package/dist/reorder/surface.js.map +1 -0
- package/dist/reorder/types.d.ts +92 -0
- package/dist/reorder/types.d.ts.map +1 -0
- package/dist/reorder/types.js +2 -0
- package/dist/reorder/types.js.map +1 -0
- package/dist/sampling.d.ts +35 -0
- package/dist/sampling.d.ts.map +1 -0
- package/dist/sampling.js +123 -0
- package/dist/sampling.js.map +1 -0
- package/dist/scene-appearance.d.ts +14 -0
- package/dist/scene-appearance.d.ts.map +1 -0
- package/dist/scene-appearance.js +68 -0
- package/dist/scene-appearance.js.map +1 -0
- package/dist/scene-camera.d.ts +5 -0
- package/dist/scene-camera.d.ts.map +1 -0
- package/dist/scene-camera.js +23 -0
- package/dist/scene-camera.js.map +1 -0
- package/dist/scene-shader.d.ts +18 -0
- package/dist/scene-shader.d.ts.map +1 -0
- package/dist/scene-shader.js +76 -0
- package/dist/scene-shader.js.map +1 -0
- package/dist/scroll-header/geometry.d.ts +18 -0
- package/dist/scroll-header/geometry.d.ts.map +1 -0
- package/dist/scroll-header/geometry.js +46 -0
- package/dist/scroll-header/geometry.js.map +1 -0
- package/dist/scroll-header/index.d.ts +48 -0
- package/dist/scroll-header/index.d.ts.map +1 -0
- package/dist/scroll-header/index.js +373 -0
- package/dist/scroll-header/index.js.map +1 -0
- package/dist/scroll-header/native.d.ts +28 -0
- package/dist/scroll-header/native.d.ts.map +1 -0
- package/dist/scroll-header/native.js +43 -0
- package/dist/scroll-header/native.js.map +1 -0
- package/dist/sensors/index.d.ts +69 -0
- package/dist/sensors/index.d.ts.map +1 -0
- package/dist/sensors/index.js +149 -0
- package/dist/sensors/index.js.map +1 -0
- package/dist/sensors/native.d.ts +20 -0
- package/dist/sensors/native.d.ts.map +1 -0
- package/dist/sensors/native.js +48 -0
- package/dist/sensors/native.js.map +1 -0
- package/dist/sequence.d.ts +24 -0
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +181 -19
- package/dist/sequence.js.map +1 -1
- package/dist/shapes/android.d.ts +3 -0
- package/dist/shapes/android.d.ts.map +1 -0
- package/dist/shapes/android.js +51 -0
- package/dist/shapes/android.js.map +1 -0
- package/dist/shapes/index.d.ts +6 -0
- package/dist/shapes/index.d.ts.map +1 -0
- package/dist/shapes/index.js +238 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/ios.d.ts +3 -0
- package/dist/shapes/ios.d.ts.map +1 -0
- package/dist/shapes/ios.js +164 -0
- package/dist/shapes/ios.js.map +1 -0
- package/dist/shapes/native.d.ts +18 -0
- package/dist/shapes/native.d.ts.map +1 -0
- package/dist/shapes/native.js +10 -0
- package/dist/shapes/native.js.map +1 -0
- package/dist/shapes/path.d.ts +10 -0
- package/dist/shapes/path.d.ts.map +1 -0
- package/dist/shapes/path.js +106 -0
- package/dist/shapes/path.js.map +1 -0
- package/dist/shapes/types.d.ts +55 -0
- package/dist/shapes/types.d.ts.map +1 -0
- package/dist/shapes/types.js +11 -0
- package/dist/shapes/types.js.map +1 -0
- package/dist/shared-layout/index.d.ts +40 -0
- package/dist/shared-layout/index.d.ts.map +1 -0
- package/dist/shared-layout/index.js +267 -0
- package/dist/shared-layout/index.js.map +1 -0
- package/dist/shared-layout/native.d.ts +15 -0
- package/dist/shared-layout/native.d.ts.map +1 -0
- package/dist/shared-layout/native.js +79 -0
- package/dist/shared-layout/native.js.map +1 -0
- package/dist/shared-layout/timing.d.ts +9 -0
- package/dist/shared-layout/timing.d.ts.map +1 -0
- package/dist/shared-layout/timing.js +68 -0
- package/dist/shared-layout/timing.js.map +1 -0
- package/dist/shared-navigation/entry.d.ts +51 -0
- package/dist/shared-navigation/entry.d.ts.map +1 -0
- package/dist/shared-navigation/entry.js +619 -0
- package/dist/shared-navigation/entry.js.map +1 -0
- package/dist/shared-navigation/index.d.ts +58 -0
- package/dist/shared-navigation/index.d.ts.map +1 -0
- package/dist/shared-navigation/index.js +318 -0
- package/dist/shared-navigation/index.js.map +1 -0
- package/dist/shared-navigation/return-signal.d.ts +16 -0
- package/dist/shared-navigation/return-signal.d.ts.map +1 -0
- package/dist/shared-navigation/return-signal.js +35 -0
- package/dist/shared-navigation/return-signal.js.map +1 -0
- package/dist/shared-navigation/return-target.d.ts +32 -0
- package/dist/shared-navigation/return-target.d.ts.map +1 -0
- package/dist/shared-navigation/return-target.js +168 -0
- package/dist/shared-navigation/return-target.js.map +1 -0
- package/dist/shared-navigation/scope.d.ts +4 -0
- package/dist/shared-navigation/scope.d.ts.map +1 -0
- package/dist/shared-navigation/scope.js +2 -0
- package/dist/shared-navigation/scope.js.map +1 -0
- package/dist/shared-navigation/targets.d.ts +6 -0
- package/dist/shared-navigation/targets.d.ts.map +1 -0
- package/dist/shared-navigation/targets.js +36 -0
- package/dist/shared-navigation/targets.js.map +1 -0
- package/dist/size-layout.d.ts +19 -0
- package/dist/size-layout.d.ts.map +1 -0
- package/dist/size-layout.js +216 -0
- package/dist/size-layout.js.map +1 -0
- package/dist/size.d.ts +19 -0
- package/dist/size.d.ts.map +1 -0
- package/dist/size.js +251 -0
- package/dist/size.js.map +1 -0
- package/dist/spring.d.ts +2 -0
- package/dist/spring.d.ts.map +1 -1
- package/dist/spring.js +11 -0
- package/dist/spring.js.map +1 -1
- package/dist/svg-path.d.ts +18 -0
- package/dist/svg-path.d.ts.map +1 -1
- package/dist/svg-path.js +3 -2
- package/dist/svg-path.js.map +1 -1
- package/dist/testing/clock.d.ts +40 -0
- package/dist/testing/clock.d.ts.map +1 -0
- package/dist/testing/clock.js +116 -0
- package/dist/testing/clock.js.map +1 -0
- package/dist/testing/handoff-recorder.d.ts +8 -0
- package/dist/testing/handoff-recorder.d.ts.map +1 -0
- package/dist/testing/handoff-recorder.js +77 -0
- package/dist/testing/handoff-recorder.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +5 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/native.d.ts +46 -0
- package/dist/testing/native.d.ts.map +1 -0
- package/dist/testing/native.js +313 -0
- package/dist/testing/native.js.map +1 -0
- package/dist/testing/presentation.d.ts +11 -0
- package/dist/testing/presentation.d.ts.map +1 -0
- package/dist/testing/presentation.js +45 -0
- package/dist/testing/presentation.js.map +1 -0
- package/dist/testing/replay.d.ts +39 -0
- package/dist/testing/replay.d.ts.map +1 -0
- package/dist/testing/replay.js +99 -0
- package/dist/testing/replay.js.map +1 -0
- package/dist/testing/scroll-handoff-native.d.ts +10 -0
- package/dist/testing/scroll-handoff-native.d.ts.map +1 -0
- package/dist/testing/scroll-handoff-native.js +151 -0
- package/dist/testing/scroll-handoff-native.js.map +1 -0
- package/dist/testing/scroll-handoff.d.ts +25 -0
- package/dist/testing/scroll-handoff.d.ts.map +1 -0
- package/dist/testing/scroll-handoff.js +127 -0
- package/dist/testing/scroll-handoff.js.map +1 -0
- package/dist/testing/sensors.d.ts +13 -0
- package/dist/testing/sensors.d.ts.map +1 -0
- package/dist/testing/sensors.js +26 -0
- package/dist/testing/sensors.js.map +1 -0
- package/dist/testing/trace.d.ts +101 -0
- package/dist/testing/trace.d.ts.map +1 -0
- package/dist/testing/trace.js +263 -0
- package/dist/testing/trace.js.map +1 -0
- package/dist/timed-animation.d.ts +38 -0
- package/dist/timed-animation.d.ts.map +1 -0
- package/dist/timed-animation.js +177 -0
- package/dist/timed-animation.js.map +1 -0
- package/dist/track.d.ts +3 -0
- package/dist/track.d.ts.map +1 -1
- package/dist/track.js +281 -40
- package/dist/track.js.map +1 -1
- package/dist/transition.d.ts +54 -2
- package/dist/transition.d.ts.map +1 -1
- package/dist/transition.js +128 -8
- package/dist/transition.js.map +1 -1
- package/dist/types.d.ts +10 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/value-observers.d.ts +22 -0
- package/dist/value-observers.d.ts.map +1 -0
- package/dist/value-observers.js +122 -0
- package/dist/value-observers.js.map +1 -0
- package/dist/value-track.d.ts +13 -0
- package/dist/value-track.d.ts.map +1 -0
- package/dist/value-track.js +59 -0
- package/dist/value-track.js.map +1 -0
- package/dist/vue/index.d.ts +33 -3
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +118 -3
- package/dist/vue/index.js.map +1 -1
- package/dist/zoomable.d.ts +1 -1
- package/dist/zoomable.d.ts.map +1 -1
- package/package.json +68 -3
- package/platforms/android/include.gradle +10 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/BlurEffect.java +89 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/CircleMath.java +151 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/CircleWorld.java +210 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/GestureSession.java +227 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/GestureSurface.java +54 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/GradientLayer.java +224 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardFrame.java +53 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardFrameFollower.java +57 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardObserver.java +97 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/LiveSpring.java +277 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/MotionProbe.java +70 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ParticleEmitter.java +192 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ParticleSimulation.java +114 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/PredictiveBackSession.java +212 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ReorderHandle.java +25 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ReorderSession.java +213 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ReorderSurface.java +27 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ScrollHeader.java +84 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/SensorMath.java +28 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/SensorSource.java +217 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ShapeLayer.java +120 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/SharedLayoutFlight.java +287 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/SharedNavigationScene.java +115 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/SpringState.java +39 -0
- package/platforms/android/proguard-rules.pro +20 -0
- package/platforms/ios/build.xcconfig +1 -1
- package/platforms/ios/src/JoltBlur.h +14 -0
- package/platforms/ios/src/JoltBlur.m +86 -0
- package/platforms/ios/src/JoltCircleMath.h +183 -0
- package/platforms/ios/src/JoltCircleWorld.h +17 -0
- package/platforms/ios/src/JoltCircleWorld.m +203 -0
- package/platforms/ios/src/JoltGestureSession.h +23 -0
- package/platforms/ios/src/JoltGestureSession.m +251 -0
- package/platforms/ios/src/JoltInteractiveNavigation.h +23 -0
- package/platforms/ios/src/JoltInteractiveNavigation.m +255 -0
- package/platforms/ios/src/JoltLiveSpring.h +29 -0
- package/platforms/ios/src/JoltLiveSpring.m +243 -0
- package/platforms/ios/src/JoltMotionProbe.h +9 -0
- package/platforms/ios/src/JoltMotionProbe.m +72 -0
- package/platforms/ios/src/JoltReorderSession.h +15 -0
- package/platforms/ios/src/JoltReorderSession.m +205 -0
- package/platforms/ios/src/JoltScrollHeader.h +13 -0
- package/platforms/ios/src/JoltScrollHeader.m +93 -0
- package/platforms/ios/src/JoltSensorMath.h +39 -0
- package/platforms/ios/src/JoltSensorSource.h +13 -0
- package/platforms/ios/src/JoltSensorSource.m +201 -0
- package/platforms/ios/src/JoltSharedLayoutFlight.h +19 -0
- package/platforms/ios/src/JoltSharedLayoutFlight.m +250 -0
- package/platforms/ios/src/JoltSpringState.h +35 -0
- package/platforms/ios/src/module.modulemap +10 -0
- package/src/android-plugin.d.ts +463 -0
- package/src/animate.ts +129 -15
- package/src/blur/index.ts +195 -0
- package/src/blur/native.ts +70 -0
- package/src/blur/types.ts +32 -0
- package/src/bottom-sheet/geometry.ts +84 -0
- package/src/bottom-sheet/index.ts +536 -0
- package/src/bottom-sheet/native.ts +214 -0
- package/src/config.ts +39 -1
- package/src/decay.ts +9 -0
- package/src/drag.ts +67 -21
- package/src/driver/android-gradient.ts +116 -0
- package/src/driver/android-particles.ts +118 -0
- package/src/driver/android.ts +69 -1
- package/src/driver/frame.ts +10 -0
- package/src/driver/index.ts +15 -0
- package/src/driver/ios-gradient.ts +136 -0
- package/src/driver/ios-layout.ts +63 -0
- package/src/driver/ios-scroll-delegate.ts +23 -0
- package/src/driver/ios.ts +70 -17
- package/src/easing.ts +21 -1
- package/src/engine.ts +226 -59
- package/src/gesture-native.ts +139 -0
- package/src/gestures/index.ts +365 -0
- package/src/glass/index.ts +218 -0
- package/src/gradient-binding.ts +158 -0
- package/src/gradient.ts +663 -0
- package/src/gravity.ts +107 -0
- package/src/haptics.ts +106 -28
- package/src/image-effect.ts +10 -2
- package/src/index.ts +59 -7
- package/src/inspector/index.ts +523 -0
- package/src/inspector/plot.ts +27 -0
- package/src/inspector/probe.ts +50 -0
- package/src/inspector/tuning.ts +51 -0
- package/src/interactive-navigation/index.ts +398 -0
- package/src/ios-plugin.d.ts +279 -0
- package/src/keyboard.ts +231 -7
- package/src/layout.ts +408 -0
- package/src/live-spring-driver.ts +181 -0
- package/src/mixer.ts +306 -0
- package/src/motion-scope.ts +53 -6
- package/src/motion-states.ts +149 -42
- package/src/motion-value.ts +1289 -0
- package/src/native/index.ts +30 -0
- package/src/native-properties.ts +188 -0
- package/src/native-property-driver.ts +123 -0
- package/src/native-property.ts +366 -0
- package/src/particles.ts +18 -17
- package/src/path.ts +2 -1
- package/src/physics/index.ts +443 -0
- package/src/physics/native.ts +110 -0
- package/src/playback-group.ts +17 -1
- package/src/playback.ts +41 -0
- package/src/predictive-back/index.ts +280 -0
- package/src/predictive-back/presentation.ts +6 -0
- package/src/reorder/handle.ts +9 -0
- package/src/reorder/index.ts +243 -0
- package/src/reorder/list-view.ts +262 -0
- package/src/reorder/model.ts +47 -0
- package/src/reorder/surface.ts +10 -0
- package/src/reorder/types.ts +87 -0
- package/src/sampling.ts +173 -0
- package/src/scene-appearance.ts +92 -0
- package/src/scene-camera.ts +30 -0
- package/src/scene-shader.ts +139 -0
- package/src/scroll-header/geometry.ts +88 -0
- package/src/scroll-header/index.ts +504 -0
- package/src/scroll-header/native.ts +89 -0
- package/src/sensors/index.ts +246 -0
- package/src/sensors/native.ts +72 -0
- package/src/sequence.ts +209 -20
- package/src/shapes/android.ts +63 -0
- package/src/shapes/index.ts +267 -0
- package/src/shapes/ios.ts +194 -0
- package/src/shapes/native.ts +27 -0
- package/src/shapes/path.ts +127 -0
- package/src/shapes/types.ts +63 -0
- package/src/shared-layout/index.ts +343 -0
- package/src/shared-layout/native.ts +138 -0
- package/src/shared-layout/timing.ts +87 -0
- package/src/shared-navigation/entry.ts +695 -0
- package/src/shared-navigation/index.ts +414 -0
- package/src/shared-navigation/return-signal.ts +41 -0
- package/src/shared-navigation/return-target.ts +197 -0
- package/src/shared-navigation/scope.ts +3 -0
- package/src/shared-navigation/targets.ts +38 -0
- package/src/size-layout.ts +237 -0
- package/src/size.ts +302 -0
- package/src/spring.ts +18 -0
- package/src/svg-path.ts +8 -3
- package/src/testing/clock.ts +128 -0
- package/src/testing/handoff-recorder.ts +98 -0
- package/src/testing/index.ts +4 -0
- package/src/testing/native.ts +386 -0
- package/src/testing/presentation.ts +46 -0
- package/src/testing/replay.ts +149 -0
- package/src/testing/scroll-handoff-native.ts +201 -0
- package/src/testing/scroll-handoff.ts +140 -0
- package/src/testing/sensors.ts +41 -0
- package/src/testing/trace.ts +340 -0
- package/src/timed-animation.ts +192 -0
- package/src/track.ts +334 -38
- package/src/transition.ts +197 -9
- package/src/types.ts +11 -1
- package/src/value-observers.ts +147 -0
- package/src/value-track.ts +71 -0
- package/src/vue/index.ts +147 -1
- package/src/zoomable.ts +1 -1
package/src/keyboard.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Application, Utils, isAndroid, isIOS, type View } from '@nativescript/core'
|
|
2
|
-
import { stop, toView } from './animate.js'
|
|
2
|
+
import { animate, stop, toView } from './animate.js'
|
|
3
|
+
import type { EasingFunction, EasingName } from './easing.js'
|
|
4
|
+
import type { Spring, Transition, Tween } from './transition.js'
|
|
3
5
|
import type { Target } from './types.js'
|
|
4
6
|
|
|
5
7
|
export interface KeyboardOptions {
|
|
@@ -7,7 +9,180 @@ export interface KeyboardOptions {
|
|
|
7
9
|
offset?: number
|
|
8
10
|
}
|
|
9
11
|
|
|
12
|
+
export interface KeyboardState {
|
|
13
|
+
/** Whether a docked software keyboard covers part of the window. */
|
|
14
|
+
readonly visible: boolean
|
|
15
|
+
/** DIPs of the window the keyboard covers, from its bottom edge. Zero when hidden or floating. */
|
|
16
|
+
readonly height: number
|
|
17
|
+
/** Milliseconds the keyboard takes to get there. Zero when it changes at once. */
|
|
18
|
+
readonly duration: number
|
|
19
|
+
/** The keyboard's own timing, to pass to `animate()` and move in step with it. */
|
|
20
|
+
readonly transition: Transition
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
const BEGIN_FROM_CURRENT_STATE = 4
|
|
24
|
+
const IOS_KEYBOARD_CURVE = 7
|
|
25
|
+
// Measured: Core Animation plays the keyboard's spring (stiffness 1000, mass 3) critically damped in 500 ms.
|
|
26
|
+
const iosKeyboard: Spring = {
|
|
27
|
+
type: 'spring',
|
|
28
|
+
stiffness: 1000,
|
|
29
|
+
mass: 3,
|
|
30
|
+
damping: 2 * Math.sqrt(3000),
|
|
31
|
+
}
|
|
32
|
+
const iosCurves: readonly EasingName[] = ['easeInOut', 'easeIn', 'easeOut', 'linear']
|
|
33
|
+
// Before Android 11 nothing reports the keyboard's timing. Measured on an Android 9 emulator,
|
|
34
|
+
// its window fades and slides into place in about 150 ms, decelerating, and leaves as quickly.
|
|
35
|
+
const LEGACY_DURATION = 150
|
|
36
|
+
const legacyShow: Tween = { duration: LEGACY_DURATION, ease: 'quadOut' }
|
|
37
|
+
const legacyHide: Tween = { duration: LEGACY_DURATION, ease: 'quadIn' }
|
|
38
|
+
const legacy = () => isAndroid && android.os.Build.VERSION.SDK_INT < 30
|
|
39
|
+
const hidden: KeyboardState = Object.freeze({
|
|
40
|
+
visible: false,
|
|
41
|
+
height: 0,
|
|
42
|
+
duration: 0,
|
|
43
|
+
transition: { duration: 0 },
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const listeners = new Set<(keyboard: KeyboardState) => void>()
|
|
47
|
+
let state = hidden
|
|
48
|
+
let unwatch: (() => void) | undefined
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Calls back whenever the keyboard shows, hides or changes height, with how much
|
|
52
|
+
* of the window it covers and its timing. Returns a cleanup function.
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* const off = onKeyboard(({ visible, transition }) => {
|
|
56
|
+
* animate(header, { scale: visible ? 0.8 : 1 }, transition)
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export function onKeyboard(callback: (keyboard: KeyboardState) => void): () => void {
|
|
61
|
+
if (typeof callback !== 'function')
|
|
62
|
+
throw new TypeError('onKeyboard() takes a callback.')
|
|
63
|
+
const listener = (keyboard: KeyboardState) => callback(keyboard)
|
|
64
|
+
if (listeners.size === 0) {
|
|
65
|
+
state = hidden
|
|
66
|
+
unwatch = isIOS ? watchIOS() : isAndroid ? watchAndroid() : undefined
|
|
67
|
+
}
|
|
68
|
+
listeners.add(listener)
|
|
69
|
+
return () => {
|
|
70
|
+
if (!listeners.delete(listener) || listeners.size > 0) return
|
|
71
|
+
unwatch?.()
|
|
72
|
+
unwatch = undefined
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The last state reported while someone listens. */
|
|
77
|
+
export function currentKeyboard(): KeyboardState {
|
|
78
|
+
return state
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function update(height: number, duration: number, transition: Transition) {
|
|
82
|
+
if (height === state.height) return
|
|
83
|
+
state = Object.freeze({ visible: height > 0, height, duration, transition })
|
|
84
|
+
for (const listener of [...listeners]) listener(state)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function watchIOS() {
|
|
88
|
+
const name = UIKeyboardWillChangeFrameNotification
|
|
89
|
+
const observer = Application.ios.addNotificationObserver(
|
|
90
|
+
name,
|
|
91
|
+
(notification: NSNotification) => {
|
|
92
|
+
const info = notification.userInfo
|
|
93
|
+
const window = Application.ios.window
|
|
94
|
+
const end = info?.objectForKey(UIKeyboardFrameEndUserInfoKey)?.CGRectValue as
|
|
95
|
+
CGRect | undefined
|
|
96
|
+
if (!info || !window || !end) return
|
|
97
|
+
const frame = window.convertRectFromWindow(end, null)
|
|
98
|
+
const bottom = window.bounds.size.height
|
|
99
|
+
const docked =
|
|
100
|
+
frame.size.height > 0 &&
|
|
101
|
+
frame.origin.y < bottom &&
|
|
102
|
+
frame.origin.y + frame.size.height >= bottom - 0.5
|
|
103
|
+
const reported = numberIn(info, UIKeyboardAnimationDurationUserInfoKey) * 1000
|
|
104
|
+
const curve = numberIn(info, UIKeyboardAnimationCurveUserInfoKey)
|
|
105
|
+
const height = docked ? bottom - frame.origin.y : 0
|
|
106
|
+
if (!reported) return update(height, 0, { duration: 0 })
|
|
107
|
+
if (curve === IOS_KEYBOARD_CURVE) return update(height, 500, iosKeyboard)
|
|
108
|
+
update(height, reported, {
|
|
109
|
+
duration: reported,
|
|
110
|
+
ease: iosCurves[curve] ?? 'easeInOut',
|
|
111
|
+
})
|
|
112
|
+
},
|
|
113
|
+
)
|
|
114
|
+
return () => Application.ios.removeNotificationObserver(observer, name)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function watchAndroid() {
|
|
118
|
+
const density = Utils.layout.getDisplayDensity()
|
|
119
|
+
let observer:
|
|
120
|
+
| org.rafaelaugusto.jolt.KeyboardObserver
|
|
121
|
+
| org.rafaelaugusto.jolt.KeyboardFrame
|
|
122
|
+
| undefined
|
|
123
|
+
let stopped = false
|
|
124
|
+
const attach = () => {
|
|
125
|
+
Application.off(Application.launchEvent, attach)
|
|
126
|
+
if (stopped || observer) return
|
|
127
|
+
const activity =
|
|
128
|
+
Application.android.foregroundActivity ?? Application.android.startActivity
|
|
129
|
+
const root = activity?.getWindow()?.getDecorView()
|
|
130
|
+
if (!root) return
|
|
131
|
+
try {
|
|
132
|
+
observer = legacy()
|
|
133
|
+
? new org.rafaelaugusto.jolt.KeyboardFrame(
|
|
134
|
+
root,
|
|
135
|
+
new org.rafaelaugusto.jolt.KeyboardFrame.Listener({
|
|
136
|
+
onChange: (height) =>
|
|
137
|
+
update(
|
|
138
|
+
height / density,
|
|
139
|
+
LEGACY_DURATION,
|
|
140
|
+
height ? legacyShow : legacyHide,
|
|
141
|
+
),
|
|
142
|
+
}),
|
|
143
|
+
)
|
|
144
|
+
: new org.rafaelaugusto.jolt.KeyboardObserver(
|
|
145
|
+
root,
|
|
146
|
+
new org.rafaelaugusto.jolt.KeyboardObserver.Listener({
|
|
147
|
+
onChange: (height, duration, curve) =>
|
|
148
|
+
update(
|
|
149
|
+
height / density,
|
|
150
|
+
duration,
|
|
151
|
+
duration
|
|
152
|
+
? { duration, ease: curve ? sampled(curve) : 'linear' }
|
|
153
|
+
: { duration: 0 },
|
|
154
|
+
),
|
|
155
|
+
}),
|
|
156
|
+
)
|
|
157
|
+
} catch {
|
|
158
|
+
// A JS-only update cannot install the native plugin.
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
observer.attach()
|
|
162
|
+
const height = observer.height() / density
|
|
163
|
+
if (height > 0) state = Object.freeze({ ...hidden, visible: true, height })
|
|
164
|
+
}
|
|
165
|
+
if (Application.android.foregroundActivity ?? Application.android.startActivity)
|
|
166
|
+
attach()
|
|
167
|
+
else Application.on(Application.launchEvent, attach)
|
|
168
|
+
return () => {
|
|
169
|
+
stopped = true
|
|
170
|
+
Application.off(Application.launchEvent, attach)
|
|
171
|
+
observer?.detach()
|
|
172
|
+
observer = undefined
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function sampled(curve: ArrayLike<number>): EasingFunction {
|
|
177
|
+
const values = Array.from({ length: curve.length }, (_, i) => curve[i]!)
|
|
178
|
+
const last = values.length - 1
|
|
179
|
+
if (last < 1) return (progress) => progress
|
|
180
|
+
return (progress) => {
|
|
181
|
+
const position = Math.min(Math.max(progress, 0), 1) * last
|
|
182
|
+
const index = Math.min(Math.floor(position), last - 1)
|
|
183
|
+
return values[index]! + (values[index + 1]! - values[index]!) * (position - index)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
11
186
|
|
|
12
187
|
/**
|
|
13
188
|
* Lifts the view by its overlap with the software keyboard, at the keyboard's
|
|
@@ -55,12 +230,9 @@ function followIOS(view: View, offset: number) {
|
|
|
55
230
|
const apply = () => {
|
|
56
231
|
view.translateY = overlap ? -overlap : 0
|
|
57
232
|
}
|
|
58
|
-
const duration = info
|
|
59
|
-
?.doubleValue as number | undefined
|
|
233
|
+
const duration = numberIn(info, UIKeyboardAnimationDurationUserInfoKey)
|
|
60
234
|
if (!duration) return apply()
|
|
61
|
-
const curve =
|
|
62
|
-
(info.objectForKey(UIKeyboardAnimationCurveUserInfoKey)?.integerValue as
|
|
63
|
-
number | undefined) ?? 0
|
|
235
|
+
const curve = numberIn(info, UIKeyboardAnimationCurveUserInfoKey)
|
|
64
236
|
// The keyboard's curve is private; shifted into the options it still applies.
|
|
65
237
|
UIView.animateWithDurationDelayOptionsAnimationsCompletion(
|
|
66
238
|
duration,
|
|
@@ -89,7 +261,7 @@ function followIOS(view: View, offset: number) {
|
|
|
89
261
|
}
|
|
90
262
|
|
|
91
263
|
function followAndroid(view: View, offset: number) {
|
|
92
|
-
if (
|
|
264
|
+
if (legacy()) return followLegacy(view, offset)
|
|
93
265
|
const density = Utils.layout.getDisplayDensity()
|
|
94
266
|
let disposed = false
|
|
95
267
|
let follower: org.rafaelaugusto.jolt.KeyboardFollower | undefined
|
|
@@ -130,3 +302,55 @@ function followAndroid(view: View, offset: number) {
|
|
|
130
302
|
if (view.isLoaded) attach()
|
|
131
303
|
return cleanup
|
|
132
304
|
}
|
|
305
|
+
|
|
306
|
+
/** Android 7 to 10: no frame-by-frame progress, so the view animates with the keyboard's usual timing. */
|
|
307
|
+
function followLegacy(view: View, offset: number) {
|
|
308
|
+
const density = Utils.layout.getDisplayDensity()
|
|
309
|
+
let disposed = false
|
|
310
|
+
let follower: org.rafaelaugusto.jolt.KeyboardFrameFollower | undefined
|
|
311
|
+
const attach = () => {
|
|
312
|
+
if (disposed || follower) return
|
|
313
|
+
const native = view.nativeViewProtected as android.view.View | undefined
|
|
314
|
+
if (!native) return
|
|
315
|
+
try {
|
|
316
|
+
follower = new org.rafaelaugusto.jolt.KeyboardFrameFollower(
|
|
317
|
+
native,
|
|
318
|
+
offset * density,
|
|
319
|
+
new org.rafaelaugusto.jolt.KeyboardFrameFollower.Listener({
|
|
320
|
+
onMove: (from, to, keyboard) => {
|
|
321
|
+
stop(view, ['y'])
|
|
322
|
+
view.translateY = from / density
|
|
323
|
+
animate(view, { y: to / density }, keyboard ? legacyShow : legacyHide)
|
|
324
|
+
},
|
|
325
|
+
}),
|
|
326
|
+
)
|
|
327
|
+
} catch {
|
|
328
|
+
// A JS-only update cannot install the native plugin. Leave the platform's resize in place.
|
|
329
|
+
return
|
|
330
|
+
}
|
|
331
|
+
follower.attach()
|
|
332
|
+
}
|
|
333
|
+
const cleanup = () => {
|
|
334
|
+
if (disposed) return
|
|
335
|
+
disposed = true
|
|
336
|
+
view.off('loaded', attach)
|
|
337
|
+
view.off('unloaded', cleanup)
|
|
338
|
+
if (follower) {
|
|
339
|
+
follower.detach()
|
|
340
|
+
follower = undefined
|
|
341
|
+
stop(view, ['y'])
|
|
342
|
+
view.translateY = 0
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
view.on('loaded', attach)
|
|
346
|
+
view.on('unloaded', cleanup)
|
|
347
|
+
if (view.isLoaded) attach()
|
|
348
|
+
return cleanup
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** The runtime hands NSNumber values over as plain numbers. */
|
|
352
|
+
function numberIn(info: NSDictionary<unknown, unknown>, key: string): number {
|
|
353
|
+
const value = info.objectForKey(key) as number | NSNumber | null | undefined
|
|
354
|
+
if (typeof value === 'number') return value
|
|
355
|
+
return value?.doubleValue ?? 0
|
|
356
|
+
}
|
package/src/layout.ts
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import { Application, type View } from '@nativescript/core'
|
|
2
|
+
import { prepareAnimation, toView } from './animate.js'
|
|
3
|
+
import { getDriver, type LayoutFrame } from './driver/index.js'
|
|
4
|
+
import {
|
|
5
|
+
captureValue,
|
|
6
|
+
propertyRevision,
|
|
7
|
+
arrivalOf,
|
|
8
|
+
setArrival,
|
|
9
|
+
type Animation,
|
|
10
|
+
} from './engine.js'
|
|
11
|
+
import { interactionSurface } from './interaction-surface.js'
|
|
12
|
+
import { readValue, writeValue, type NumericProperty } from './properties.js'
|
|
13
|
+
import { springs, type Spring, type Tween, type SpringName } from './transition.js'
|
|
14
|
+
import type { Keyframes, Target } from './types.js'
|
|
15
|
+
|
|
16
|
+
export type LayoutOptions = (
|
|
17
|
+
Omit<Spring, 'repeat' | 'repeatType'> | Omit<Tween, 'repeat' | 'repeatType'>
|
|
18
|
+
) & {
|
|
19
|
+
/** Scale from the previous size (including content); false snaps size and only moves. Default: 'scale'. */
|
|
20
|
+
size?: 'scale' | false
|
|
21
|
+
/** Fade new children from zero to their configured opacity. Default: true. */
|
|
22
|
+
enter?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type Geometry = 'x' | 'y' | 'scaleX' | 'scaleY'
|
|
26
|
+
interface Snapshot {
|
|
27
|
+
frame: LayoutFrame
|
|
28
|
+
originX: number
|
|
29
|
+
originY: number
|
|
30
|
+
rotate: number
|
|
31
|
+
rotateX: number
|
|
32
|
+
rotateY: number
|
|
33
|
+
values: Record<Geometry, () => number | undefined>
|
|
34
|
+
}
|
|
35
|
+
interface Owned {
|
|
36
|
+
view: View
|
|
37
|
+
handle: Animation
|
|
38
|
+
detach(): void
|
|
39
|
+
targets: { property: NumericProperty; value: number; token: symbol | undefined }[]
|
|
40
|
+
}
|
|
41
|
+
const pending = new WeakMap<View, Animation>()
|
|
42
|
+
const playing = new WeakMap<View, Set<Animation>>()
|
|
43
|
+
const properties = ['x', 'y', 'scaleX', 'scaleY'] as const
|
|
44
|
+
|
|
45
|
+
/** Animate the next layout of a container's direct children. Call before a synchronous mutation. */
|
|
46
|
+
export function animateLayout(
|
|
47
|
+
container: Target,
|
|
48
|
+
options?: LayoutOptions | SpringName,
|
|
49
|
+
): Animation
|
|
50
|
+
export function animateLayout(
|
|
51
|
+
container: Target,
|
|
52
|
+
change: () => void,
|
|
53
|
+
options?: LayoutOptions | SpringName,
|
|
54
|
+
): Animation
|
|
55
|
+
export function animateLayout(
|
|
56
|
+
container: Target,
|
|
57
|
+
changeOrOptions?: (() => void) | LayoutOptions | SpringName,
|
|
58
|
+
options?: LayoutOptions | SpringName,
|
|
59
|
+
): Animation {
|
|
60
|
+
const host = toView(container)
|
|
61
|
+
const change = typeof changeOrOptions === 'function' ? changeOrOptions : undefined
|
|
62
|
+
const input = change ? options : changeOrOptions
|
|
63
|
+
const {
|
|
64
|
+
size = 'scale',
|
|
65
|
+
enter = true,
|
|
66
|
+
...transition
|
|
67
|
+
} = normalize(input as LayoutOptions | SpringName | undefined)
|
|
68
|
+
// Validate the complete transition before changing children or cancelling an earlier request.
|
|
69
|
+
prepareAnimation(
|
|
70
|
+
host,
|
|
71
|
+
{ x: [0, 1], y: [0, 1], scaleX: [1, 2], scaleY: [1, 2], opacity: [0, 1] },
|
|
72
|
+
transition,
|
|
73
|
+
)
|
|
74
|
+
const driver = getDriver()
|
|
75
|
+
const before = new Map<View, Snapshot>()
|
|
76
|
+
const ready = laidOut(host)
|
|
77
|
+
if (ready)
|
|
78
|
+
for (const child of childrenOf(host)) {
|
|
79
|
+
const frame = frameOf(child)
|
|
80
|
+
if (frame)
|
|
81
|
+
before.set(child, {
|
|
82
|
+
frame,
|
|
83
|
+
originX: child.originX,
|
|
84
|
+
originY: child.originY,
|
|
85
|
+
rotate: child.rotate,
|
|
86
|
+
rotateX: child.rotateX,
|
|
87
|
+
rotateY: child.rotateY,
|
|
88
|
+
values: {
|
|
89
|
+
x: captureValue(child, 'x'),
|
|
90
|
+
y: captureValue(child, 'y'),
|
|
91
|
+
scaleX: captureValue(child, 'scaleX'),
|
|
92
|
+
scaleY: captureValue(child, 'scaleY'),
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let resolve!: (finished: boolean) => void
|
|
98
|
+
let reject!: (error: unknown) => void
|
|
99
|
+
const finished = new Promise<boolean>((done, fail) => {
|
|
100
|
+
resolve = done
|
|
101
|
+
reject = fail
|
|
102
|
+
})
|
|
103
|
+
let arrive!: () => void
|
|
104
|
+
const arrival = new Promise<void>((done) => (arrive = done))
|
|
105
|
+
const owned: Owned[] = []
|
|
106
|
+
let settled = false
|
|
107
|
+
let detach: (() => void) | undefined
|
|
108
|
+
const cleanup = () => {
|
|
109
|
+
detach?.()
|
|
110
|
+
detach = undefined
|
|
111
|
+
host.off('unloaded', stop)
|
|
112
|
+
Application.off(Application.suspendEvent, stop)
|
|
113
|
+
if (pending.get(host) === handle) pending.delete(host)
|
|
114
|
+
const active = playing.get(host)
|
|
115
|
+
active?.delete(handle)
|
|
116
|
+
if (!active?.size) playing.delete(host)
|
|
117
|
+
before.clear()
|
|
118
|
+
owned.forEach((child) => child.detach())
|
|
119
|
+
arrive()
|
|
120
|
+
}
|
|
121
|
+
const complete = (result: boolean, error?: unknown) => {
|
|
122
|
+
if (settled) return
|
|
123
|
+
settled = true
|
|
124
|
+
cleanup()
|
|
125
|
+
if (error !== undefined) reject(error)
|
|
126
|
+
else resolve(result)
|
|
127
|
+
}
|
|
128
|
+
// A cancelled FLIP settles into the real layout rather than leaving a temporary inverse offset.
|
|
129
|
+
// The engine marker protects any animation that took ownership after this operation.
|
|
130
|
+
const restoreOne = ({ view, handle: child, targets }: Owned) => {
|
|
131
|
+
const current = targets.filter(
|
|
132
|
+
(target) => propertyRevision(view, target.property) === target.token,
|
|
133
|
+
)
|
|
134
|
+
child.stop()
|
|
135
|
+
for (const target of current)
|
|
136
|
+
if (propertyRevision(view, target.property) === target.token)
|
|
137
|
+
writeValue(view, target.property, target.value)
|
|
138
|
+
if (current.length) driver.sync?.(view)
|
|
139
|
+
}
|
|
140
|
+
const restore = () => {
|
|
141
|
+
owned.forEach(restoreOne)
|
|
142
|
+
}
|
|
143
|
+
function stop() {
|
|
144
|
+
if (settled) return
|
|
145
|
+
restore()
|
|
146
|
+
complete(false)
|
|
147
|
+
}
|
|
148
|
+
const handle: Animation = {
|
|
149
|
+
finished,
|
|
150
|
+
stop,
|
|
151
|
+
then: (onfulfilled, onrejected) => finished.then(onfulfilled, onrejected),
|
|
152
|
+
}
|
|
153
|
+
setArrival(handle, arrival)
|
|
154
|
+
const run = () => {
|
|
155
|
+
if (settled) return
|
|
156
|
+
detach?.()
|
|
157
|
+
detach = undefined
|
|
158
|
+
if (!laidOut(host)) {
|
|
159
|
+
stop()
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
if (pending.get(host) === handle) pending.delete(host)
|
|
163
|
+
const previous = [...(playing.get(host) ?? [])]
|
|
164
|
+
try {
|
|
165
|
+
const prepared: { view: View; frames: Keyframes; start: () => Animation }[] = []
|
|
166
|
+
for (const child of childrenOf(host)) {
|
|
167
|
+
const now = frameOf(child)
|
|
168
|
+
if (!now) continue
|
|
169
|
+
const was = before.get(child)
|
|
170
|
+
const frames = was
|
|
171
|
+
? inverse(child, was, now, size)
|
|
172
|
+
: enter
|
|
173
|
+
? { opacity: [0, child.opacity] }
|
|
174
|
+
: undefined
|
|
175
|
+
if (frames && Object.keys(frames).length)
|
|
176
|
+
prepared.push({
|
|
177
|
+
view: child,
|
|
178
|
+
frames,
|
|
179
|
+
start: prepareAnimation(child, frames, transition),
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
before.clear()
|
|
183
|
+
// Selection lasts only for starting these tracks; their native geometry driver stays until completion.
|
|
184
|
+
for (const { view, frames, start } of prepared) {
|
|
185
|
+
const surface = interactionSurface(view)
|
|
186
|
+
try {
|
|
187
|
+
const child = start()
|
|
188
|
+
const targets = Object.entries(frames).map(([property, frames]) => ({
|
|
189
|
+
property: property as NumericProperty,
|
|
190
|
+
value: (frames as number[]).at(-1)!,
|
|
191
|
+
token: propertyRevision(view, property as NumericProperty),
|
|
192
|
+
}))
|
|
193
|
+
const item: Owned = {
|
|
194
|
+
view,
|
|
195
|
+
handle: child,
|
|
196
|
+
targets,
|
|
197
|
+
detach: () => view.off('unloaded', unloaded),
|
|
198
|
+
}
|
|
199
|
+
const unloaded = () => {
|
|
200
|
+
item.detach()
|
|
201
|
+
if (!settled) restoreOne(item)
|
|
202
|
+
}
|
|
203
|
+
// Keyed reorder may unload/reinsert the same native view. Do not persist its FLIP offset.
|
|
204
|
+
view.on('unloaded', unloaded)
|
|
205
|
+
owned.push(item)
|
|
206
|
+
} finally {
|
|
207
|
+
surface.dispose()
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const active = playing.get(host) ?? new Set<Animation>()
|
|
211
|
+
active.add(handle)
|
|
212
|
+
playing.set(host, active)
|
|
213
|
+
// Replacements start before old handles stop so the engine can transfer velocity.
|
|
214
|
+
for (const old of previous) old.stop()
|
|
215
|
+
void Promise.all(owned.map(({ handle }) => arrivalOf(handle))).then(arrive)
|
|
216
|
+
void Promise.all(owned.map(({ handle }) => handle.finished)).then(
|
|
217
|
+
(results) => complete(results.every(Boolean)),
|
|
218
|
+
(error) => {
|
|
219
|
+
restore()
|
|
220
|
+
complete(false, error)
|
|
221
|
+
},
|
|
222
|
+
)
|
|
223
|
+
} catch (error) {
|
|
224
|
+
restore()
|
|
225
|
+
complete(false, error)
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
pending.get(host)?.stop()
|
|
230
|
+
pending.set(host, handle)
|
|
231
|
+
host.on('unloaded', stop)
|
|
232
|
+
Application.on(Application.suspendEvent, stop)
|
|
233
|
+
try {
|
|
234
|
+
const result = change?.() as unknown
|
|
235
|
+
if (result && typeof (result as PromiseLike<unknown>).then === 'function') {
|
|
236
|
+
void Promise.resolve(result).catch(() => {})
|
|
237
|
+
throw new TypeError(
|
|
238
|
+
'Layout mutations must be synchronous. Call animateLayout after awaited work.',
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
if (!settled) {
|
|
242
|
+
if (!ready || !laidOut(host)) complete(true)
|
|
243
|
+
else {
|
|
244
|
+
if (!driver.afterLayout || !driver.layoutFrame)
|
|
245
|
+
throw new Error('The animation driver does not support layout changes.')
|
|
246
|
+
detach = driver.afterLayout(host, run)
|
|
247
|
+
// Always request a pass, including a no-op mutation: no arbitrary timer or hanging wait.
|
|
248
|
+
host.requestLayout()
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
} catch (error) {
|
|
252
|
+
stop()
|
|
253
|
+
throw error
|
|
254
|
+
}
|
|
255
|
+
return handle
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function normalize(input: LayoutOptions | SpringName | undefined): LayoutOptions {
|
|
259
|
+
if (typeof input === 'string') {
|
|
260
|
+
if (!Object.hasOwn(springs, input))
|
|
261
|
+
throw new TypeError(`Unknown layout spring "${input}".`)
|
|
262
|
+
return normalize({ ...springs[input] })
|
|
263
|
+
}
|
|
264
|
+
if (input === undefined) return {}
|
|
265
|
+
if (!input || typeof input !== 'object' || Array.isArray(input))
|
|
266
|
+
throw new TypeError('Invalid layout options.')
|
|
267
|
+
const allowed = new Set([
|
|
268
|
+
'type',
|
|
269
|
+
'duration',
|
|
270
|
+
'ease',
|
|
271
|
+
'times',
|
|
272
|
+
'stiffness',
|
|
273
|
+
'damping',
|
|
274
|
+
'mass',
|
|
275
|
+
'bounce',
|
|
276
|
+
'velocity',
|
|
277
|
+
'delay',
|
|
278
|
+
'size',
|
|
279
|
+
'enter',
|
|
280
|
+
])
|
|
281
|
+
for (const key of Object.keys(input))
|
|
282
|
+
if (!allowed.has(key)) throw new TypeError(`Unsupported layout option "${key}".`)
|
|
283
|
+
if (input.size !== undefined && input.size !== false && input.size !== 'scale')
|
|
284
|
+
throw new TypeError('Layout size must be "scale" or false.')
|
|
285
|
+
if (input.enter !== undefined && typeof input.enter !== 'boolean')
|
|
286
|
+
throw new TypeError('Layout enter must be boolean.')
|
|
287
|
+
if (input.type !== undefined && input.type !== 'spring' && input.type !== 'tween')
|
|
288
|
+
throw new TypeError('Layout type must be "spring" or "tween".')
|
|
289
|
+
const numbers = input as Record<string, unknown>
|
|
290
|
+
for (const key of [
|
|
291
|
+
'duration',
|
|
292
|
+
'delay',
|
|
293
|
+
'stiffness',
|
|
294
|
+
'damping',
|
|
295
|
+
'mass',
|
|
296
|
+
'bounce',
|
|
297
|
+
'velocity',
|
|
298
|
+
]) {
|
|
299
|
+
const value = numbers[key]
|
|
300
|
+
if (value !== undefined && (typeof value !== 'number' || !Number.isFinite(value)))
|
|
301
|
+
throw new RangeError(`Layout ${key} must be finite.`)
|
|
302
|
+
if (typeof value === 'number') {
|
|
303
|
+
if (['duration', 'delay', 'damping'].includes(key) && value < 0)
|
|
304
|
+
throw new RangeError(`Layout ${key} must be nonnegative.`)
|
|
305
|
+
if (['stiffness', 'mass'].includes(key) && value <= 0)
|
|
306
|
+
throw new RangeError(`Layout ${key} must be positive.`)
|
|
307
|
+
if (key === 'bounce' && (value < -1 || value > 1))
|
|
308
|
+
throw new RangeError('Layout bounce must be between -1 and 1.')
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
const physical = ['stiffness', 'damping', 'mass'].some(
|
|
312
|
+
(key) => numbers[key] !== undefined,
|
|
313
|
+
)
|
|
314
|
+
const spring =
|
|
315
|
+
input.type === 'spring' ||
|
|
316
|
+
(input.type !== 'tween' &&
|
|
317
|
+
['bounce', 'velocity', 'stiffness', 'damping', 'mass'].some(
|
|
318
|
+
(key) => numbers[key] !== undefined,
|
|
319
|
+
))
|
|
320
|
+
if (spring && !physical && input.duration === 0)
|
|
321
|
+
throw new RangeError(
|
|
322
|
+
'A duration-based layout spring must have positive duration; use a zero-duration tween to settle immediately.',
|
|
323
|
+
)
|
|
324
|
+
const result = { ...input }
|
|
325
|
+
if ('ease' in result && Array.isArray(result.ease)) result.ease = [...result.ease]
|
|
326
|
+
if ('times' in result && result.times) result.times = [...result.times]
|
|
327
|
+
return result
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function inverse(
|
|
331
|
+
view: View,
|
|
332
|
+
was: Snapshot,
|
|
333
|
+
now: LayoutFrame,
|
|
334
|
+
size: LayoutOptions['size'],
|
|
335
|
+
): Keyframes | undefined {
|
|
336
|
+
// Origin/rotation changes require a different affine transform, not a translation/scale FLIP.
|
|
337
|
+
if (
|
|
338
|
+
view.originX !== was.originX ||
|
|
339
|
+
view.originY !== was.originY ||
|
|
340
|
+
view.rotate !== was.rotate ||
|
|
341
|
+
was.rotateX ||
|
|
342
|
+
was.rotateY ||
|
|
343
|
+
view.rotateX ||
|
|
344
|
+
view.rotateY
|
|
345
|
+
)
|
|
346
|
+
return undefined
|
|
347
|
+
const frames: Keyframes = {}
|
|
348
|
+
const width = was.frame.width - now.width,
|
|
349
|
+
height = was.frame.height - now.height
|
|
350
|
+
const resized = Math.abs(width) > 0.25 || Math.abs(height) > 0.25
|
|
351
|
+
for (const property of properties) {
|
|
352
|
+
const current = was.values[property]()
|
|
353
|
+
if (current === undefined) continue // A newer explicit animation owns this property.
|
|
354
|
+
let start: number
|
|
355
|
+
if (property === 'x')
|
|
356
|
+
start =
|
|
357
|
+
was.frame.x -
|
|
358
|
+
now.x +
|
|
359
|
+
current +
|
|
360
|
+
(size === 'scale' && resized ? width * was.originX : 0)
|
|
361
|
+
else if (property === 'y')
|
|
362
|
+
start =
|
|
363
|
+
was.frame.y -
|
|
364
|
+
now.y +
|
|
365
|
+
current +
|
|
366
|
+
(size === 'scale' && resized ? height * was.originY : 0)
|
|
367
|
+
else {
|
|
368
|
+
if (size !== 'scale') continue
|
|
369
|
+
start =
|
|
370
|
+
current *
|
|
371
|
+
(property === 'scaleX'
|
|
372
|
+
? was.frame.width / now.width
|
|
373
|
+
: was.frame.height / now.height)
|
|
374
|
+
}
|
|
375
|
+
const end = readValue(view, property)
|
|
376
|
+
if (Math.abs(start - end) > (property.startsWith('scale') ? 0.0001 : 0.25))
|
|
377
|
+
frames[property] = [start, end]
|
|
378
|
+
}
|
|
379
|
+
return frames
|
|
380
|
+
}
|
|
381
|
+
function laidOut(view: View): boolean {
|
|
382
|
+
if (!view.isLoaded || !view.nativeViewProtected) return false
|
|
383
|
+
for (
|
|
384
|
+
let current: View | undefined = view;
|
|
385
|
+
current;
|
|
386
|
+
current = current.parent as View | undefined
|
|
387
|
+
)
|
|
388
|
+
if (current.isCollapsed) return false
|
|
389
|
+
return true
|
|
390
|
+
}
|
|
391
|
+
function frameOf(view: View): LayoutFrame | undefined {
|
|
392
|
+
if (!laidOut(view)) return undefined
|
|
393
|
+
const frame = getDriver().layoutFrame?.(view)
|
|
394
|
+
return frame &&
|
|
395
|
+
Object.values(frame).every(Number.isFinite) &&
|
|
396
|
+
frame.width > 0 &&
|
|
397
|
+
frame.height > 0
|
|
398
|
+
? frame
|
|
399
|
+
: undefined
|
|
400
|
+
}
|
|
401
|
+
function childrenOf(host: View): View[] {
|
|
402
|
+
const children: View[] = []
|
|
403
|
+
host.eachChildView((child) => {
|
|
404
|
+
children.push(child)
|
|
405
|
+
return true
|
|
406
|
+
})
|
|
407
|
+
return children
|
|
408
|
+
}
|