@hilux/ngx-motion 2.1.0 → 2.2.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/README.md +36 -0
- package/fesm2022/hilux-ngx-motion.mjs +305 -5
- package/fesm2022/hilux-ngx-motion.mjs.map +1 -1
- package/package.json +1 -1
- package/types/hilux-ngx-motion.d.ts +108 -0
package/package.json
CHANGED
|
@@ -1382,4 +1382,112 @@ export declare class MotionReorderItemDirective<T = unknown> {
|
|
|
1382
1382
|
};
|
|
1383
1383
|
}]>;
|
|
1384
1384
|
}
|
|
1385
|
+
/** A layout box: centre and size, in layout coordinates (transforms and scrolling ignored). */
|
|
1386
|
+
interface Box {
|
|
1387
|
+
cx: number;
|
|
1388
|
+
cy: number;
|
|
1389
|
+
w: number;
|
|
1390
|
+
h: number;
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Where each shared layout id was last seen (its visual box, in viewport
|
|
1394
|
+
* coordinates so it holds across scroll containers), so a new element with
|
|
1395
|
+
* the same id can start from there.
|
|
1396
|
+
* @internal
|
|
1397
|
+
*/
|
|
1398
|
+
export declare class MotionLayoutRegistry {
|
|
1399
|
+
private readonly seen;
|
|
1400
|
+
record(id: string, owner: object, box: Box): void;
|
|
1401
|
+
/** The box another element left for this id, if any. */
|
|
1402
|
+
from(id: string, owner: object): Box | undefined;
|
|
1403
|
+
release(id: string, owner: object): void;
|
|
1404
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MotionLayoutRegistry, never>;
|
|
1405
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Layout animations, like Framer Motion's `layout` and `layoutId`.
|
|
1409
|
+
*
|
|
1410
|
+
* <!-- Glides to its new place (and size) whenever the layout changes -->
|
|
1411
|
+
* <li motionLayout>…</li>
|
|
1412
|
+
* <div motionLayout="position">only moves; size changes jump (good for text)</div>
|
|
1413
|
+
*
|
|
1414
|
+
* <!-- Shared element: a new element with the same id starts where the old one was -->
|
|
1415
|
+
* @for (tab of tabs; track tab) {
|
|
1416
|
+
* <button (click)="active = tab">{{ tab }}
|
|
1417
|
+
* @if (active === tab) { <span class="underline" motionLayoutId="underline"></span> }
|
|
1418
|
+
* </button>
|
|
1419
|
+
* }
|
|
1420
|
+
*
|
|
1421
|
+
* After every render it measures the element's layout box (offsets, so
|
|
1422
|
+
* transforms and scrolling don't count). When the box has changed, it jumps
|
|
1423
|
+
* back to where it was drawn (FLIP) and springs to the new place: x/y for
|
|
1424
|
+
* position, scaleX/scaleY for size. Interrupted animations continue from
|
|
1425
|
+
* where they are. Resizing the window re-measures without animating, and
|
|
1426
|
+
* with reduced motion it doesn't animate.
|
|
1427
|
+
*
|
|
1428
|
+
* - Size changes scale the element, so content would stretch while it
|
|
1429
|
+
* moves. Mark descendants with `motionLayoutCorrect` to counter-scale them
|
|
1430
|
+
* (they keep their own size), or use "position".
|
|
1431
|
+
* - Uses transform (centre origin); don't give the element a CSS transform
|
|
1432
|
+
* of its own, wrap it instead.
|
|
1433
|
+
*/
|
|
1434
|
+
export declare class MotionLayoutDirective {
|
|
1435
|
+
/** What animates: both (default, also for an empty attribute), 'position' or 'size'. */
|
|
1436
|
+
readonly motionLayout: import("@angular/core").InputSignal<boolean | "" | "position" | "size" | "both">;
|
|
1437
|
+
/** Shared layout id: an element with the same id that appears takes over from this one. */
|
|
1438
|
+
readonly motionLayoutId: import("@angular/core").InputSignal<string | null | undefined>;
|
|
1439
|
+
readonly layoutTransition: import("@angular/core").InputSignal<Record<string, unknown>>;
|
|
1440
|
+
readonly layoutAnimationStart: import("@angular/core").OutputEmitterRef<void>;
|
|
1441
|
+
readonly layoutAnimationComplete: import("@angular/core").OutputEmitterRef<void>;
|
|
1442
|
+
private readonly _animating;
|
|
1443
|
+
readonly animating: import("@angular/core").Signal<boolean>;
|
|
1444
|
+
private readonly el;
|
|
1445
|
+
private readonly motion;
|
|
1446
|
+
private readonly registry;
|
|
1447
|
+
private prev;
|
|
1448
|
+
/** Layout box to viewport offset (scrolling), measured for shared ids only. */
|
|
1449
|
+
private shift;
|
|
1450
|
+
private cur;
|
|
1451
|
+
private controls?;
|
|
1452
|
+
/** Measure again without animating (after a window resize). */
|
|
1453
|
+
private resnap;
|
|
1454
|
+
private readonly reduced;
|
|
1455
|
+
constructor();
|
|
1456
|
+
private mode;
|
|
1457
|
+
/** Layout box from offsets: unaffected by transforms (ours or anyone's) and by scrolling. */
|
|
1458
|
+
private measure;
|
|
1459
|
+
/** A box in layout coordinates moved to (or, with -1, from) viewport coordinates. */
|
|
1460
|
+
private shifted;
|
|
1461
|
+
/** Where the element is drawn: its layout box moved and scaled by our transform. */
|
|
1462
|
+
private visual;
|
|
1463
|
+
private update;
|
|
1464
|
+
private animateFrom;
|
|
1465
|
+
/**
|
|
1466
|
+
* Set our transform. Written straight to the style (not through Motion's
|
|
1467
|
+
* next frame), so what's drawn always matches `cur`: measuring and
|
|
1468
|
+
* interrupting read the same position the user sees.
|
|
1469
|
+
*/
|
|
1470
|
+
private apply;
|
|
1471
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MotionLayoutDirective, never>;
|
|
1472
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<MotionLayoutDirective, "[motionLayout], [motionLayoutId]", ["motionLayout"], {
|
|
1473
|
+
"motionLayout": {
|
|
1474
|
+
"alias": "motionLayout";
|
|
1475
|
+
"required": false;
|
|
1476
|
+
"isSignal": true;
|
|
1477
|
+
};
|
|
1478
|
+
"motionLayoutId": {
|
|
1479
|
+
"alias": "motionLayoutId";
|
|
1480
|
+
"required": false;
|
|
1481
|
+
"isSignal": true;
|
|
1482
|
+
};
|
|
1483
|
+
"layoutTransition": {
|
|
1484
|
+
"alias": "layoutTransition";
|
|
1485
|
+
"required": false;
|
|
1486
|
+
"isSignal": true;
|
|
1487
|
+
};
|
|
1488
|
+
}, {
|
|
1489
|
+
"layoutAnimationStart": "layoutAnimationStart";
|
|
1490
|
+
"layoutAnimationComplete": "layoutAnimationComplete";
|
|
1491
|
+
}, never, never, true, never>;
|
|
1492
|
+
}
|
|
1385
1493
|
export type { TimelineStep, TransitionOptions, VariantWithTransition };
|