@glissade/core 0.17.1 → 0.18.0-pre.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/index.d.ts +30 -1
- package/dist/index.js +30 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -240,9 +240,38 @@ interface TweenOpts<T = unknown> {
|
|
|
240
240
|
/** Explicit start value — sugar for fromTo; required ergonomics for string targets. */
|
|
241
241
|
from?: T;
|
|
242
242
|
}
|
|
243
|
+
/** The shared tween shape applied to every staggered target (§2.6 stagger sugar). */
|
|
244
|
+
interface StaggerSpec<T = unknown> {
|
|
245
|
+
to: T;
|
|
246
|
+
/** Explicit start value — routes each target through `fromTo` when present. */
|
|
247
|
+
from?: T;
|
|
248
|
+
duration?: number;
|
|
249
|
+
ease?: EaseSpec;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Stagger placement. `each` is the per-rank delay (seconds, number-only in v1).
|
|
253
|
+
* `from` picks the anchor the cascade ranks outward from (GSAP parity); `at`
|
|
254
|
+
* places the whole group's base position (defaults to the chain end).
|
|
255
|
+
*/
|
|
256
|
+
interface StaggerOpts {
|
|
257
|
+
each: number;
|
|
258
|
+
from?: 'start' | 'end' | 'center' | 'edges' | number;
|
|
259
|
+
at?: Position;
|
|
260
|
+
}
|
|
243
261
|
interface TimelineBuilder {
|
|
244
262
|
to<T>(target: TweenTarget, value: T, opts?: TweenOpts<T>): TimelineBuilder;
|
|
245
263
|
fromTo<T>(target: TweenTarget, from: T, to: T, opts?: TweenOpts<T>): TimelineBuilder;
|
|
264
|
+
/**
|
|
265
|
+
* Build-time sugar: loop the shipped `to`/`fromTo` emission over `targets`,
|
|
266
|
+
* cascading each by a per-rank delay. Emits keys byte-identical to N
|
|
267
|
+
* hand-authored offset tweens. The `from` anchor ranks targets over their
|
|
268
|
+
* array index i (n = targets.length, c = (n-1)/2): `'start'` → i; `'end'` →
|
|
269
|
+
* (n-1)-i; `'center'` → round(|i-c|); `'edges'` → round(c-|i-c|); numeric k →
|
|
270
|
+
* round(|i-k|). Delay d_i = rank_i * each, inserted at `base + d_i` where
|
|
271
|
+
* `base = resolvePosition(opts.at)`. The group reads as one block to a
|
|
272
|
+
* following `'<'`/`'>'`/`'+='` step.
|
|
273
|
+
*/
|
|
274
|
+
stagger<T>(targets: TweenTarget[], spec: StaggerSpec<T>, opts: StaggerOpts): TimelineBuilder;
|
|
246
275
|
/** Hold key: the value snaps at the resolved position (§2.6). */
|
|
247
276
|
set<T>(target: TweenTarget, value: T, opts?: {
|
|
248
277
|
at?: Position;
|
|
@@ -392,4 +421,4 @@ interface CheckpointedSim {
|
|
|
392
421
|
}
|
|
393
422
|
declare function bakeCheckpointed<W, S = W>(cfg: CheckpointedBakeConfig<W, S>): CheckpointedSim;
|
|
394
423
|
//#endregion
|
|
395
|
-
export { type AssetRef, type AudioClip, type BakeConfig, BakeError, type BindTarget, BindTypeMismatchError, type BindableSignal, type BoundTimeline, type CheckpointedBakeConfig, type CheckpointedSim, type ChildEntry, CircularDependencyError, ColorParseError, type ColorStop, type CompiledTimeline, type CoverageReport, type CurveSampler, DEFAULT_EASE, type DevWarning, type EaseSpec, type EasingFn, type Equals, type FontFaceRef, type FontMode, type FontRegistry, type FontUsage, FontValidationError, type GainEnvelope, type GradientInterpolation, type HandoffKind, type Json, type Key, type KeyOpts, type Marker, type MergeResult, type MeshInterpolation, type MeshPaint, type MeshPoint, type MissingGlyphs, type OkLab, type OrphanReason, type Paint, type PathContour, type PathValue, type Playhead, type Position, PositionError, type ReadonlySignal, type ResolvedFace, type RetargetSpring, type Rgba, type Rng, type Scheduler, type SidecarDoc, type SidecarDocV1, type SidecarOrphan, type SidecarTimelineEntry, type SidecarTrackEntry, SidecarVersionError, type Signal, type SignalOptions, type SpringConfig, type SpringEase, TARGET_PATH, type TargetCarrier, type Timeline, type TimelineBuilder, type TimelineInit, TimelineValidationError, type Track, TrackValidationError, type TweenOpts, type TweenTarget, UnboundTargetError, UnknownEasingError, UnknownValueTypeError, UnresolvableTargetError, type ValidateFontsOptions, type ValueType, type ValueTypeId, ValueTypeInferenceError, type Vec2, type Vec2Component, type Vec2Signal, WriteDuringEvaluationError, assignKeyIds, audioOffsetSamples, bake, bakeCheckpointed, batch, beginReadPhase, bindTimeline, booleanType, buildFontRegistry, buildTimeline, colorType, compileTimeline, computed, createPlayhead, cubicBezier, cubicBezierDerivative, deleteSidecarTrack, easingDerivatives, easings, emitDevWarning, emptySidecar, endReadPhase, evaluateAt, formatColor, getTimelineCallbacks, getValueType, hashKeys, inReadPhase, inferValueType, isDurationEditable, isEditableNodeId, isExemptFamily, key, lerpColor, mergeSidecar, mergeSidecarDetailed, migrateSidecar, namedEasing, normalizeEditedKeys, numberType, oklabToRgba, paintType, parseCmap, parseColor, pathType, random, registerValueType, reprOf, resolveEase, resolveEaseDerivative, resolveTweenTarget, rgbaToOklab, sampleTrack, setDevWarning, setScheduler, setSidecarTrack, signal, spring, springEasing, springEasingDerivative, springPresets, springTo, stagger, stringType, synchronousScheduler, targetNodeId, timeline, track, untracked, validateFonts, validateTrack, vec2ArcType, vec2Equals, vec2Signal, vec2Type, velocityAt };
|
|
424
|
+
export { type AssetRef, type AudioClip, type BakeConfig, BakeError, type BindTarget, BindTypeMismatchError, type BindableSignal, type BoundTimeline, type CheckpointedBakeConfig, type CheckpointedSim, type ChildEntry, CircularDependencyError, ColorParseError, type ColorStop, type CompiledTimeline, type CoverageReport, type CurveSampler, DEFAULT_EASE, type DevWarning, type EaseSpec, type EasingFn, type Equals, type FontFaceRef, type FontMode, type FontRegistry, type FontUsage, FontValidationError, type GainEnvelope, type GradientInterpolation, type HandoffKind, type Json, type Key, type KeyOpts, type Marker, type MergeResult, type MeshInterpolation, type MeshPaint, type MeshPoint, type MissingGlyphs, type OkLab, type OrphanReason, type Paint, type PathContour, type PathValue, type Playhead, type Position, PositionError, type ReadonlySignal, type ResolvedFace, type RetargetSpring, type Rgba, type Rng, type Scheduler, type SidecarDoc, type SidecarDocV1, type SidecarOrphan, type SidecarTimelineEntry, type SidecarTrackEntry, SidecarVersionError, type Signal, type SignalOptions, type SpringConfig, type SpringEase, type StaggerOpts, type StaggerSpec, TARGET_PATH, type TargetCarrier, type Timeline, type TimelineBuilder, type TimelineInit, TimelineValidationError, type Track, TrackValidationError, type TweenOpts, type TweenTarget, UnboundTargetError, UnknownEasingError, UnknownValueTypeError, UnresolvableTargetError, type ValidateFontsOptions, type ValueType, type ValueTypeId, ValueTypeInferenceError, type Vec2, type Vec2Component, type Vec2Signal, WriteDuringEvaluationError, assignKeyIds, audioOffsetSamples, bake, bakeCheckpointed, batch, beginReadPhase, bindTimeline, booleanType, buildFontRegistry, buildTimeline, colorType, compileTimeline, computed, createPlayhead, cubicBezier, cubicBezierDerivative, deleteSidecarTrack, easingDerivatives, easings, emitDevWarning, emptySidecar, endReadPhase, evaluateAt, formatColor, getTimelineCallbacks, getValueType, hashKeys, inReadPhase, inferValueType, isDurationEditable, isEditableNodeId, isExemptFamily, key, lerpColor, mergeSidecar, mergeSidecarDetailed, migrateSidecar, namedEasing, normalizeEditedKeys, numberType, oklabToRgba, paintType, parseCmap, parseColor, pathType, random, registerValueType, reprOf, resolveEase, resolveEaseDerivative, resolveTweenTarget, rgbaToOklab, sampleTrack, setDevWarning, setScheduler, setSidecarTrack, signal, spring, springEasing, springEasingDerivative, springPresets, springTo, stagger, stringType, synchronousScheduler, targetNodeId, timeline, track, untracked, validateFonts, validateTrack, vec2ArcType, vec2Equals, vec2Signal, vec2Type, velocityAt };
|
package/dist/index.js
CHANGED
|
@@ -643,6 +643,36 @@ function buildTimeline(build, init = {}) {
|
|
|
643
643
|
insertions[insertions.length - 1].explicitFrom = from;
|
|
644
644
|
return builder;
|
|
645
645
|
},
|
|
646
|
+
stagger(targets, spec, opts) {
|
|
647
|
+
const n = targets.length;
|
|
648
|
+
const base = resolvePosition(opts.at);
|
|
649
|
+
const c = (n - 1) / 2;
|
|
650
|
+
const rankOf = (i) => {
|
|
651
|
+
const f = opts.from ?? "start";
|
|
652
|
+
if (f === "start") return i;
|
|
653
|
+
if (f === "end") return n - 1 - i;
|
|
654
|
+
if (f === "center") return Math.round(Math.abs(i - c));
|
|
655
|
+
if (f === "edges") return Math.round(c - Math.abs(i - c));
|
|
656
|
+
return Math.round(Math.abs(i - f));
|
|
657
|
+
};
|
|
658
|
+
const duration = spec.duration ?? 1;
|
|
659
|
+
let maxDelay = 0;
|
|
660
|
+
const tweenOpts = (d) => ({
|
|
661
|
+
at: base + d,
|
|
662
|
+
...spec.duration !== void 0 ? { duration: spec.duration } : {},
|
|
663
|
+
...spec.ease !== void 0 ? { ease: spec.ease } : {}
|
|
664
|
+
});
|
|
665
|
+
for (let i = 0; i < n; i++) {
|
|
666
|
+
const d = rankOf(i) * opts.each;
|
|
667
|
+
if (d > maxDelay) maxDelay = d;
|
|
668
|
+
const t = targets[i];
|
|
669
|
+
if (spec.from !== void 0) builder.fromTo(t, spec.from, spec.to, tweenOpts(d));
|
|
670
|
+
else builder.to(t, spec.to, tweenOpts(d));
|
|
671
|
+
}
|
|
672
|
+
prevStart = base;
|
|
673
|
+
prevEnd = base + maxDelay + duration;
|
|
674
|
+
return builder;
|
|
675
|
+
},
|
|
646
676
|
set(target, value, opts = {}) {
|
|
647
677
|
const start = resolvePosition(opts.at);
|
|
648
678
|
insertions.push({
|
package/package.json
CHANGED