motion-v 0.8.0 → 0.8.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/dist/cjs/index.js CHANGED
@@ -6398,8 +6398,12 @@ class LayoutFeature extends Feature {
6398
6398
  this.state.willUpdate("beforeUpdate");
6399
6399
  }
6400
6400
  update() {
6401
- var _a;
6402
- (_a = this.state.visualElement.projection) == null ? void 0 : _a.root.didUpdate();
6401
+ this.didUpdate();
6402
+ }
6403
+ didUpdate() {
6404
+ var _a, _b;
6405
+ if (this.state.options.layout || this.state.options.layoutId)
6406
+ (_b = (_a = this.state.visualElement.projection) == null ? void 0 : _a.root) == null ? void 0 : _b.didUpdate();
6403
6407
  }
6404
6408
  beforeMount() {
6405
6409
  }
@@ -6413,7 +6417,7 @@ class LayoutFeature extends Feature {
6413
6417
  (_a = layoutGroup == null ? void 0 : layoutGroup.group) == null ? void 0 : _a.add(projection);
6414
6418
  }
6415
6419
  globalProjectionState.hasEverUpdated = true;
6416
- projection == null ? void 0 : projection.root.didUpdate();
6420
+ this.didUpdate();
6417
6421
  }
6418
6422
  }
6419
6423
  beforeUnmount() {
@@ -6429,14 +6433,11 @@ class LayoutFeature extends Feature {
6429
6433
  }
6430
6434
  }
6431
6435
  unmount() {
6432
- var _a, _b;
6433
6436
  const layoutGroup = this.state.options.layoutGroup;
6434
6437
  const projection = this.state.visualElement.projection;
6435
6438
  if ((layoutGroup == null ? void 0 : layoutGroup.group) && projection)
6436
6439
  layoutGroup.group.remove(projection);
6437
- if (this.state.options.layoutId || this.state.options.layout) {
6438
- (_b = (_a = this.state.visualElement.projection) == null ? void 0 : _a.root) == null ? void 0 : _b.didUpdate();
6439
- }
6440
+ this.didUpdate();
6440
6441
  }
6441
6442
  }
6442
6443
  function asyncHandler(handler) {
@@ -7932,7 +7933,21 @@ class ProjectionFeature extends Feature {
7932
7933
  // initialPromotionConfig
7933
7934
  layoutRoot: options.layoutRoot,
7934
7935
  layoutScroll: options.layoutScroll,
7935
- crossfade: options.crossfade
7936
+ crossfade: options.crossfade,
7937
+ onExitComplete: () => {
7938
+ var _a;
7939
+ if (!((_a = this.state.visualElement.projection) == null ? void 0 : _a.isPresent)) {
7940
+ const done = doneCallbacks.get(this.state.element);
7941
+ this.state.isSafeToRemove = true;
7942
+ if (done) {
7943
+ done({
7944
+ detail: {
7945
+ isExit: true
7946
+ }
7947
+ }, true);
7948
+ }
7949
+ }
7950
+ }
7936
7951
  });
7937
7952
  }
7938
7953
  update() {
@@ -8345,7 +8360,8 @@ class MotionState {
8345
8360
  }
8346
8361
  willUpdate(label) {
8347
8362
  var _a;
8348
- (_a = this.visualElement.projection) == null ? void 0 : _a.willUpdate();
8363
+ if (this.options.layout || this.options.layoutId)
8364
+ (_a = this.visualElement.projection) == null ? void 0 : _a.willUpdate();
8349
8365
  }
8350
8366
  }
8351
8367
  function getMotionElement(el) {
@@ -8802,11 +8818,7 @@ function nodeGroup() {
8802
8818
  subscriptions.delete(node);
8803
8819
  }
8804
8820
  },
8805
- dirty: dirtyAll,
8806
- didUpdate: () => {
8807
- var _a;
8808
- (_a = nodes[0]) == null ? void 0 : _a.didUpdate();
8809
- }
8821
+ dirty: dirtyAll
8810
8822
  };
8811
8823
  }
8812
8824
  function useLayoutGroupProvider(props) {
@@ -3,6 +3,5 @@ export interface NodeGroup {
3
3
  add: (node: IProjectionNode) => void;
4
4
  remove: (node: IProjectionNode) => void;
5
5
  dirty: VoidFunction;
6
- didUpdate: VoidFunction;
7
6
  }
8
7
  export declare function nodeGroup(): NodeGroup;
@@ -21,11 +21,7 @@ function nodeGroup() {
21
21
  subscriptions.delete(node);
22
22
  }
23
23
  },
