@motion.page/sdk 1.1.1 → 1.1.3

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.
@@ -58,6 +58,7 @@ export declare class Animation {
58
58
  private _pendingFitSetup;
59
59
  private _fitCleanupFn;
60
60
  private _unregisterCallback;
61
+ private _activationCallback;
61
62
  /**
62
63
  * Initialize the animation
63
64
  */
@@ -190,6 +191,11 @@ export declare class Animation {
190
191
  * This avoids circular dependency with Engine
191
192
  */
192
193
  setUnregisterCallback(callback: () => void): void;
194
+ /**
195
+ * Set callback invoked whenever this animation becomes active.
196
+ * Used by Engine to restart the global ticker after it idles.
197
+ */
198
+ setActivationCallback(callback: () => void): void;
193
199
  /**
194
200
  * Capture current element values as start values for all PropTweens
195
201
  * This enables proper chaining in timelines
@@ -25,6 +25,7 @@ export declare class Engine {
25
25
  private timelines;
26
26
  private _captureTarget;
27
27
  private ticker;
28
+ private _tickerSubscribed;
28
29
  private animationPool;
29
30
  private propTweenPool;
30
31
  private constructor();
@@ -36,6 +37,9 @@ export declare class Engine {
36
37
  * Main update loop called by Ticker
37
38
  */
38
39
  private update;
40
+ private _ensureTickerSubscription;
41
+ private _hasActiveWork;
42
+ private _releaseTickerIfIdle;
39
43
  /**
40
44
  * Create a new animation (called by AnimationBuilder)
41
45
  * Returns either a single Animation or an array of Animations (for stagger)
@@ -21,11 +21,17 @@ export declare class Timeline {
21
21
  * @internal
22
22
  */
23
23
  private static _registerWithEngine;
24
+ private static _activateEngine;
24
25
  /**
25
26
  * Set the engine registration callback. Called once by Engine during initialization.
26
27
  * @internal
27
28
  */
28
29
  static setEngineRegisterCallback(callback: (name: string, timeline: Timeline) => void): void;
30
+ /**
31
+ * Set the engine activation callback. Called once by Engine during initialization.
32
+ * @internal
33
+ */
34
+ static setEngineActivationCallback(callback: () => void): void;
29
35
  private _name?;
30
36
  private _children;
31
37
  private _duration;
@@ -62,6 +68,7 @@ export declare class Timeline {
62
68
  * @internal
63
69
  */
64
70
  setUnregisterCallback(callback: () => void): void;
71
+ private _notifyActivated;
65
72
  private _previousStart;
66
73
  private _previousEnd;
67
74
  private _eachInstances?;
@@ -149,10 +156,34 @@ export declare class Timeline {
149
156
  private _createInstanceForElement;
150
157
  /**
151
158
  * Create a timeline instance for multiple elements (for each mode with explicit container target).
152
- * This is a sibling of _createInstanceForElement — the only difference is that it accepts an
153
- * Element[] and passes the array directly to AnimationBuilder instead of a single element.
159
+ * This is a sibling of _createInstanceForElement — the difference is that it accepts an
160
+ * Element[] of scoped targets (animation targets belonging to one container).
161
+ *
162
+ * Per-builder filtering: each cloned builder ONLY animates the subset of `elements`
163
+ * that the original builder targeted. Without this, a builder for `.subtitle` would
164
+ * also animate `.eyebrow` and `.section-title` elements that happen to share the
165
+ * same scoped container — producing visually broken animations.
154
166
  */
155
167
  private _createInstanceForElements;
168
+ /**
169
+ * Find animation targets that "belong" to a container in each-mode.
170
+ *
171
+ * Strategy 1 (preferred): the container itself (when it's also an animation
172
+ * target) and/or its descendants. Covers the most common Builder workflow
173
+ * where the trigger target IS the animation target (e.g.
174
+ * `.onScroll({ target: '.fade-up', each: true })` animating `.fade-up`),
175
+ * as well as parent-child setups (e.g. `.section-header` containing
176
+ * `.eyebrow`/`.subtitle`).
177
+ * Strategy 2 (sibling fallback): anim targets sharing the container's parent
178
+ * that aren't owned by another container.
179
+ *
180
+ * Returns [] when neither strategy yields targets — the caller skips this
181
+ * container, dropping the orphaned anim targets entirely. This matches the
182
+ * documented behaviour: when each:true + explicit target is set, only anim
183
+ * targets associated with a container (self, descendant, or sibling) are
184
+ * animated.
185
+ */
186
+ private _findScopedTargetsForContainer;
156
187
  /**
157
188
  * Resolve a CSS selector string or Element into an array of DOM elements.
158
189
  */