motion-v 0.12.0-beta.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,4 +6,6 @@ export declare class PressGesture extends Feature {
6
6
  isActive(): boolean;
7
7
  constructor(state: MotionState);
8
8
  mount(): void;
9
+ update(): void;
10
+ register(): void;
9
11
  }
@@ -23,27 +23,39 @@ function handlePressEvent(state, event, lifecycle) {
23
23
  }
24
24
  class PressGesture extends Feature {
25
25
  isActive() {
26
- return Boolean(this.state.options.press);
26
+ return Boolean(this.state.options.whilePress);
27
27
  }
28
28
  constructor(state) {
29
29
  super(state);
30
30
  }
31
31
  mount() {
32
- const element = this.state.element;
33
- if (!element)
34
- return;
35
- this.unmount = press(
36
- element,
37
- (el, startEvent) => {
38
- handlePressEvent(this.state, startEvent, "Start");
39
- return (endEvent, { success }) => handlePressEvent(
40
- this.state,
41
- endEvent,
42
- success ? "End" : "Cancel"
43
- );
44
- },
45
- { useGlobalTarget: this.state.options.globalPressTarget }
46
- );
32
+ this.register();
33
+ }
34
+ update() {
35
+ const preProps = this.state.visualElement.prevProps;
36
+ if (preProps.whilePress !== this.state.options.whilePress) {
37
+ this.register();
38
+ }
39
+ }
40
+ register() {
41
+ this.unmount();
42
+ if (this.isActive()) {
43
+ const element = this.state.element;
44
+ if (!element)
45
+ return;
46
+ this.unmount = press(
47
+ element,
48
+ (el, startEvent) => {
49
+ handlePressEvent(this.state, startEvent, "Start");
50
+ return (endEvent, { success }) => handlePressEvent(
51
+ this.state,
52
+ endEvent,
53
+ success ? "End" : "Cancel"
54
+ );
55
+ },
56
+ { useGlobalTarget: this.state.options.globalPressTarget }
57
+ );
58
+ }
47
59
  }
48
60
  }
49
61
  export {
@@ -196,7 +196,7 @@ class MotionState {
196
196
  if (isAnimate) {
197
197
  this.animateUpdates({
198
198
  isFallback: !isActive && name !== "exit" && this.visualElement.isControllingVariants,
199
- isExit: this.activeStates.exit
199
+ isExit: name === "exit" && this.activeStates.exit
200
200
  });
201
201
  }
202
202
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-v",
3
- "version": "0.12.0-beta.2",
3
+ "version": "0.12.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",