24
- dirty: dirtyAll,
25
- didUpdate: () => {
26
- var _a;
27
- (_a = nodes[0]) == null ? void 0 : _a.didUpdate();
28
- }
24
+ dirty: dirtyAll
29
25
  };
30
26
  }
31
27
  export {
@@ -4,6 +4,7 @@ export declare class LayoutFeature extends Feature {
4
4
  constructor(state: MotionState);
5
5
  beforeUpdate(): void;
6
6
  update(): void;
7
+ didUpdate(): void;
7
8
  beforeMount(): void;
8
9
  mount(): void;
9
10
  beforeUnmount(): void;
@@ -11,8 +11,12 @@ class LayoutFeature extends Feature {
11
11
  this.state.willUpdate("beforeUpdate");
12
12
  }
13
13
  update() {
14
- var _a;
15
- (_a = this.state.visualElement.projection) == null ? void 0 : _a.root.didUpdate();
14
+ this.didUpdate();
15
+ }
16
+ didUpdate() {
17
+ var _a, _b;
18
+ if (this.state.options.layout || this.state.options.layoutId)
19
+ (_b = (_a = this.state.visualElement.projection) == null ? void 0 : _a.root) == null ? void 0 : _b.didUpdate();
16
20
  }
17
21
  beforeMount() {
18
22
  }
@@ -26,7 +30,7 @@ class LayoutFeature extends Feature {
26
30
  (_a = layoutGroup == null ? void 0 : layoutGroup.group) == null ? void 0 : _a.add(projection);
27
31
  }
28
32
  globalProjectionState.hasEverUpdated = true;
29
- projection == null ? void 0 : projection.root.didUpdate();
33
+ this.didUpdate();
30
34
  }
31
35
  }
32
36
  beforeUnmount() {
@@ -42,14 +46,11 @@ class LayoutFeature extends Feature {
42
46
  }
43
47
  }
44
48
  unmount() {
45
- var _a, _b;
46
49
  const layoutGroup = this.state.options.layoutGroup;
47
50
  const projection = this.state.visualElement.projection;
48
51
  if ((layoutGroup == null ? void 0 : layoutGroup.group) && projection)
49
52
  layoutGroup.group.remove(projection);
50
- if (this.state.options.layoutId || this.state.options.layout) {
51
- (_b = (_a = this.state.visualElement.projection) == null ? void 0 : _a.root) == null ? void 0 : _b.didUpdate();
52
- }
53
+ this.didUpdate();
53
54
  }
54
55
  }
55
56
  export {
@@ -4,6 +4,7 @@ import { getClosestProjectingNode } from "./utils.mjs";
4
4
  import { addScaleCorrector } from "../../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/projection/styles/scale-correction.mjs";
5
5
  import { defaultScaleCorrector } from "./config.mjs";
6
6
  import { isHTMLElement } from "../gestures/drag/utils/is.mjs";
7
+ import { doneCallbacks } from "../../components/presence.mjs";
7
8
  class ProjectionFeature extends Feature {
8
9
  constructor(state) {
9
10
  super(state);
@@ -32,7 +33,21 @@ class ProjectionFeature extends Feature {
32
33
  // initialPromotionConfig
33
34
  layoutRoot: options.layoutRoot,
34
35
  layoutScroll: options.layoutScroll,
35
- crossfade: options.crossfade
36
+ crossfade: options.crossfade,
37
+ onExitComplete: () => {
38
+ var _a;
39
+ if (!((_a = this.state.visualElement.projection) == null ? void 0 : _a.isPresent)) {
40
+ const done = doneCallbacks.get(this.state.element);
41
+ this.state.isSafeToRemove = true;
42
+ if (done) {
43
+ done({
44
+ detail: {
45
+ isExit: true
46
+ }
47
+ }, true);
48
+ }
49
+ }
50
+ }
36
51
  });
37
52
  }
38
53
  update() {
@@ -184,7 +184,8 @@ class MotionState {
184
184
  }
185
185
  willUpdate(label) {
186
186
  var _a;
187
- (_a = this.visualElement.projection) == null ? void 0 : _a.willUpdate();
187
+ if (this.options.layout || this.options.layoutId)
188
+ (_a = this.visualElement.projection) == null ? void 0 : _a.willUpdate();
188
189
  }
189
190
  }
190
191
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-v",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",