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.
package/dist/cjs/index.js CHANGED
@@ -5518,27 +5518,39 @@ function handlePressEvent(state2, event, lifecycle) {
5518
5518
  }
5519
5519
  class PressGesture extends Feature {
5520
5520
  isActive() {
5521
- return Boolean(this.state.options.press);
5521
+ return Boolean(this.state.options.whilePress);
5522
5522
  }
5523
5523
  constructor(state2) {
5524
5524
  super(state2);
5525
5525
  }
5526
5526
  mount() {
5527
- const element = this.state.element;
5528
- if (!element)
5529
- return;
5530
- this.unmount = press(
5531
- element,
5532
- (el, startEvent) => {
5533
- handlePressEvent(this.state, startEvent, "Start");
5534
- return (endEvent, { success }) => handlePressEvent(
5535
- this.state,
5536
- endEvent,
5537
- success ? "End" : "Cancel"
5538
- );
5539
- },
5540
- { useGlobalTarget: this.state.options.globalPressTarget }
5541
- );
5527
+ this.register();
5528
+ }
5529
+ update() {
5530
+ const preProps = this.state.visualElement.prevProps;
5531
+ if (preProps.whilePress !== this.state.options.whilePress) {
5532
+ this.register();
5533
+ }
5534
+ }
5535
+ register() {
5536
+ this.unmount();
5537
+ if (this.isActive()) {
5538
+ const element = this.state.element;
5539
+ if (!element)
5540
+ return;
5541
+ this.unmount = press(
5542
+ element,
5543
+ (el, startEvent) => {
5544
+ handlePressEvent(this.state, startEvent, "Start");
5545
+ return (endEvent, { success }) => handlePressEvent(
5546
+ this.state,
5547
+ endEvent,
5548
+ success ? "End" : "Cancel"
5549
+ );
5550
+ },
5551
+ { useGlobalTarget: this.state.options.globalPressTarget }
5552
+ );
5553
+ }
5542
5554
  }
5543
5555
  }
5544
5556
  function handleHoverEvent(state2, entry, lifecycle) {
@@ -8481,7 +8493,7 @@ class MotionState {
8481
8493
  if (isAnimate) {
8482
8494
  this.animateUpdates({
8483
8495
  isFallback: !isActive && name !== "exit" && this.visualElement.isControllingVariants,
8484
- isExit: this.activeStates.exit
8496
+ isExit: name === "exit" && this.activeStates.exit
8485
8497
  });
8486
8498
  }
8487
8499
  }