@hilux/ngx-motion 2.3.0 → 2.4.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 +44 -0
- package/fesm2022/hilux-ngx-motion.mjs +325 -3
- package/fesm2022/hilux-ngx-motion.mjs.map +1 -1
- package/package.json +1 -1
- package/types/hilux-ngx-motion.d.ts +146 -1
package/README.md
CHANGED
|
@@ -54,6 +54,7 @@ export class CardComponent {}
|
|
|
54
54
|
- **Drag:** `motionDrag` with constraints, elastic edges, momentum and snap points (carousels, sliders, card stacks).
|
|
55
55
|
- **Pan and swipe:** `motionPan` reports pointer movement and swipe directions, with `whilePan` styles.
|
|
56
56
|
- **Reorder:** `motionReorderGroup` and `motionReorderItem` for drag-to-reorder lists, with keyboard support.
|
|
57
|
+
- **Motion values:** `motionSignal`, `mapSignal`, `springSignal`, `velocitySignal` and `scrollSignal`: values that change every frame, as Angular signals, bound to styles with `[motionStyle]` without change detection.
|
|
57
58
|
- **Layout animations:** `motionLayout` glides elements to their new place and size after any layout change, and `motionLayoutId` makes shared-element transitions.
|
|
58
59
|
- **Exit animations:** `*motionIf` and `*motionPresence` keep elements in the DOM until their exit animation finishes. If shown again mid-exit, they animate back in.
|
|
59
60
|
- **Variants:** named, reusable animation states.
|
|
@@ -329,6 +330,44 @@ Drag-to-reorder lists, like Framer Motion's `Reorder.Group` and `Reorder.Item`.
|
|
|
329
330
|
- Keyboard: on a focused item (give it `tabindex="0"`), Alt + arrow keys move it one place.
|
|
330
331
|
- Track items by identity in `@for` (not `$index`) so elements move with their values. Items can be different sizes.
|
|
331
332
|
|
|
333
|
+
### Motion Values
|
|
334
|
+
Values that change every frame, like Framer Motion's `useMotionValue`, `useTransform`, `useSpring`, `useVelocity` and `useScroll`, as Angular signals. Read one in a template like any signal, or bind it with `[motionStyle]`: the directive writes each change straight to the element, so nothing re-renders while it moves.
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
import { MotionStyleDirective, mapSignal, motionSignal, scrollSignal, springSignal, velocitySignal } from '@hilux/ngx-motion';
|
|
338
|
+
|
|
339
|
+
@Component({
|
|
340
|
+
imports: [MotionStyleDirective, MotionPanDirective],
|
|
341
|
+
template: `
|
|
342
|
+
<div motionPan="x" (pan)="drag.set($event.offset.x)" (panEnd)="drag.set(0)"
|
|
343
|
+
[motionStyle]="{ x: x, backgroundColor: colour }">{{ label() }}</div>
|
|
344
|
+
<div class="bar" [motionStyle]="{ scaleX: scroll.progress, skewY: skew }"></div>
|
|
345
|
+
`,
|
|
346
|
+
})
|
|
347
|
+
export class Example {
|
|
348
|
+
readonly drag = motionSignal(0); // useMotionValue
|
|
349
|
+
readonly x = springSignal(this.drag, { stiffness: 500, damping: 40 }); // useSpring: follows drag
|
|
350
|
+
readonly colour = mapSignal(this.x, [-140, 0, 140], ['#f87171', '#3a3a3a', '#86efac']); // useTransform
|
|
351
|
+
readonly label = mapSignal(this.x, v => `${Math.round(v)}px`);
|
|
352
|
+
readonly scroll = scrollSignal(); // useScroll: progress, offset, velocity
|
|
353
|
+
readonly skew = mapSignal(velocitySignal(this.scroll.offset), [-3000, 3000], [-10, 10]); // useVelocity
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
| Function | What it gives you |
|
|
358
|
+
|---|---|
|
|
359
|
+
| `motionSignal(initial)` | A writable value: `x()` (tracked), `x.get()` (untracked), `x.set(v)`, `x.on(fn)` (every change, outside change detection), `x.getVelocity()` |
|
|
360
|
+
| `mapSignal(source, [in], [out], { clamp, ease })` | Maps a range to another: numbers, colours, or strings with units. Clamped by default |
|
|
361
|
+
| `mapSignal(source, fn)` / `mapSignal([a, b], fn)` | Any function of one or more values |
|
|
362
|
+
| `springSignal(target \| source, { stiffness, damping, mass })` | Springs to `set()` targets, or follows a source; keeps its speed when the target changes. `jump(v)` skips the spring |
|
|
363
|
+
| `velocitySignal(source)` | Speed per second; back to 0 when the source stops |
|
|
364
|
+
| `scrollSignal({ container, target, offset, axis })` | `progress` (0 to 1), `offset` (px) and `velocity` for the page or an element; `container` and `target` can be `viewChild` signals |
|
|
365
|
+
|
|
366
|
+
- Sources can be motion signals or any Angular signal (those update with change detection).
|
|
367
|
+
- `springSignal`, `velocitySignal` and `scrollSignal` must be created in an injection context (a field or the constructor), or given `{ injector }`. They clean up when it's destroyed.
|
|
368
|
+
- `[motionStyle]`: transform shortcuts `x`, `y`, `z` (px), `scale`, `scaleX`, `scaleY`, `rotate`, `rotateX/Y/Z`, `skewX/Y` (deg) are combined into `transform`, so don't animate the same element's transform another way. Other styles use camelCase names; numbers get px except unitless ones such as `opacity`. CSS custom properties (`'--progress'`) take any value.
|
|
369
|
+
- With reduced motion, and on the server, springs go straight to their target.
|
|
370
|
+
|
|
332
371
|
### Layout Animations
|
|
333
372
|
Like Framer Motion's `layout` and `layoutId`. Change the layout however you like (reorder or filter a list, switch flex to grid, toggle a class) and `motionLayout` animates each element from where it was drawn to where it is now. No positions to calculate.
|
|
334
373
|
|
|
@@ -463,6 +502,8 @@ The directives work seamlessly with Angular's new control flow syntax:
|
|
|
463
502
|
| `drag`, `dragConstraints`, `dragElastic`, `dragMomentum` | `motionDrag`, `dragConstraints`, `dragElastic`, `dragMomentum` |
|
|
464
503
|
| `onPan`, `whilePan` | `motionPan` with `(pan)`, `[whilePan]` |
|
|
465
504
|
| `<Reorder.Group values onReorder>` / `<Reorder.Item value>` | `[(motionReorderGroup)]` / `[motionReorderItem]` |
|
|
505
|
+
| `useMotionValue`, `useTransform`, `useSpring`, `useVelocity`, `useScroll` | `motionSignal`, `mapSignal`, `springSignal`, `velocitySignal`, `scrollSignal` |
|
|
506
|
+
| `style={{ x, opacity }}` with motion values | `[motionStyle]="{ x: x, opacity: opacity }"` |
|
|
466
507
|
| `layout`, `layout="position"` | `motionLayout`, `motionLayout="position"` |
|
|
467
508
|
| `layoutId` | `motionLayoutId` |
|
|
468
509
|
| `<LayoutGroup>` | not needed: every layout element is measured after every render |
|
|
@@ -495,6 +536,9 @@ A lot of animation is plain CSS now, and where CSS is enough it is the better ch
|
|
|
495
536
|
|
|
496
537
|
## Changelog
|
|
497
538
|
|
|
539
|
+
**2.4.0**
|
|
540
|
+
- Motion values as Angular signals: `motionSignal`, `mapSignal`, `springSignal`, `velocitySignal` and `scrollSignal`, and the `[motionStyle]` directive, which writes them to the element without change detection. See [Motion Values](#motion-values).
|
|
541
|
+
|
|
498
542
|
**2.3.0**
|
|
499
543
|
- Shared layout elements that stay mounted: while two elements with the same `motionLayoutId` are mounted, the newer one is shown and the older hidden, and when the newer one is removed the older one flies back from it (thumbnail and lightbox).
|
|
500
544
|
- Layout animations keep corner radii round while scaling, and add the class `motion-layout-animating` while an element moves.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { ChangeDetectorRef, DOCUMENT, DestroyRef, Directive, ElementRef, EventEmitter, HostListener, Inject, Injectable, Injector, Input, NgZone, Output, PLATFORM_ID, TemplateRef, ViewContainerRef, afterEveryRender, afterNextRender, afterRenderEffect, effect, forwardRef, inject, input, isDevMode, model, output, signal, untracked } from "@angular/core";
|
|
2
|
+
import { ChangeDetectorRef, DOCUMENT, DestroyRef, Directive, ElementRef, EventEmitter, HostListener, Inject, Injectable, Injector, Input, NgZone, Output, PLATFORM_ID, TemplateRef, ViewContainerRef, afterEveryRender, afterNextRender, afterRenderEffect, assertInInjectionContext, effect, forwardRef, inject, input, isDevMode, isSignal, model, output, signal, untracked } from "@angular/core";
|
|
3
3
|
import { isPlatformBrowser } from "@angular/common";
|
|
4
4
|
import { Subject, timer } from "rxjs";
|
|
5
5
|
import { map, take } from "rxjs/operators";
|
|
6
|
-
import { animate, easeIn, easeInOut, easeOut, inView, scroll, spring, stagger } from "motion";
|
|
6
|
+
import { animate, easeIn, easeInOut, easeOut, inView, scroll, spring, stagger, transform } from "motion";
|
|
7
7
|
var MotionOneService = class MotionOneService {
|
|
8
8
|
document;
|
|
9
9
|
platformId;
|
|
@@ -4154,6 +4154,328 @@ function lerp(a, b, p) {
|
|
|
4154
4154
|
sy: a.sy + (b.sy - a.sy) * p
|
|
4155
4155
|
};
|
|
4156
4156
|
}
|
|
4157
|
-
|
|
4157
|
+
const BRAND = Symbol("MotionSignal");
|
|
4158
|
+
function isMotionSignal(value) {
|
|
4159
|
+
return typeof value === "function" && value[BRAND] === true;
|
|
4160
|
+
}
|
|
4161
|
+
const SETTLE_MS = 50;
|
|
4162
|
+
const MIN_SPAN_MS = 16;
|
|
4163
|
+
function motionSignal(initial) {
|
|
4164
|
+
const state = signal(initial, ...ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []);
|
|
4165
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
4166
|
+
let samples = [];
|
|
4167
|
+
let lastTime = 0;
|
|
4168
|
+
const now = () => typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
4169
|
+
const read = (() => state());
|
|
4170
|
+
Object.defineProperty(read, BRAND, { value: true });
|
|
4171
|
+
read.get = () => untracked(state);
|
|
4172
|
+
read.on = (listener) => {
|
|
4173
|
+
listeners.add(listener);
|
|
4174
|
+
return () => listeners.delete(listener);
|
|
4175
|
+
};
|
|
4176
|
+
read.getVelocity = () => {
|
|
4177
|
+
if (now() - lastTime > SETTLE_MS || samples.length < 2) return 0;
|
|
4178
|
+
const last = samples[samples.length - 1];
|
|
4179
|
+
let ref = samples[0];
|
|
4180
|
+
for (let i = samples.length - 2; i >= 0; i--) if (last.t - samples[i].t >= MIN_SPAN_MS) {
|
|
4181
|
+
ref = samples[i];
|
|
4182
|
+
break;
|
|
4183
|
+
}
|
|
4184
|
+
const dt = last.t - ref.t;
|
|
4185
|
+
return dt >= MIN_SPAN_MS / 2 ? (last.v - ref.v) / dt * 1e3 : 0;
|
|
4186
|
+
};
|
|
4187
|
+
read.set = (value) => {
|
|
4188
|
+
const previous = untracked(state);
|
|
4189
|
+
if (Object.is(previous, value)) return;
|
|
4190
|
+
const t = now();
|
|
4191
|
+
if (typeof value === "number") {
|
|
4192
|
+
if (t - lastTime > SETTLE_MS) samples = [];
|
|
4193
|
+
samples.push({
|
|
4194
|
+
t,
|
|
4195
|
+
v: value
|
|
4196
|
+
});
|
|
4197
|
+
if (samples.length > 8) samples = samples.slice(-8);
|
|
4198
|
+
}
|
|
4199
|
+
lastTime = t;
|
|
4200
|
+
state.set(value);
|
|
4201
|
+
for (const listener of [...listeners]) listener(value);
|
|
4202
|
+
};
|
|
4203
|
+
return read;
|
|
4204
|
+
}
|
|
4205
|
+
function mapSignal(source, mapOrInput, outputOrOptions, rangeOptions) {
|
|
4206
|
+
const sources = Array.isArray(source) ? source : [source];
|
|
4207
|
+
let compute;
|
|
4208
|
+
let options;
|
|
4209
|
+
const value = (s) => isMotionSignal(s) ? s.get() : untracked(s);
|
|
4210
|
+
if (typeof mapOrInput === "function") {
|
|
4211
|
+
const map = mapOrInput;
|
|
4212
|
+
options = outputOrOptions;
|
|
4213
|
+
compute = Array.isArray(source) ? () => map(sources.map(value)) : () => map(value(sources[0]));
|
|
4214
|
+
} else {
|
|
4215
|
+
options = rangeOptions;
|
|
4216
|
+
const mapper = transform(mapOrInput, outputOrOptions, {
|
|
4217
|
+
clamp: rangeOptions?.clamp ?? true,
|
|
4218
|
+
ease: rangeOptions?.ease
|
|
4219
|
+
});
|
|
4220
|
+
compute = () => mapper(value(sources[0]));
|
|
4221
|
+
}
|
|
4222
|
+
const out = motionSignal(compute());
|
|
4223
|
+
connect(sources, () => out.set(compute()), options);
|
|
4224
|
+
return out;
|
|
4225
|
+
}
|
|
4226
|
+
function springSignal(source, options = {}) {
|
|
4227
|
+
const injector = injectorFor(springSignal, options);
|
|
4228
|
+
const zone = injector.get(NgZone);
|
|
4229
|
+
const browser = isPlatformBrowser(injector.get(PLATFORM_ID)) && typeof requestAnimationFrame !== "undefined";
|
|
4230
|
+
const reduced = browser && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
4231
|
+
const { stiffness = 300, damping = 30, mass = 1, restDelta = .01, restSpeed = .05 } = options;
|
|
4232
|
+
const start = typeof source === "number" ? source : isMotionSignal(source) ? source.get() : untracked(source);
|
|
4233
|
+
const value = motionSignal(start);
|
|
4234
|
+
let position = start;
|
|
4235
|
+
let velocity = 0;
|
|
4236
|
+
let target = start;
|
|
4237
|
+
let raf = 0;
|
|
4238
|
+
let last = 0;
|
|
4239
|
+
const stop = () => {
|
|
4240
|
+
if (raf) cancelAnimationFrame(raf);
|
|
4241
|
+
raf = 0;
|
|
4242
|
+
};
|
|
4243
|
+
const step = (time) => {
|
|
4244
|
+
let dt = Math.min(time > last ? time - last : 16, 64) / 1e3;
|
|
4245
|
+
last = time;
|
|
4246
|
+
while (dt > 0) {
|
|
4247
|
+
const h = Math.min(dt, .004);
|
|
4248
|
+
const accel = (-stiffness * (position - target) - damping * velocity) / mass;
|
|
4249
|
+
velocity += accel * h;
|
|
4250
|
+
position += velocity * h;
|
|
4251
|
+
dt -= h;
|
|
4252
|
+
}
|
|
4253
|
+
if (Math.abs(velocity) < restSpeed && Math.abs(position - target) < restDelta) {
|
|
4254
|
+
position = target;
|
|
4255
|
+
velocity = 0;
|
|
4256
|
+
raf = 0;
|
|
4257
|
+
} else raf = requestAnimationFrame(step);
|
|
4258
|
+
value.set(position);
|
|
4259
|
+
};
|
|
4260
|
+
const out = (() => value());
|
|
4261
|
+
Object.defineProperty(out, BRAND, { value: true });
|
|
4262
|
+
out.get = value.get;
|
|
4263
|
+
out.on = value.on;
|
|
4264
|
+
out.getVelocity = () => velocity;
|
|
4265
|
+
out.jump = (v) => {
|
|
4266
|
+
stop();
|
|
4267
|
+
position = target = v;
|
|
4268
|
+
velocity = 0;
|
|
4269
|
+
value.set(v);
|
|
4270
|
+
};
|
|
4271
|
+
out.set = (next) => {
|
|
4272
|
+
if (!browser || reduced) return out.jump(next);
|
|
4273
|
+
target = next;
|
|
4274
|
+
if (raf || position === target && velocity === 0) return;
|
|
4275
|
+
last = performance.now();
|
|
4276
|
+
zone.runOutsideAngular(() => raf = requestAnimationFrame(step));
|
|
4277
|
+
};
|
|
4278
|
+
if (typeof source !== "number") connect([source], () => out.set(isMotionSignal(source) ? source.get() : untracked(source)), options);
|
|
4279
|
+
injector.get(DestroyRef).onDestroy(stop);
|
|
4280
|
+
return out;
|
|
4281
|
+
}
|
|
4282
|
+
function velocitySignal(source, options = {}) {
|
|
4283
|
+
const injector = injectorFor(velocitySignal, options);
|
|
4284
|
+
const zone = injector.get(NgZone);
|
|
4285
|
+
const out = motionSignal(0);
|
|
4286
|
+
let raf = 0;
|
|
4287
|
+
const check = () => {
|
|
4288
|
+
raf = 0;
|
|
4289
|
+
const v = source.getVelocity();
|
|
4290
|
+
out.set(v);
|
|
4291
|
+
if (v !== 0) raf = requestAnimationFrame(check);
|
|
4292
|
+
};
|
|
4293
|
+
const stop = source.on(() => {
|
|
4294
|
+
out.set(source.getVelocity());
|
|
4295
|
+
if (!raf && typeof requestAnimationFrame !== "undefined") zone.runOutsideAngular(() => raf = requestAnimationFrame(check));
|
|
4296
|
+
});
|
|
4297
|
+
injector.get(DestroyRef).onDestroy(() => {
|
|
4298
|
+
stop();
|
|
4299
|
+
if (raf) cancelAnimationFrame(raf);
|
|
4300
|
+
});
|
|
4301
|
+
return out;
|
|
4302
|
+
}
|
|
4303
|
+
function scrollSignal(options = {}) {
|
|
4304
|
+
const injector = injectorFor(scrollSignal, options);
|
|
4305
|
+
const progress = motionSignal(0);
|
|
4306
|
+
const offset = motionSignal(0);
|
|
4307
|
+
const velocity = motionSignal(0);
|
|
4308
|
+
let cancel;
|
|
4309
|
+
if (isPlatformBrowser(injector.get(PLATFORM_ID))) afterNextRender(() => {
|
|
4310
|
+
const resolve = (e) => {
|
|
4311
|
+
const v = typeof e === "function" ? e() : e;
|
|
4312
|
+
return v instanceof ElementRef ? v.nativeElement : v ?? void 0;
|
|
4313
|
+
};
|
|
4314
|
+
const container = resolve(options.container);
|
|
4315
|
+
const target = resolve(options.target);
|
|
4316
|
+
const axis = options.axis ?? "y";
|
|
4317
|
+
injector.get(NgZone).runOutsideAngular(() => {
|
|
4318
|
+
cancel = scroll((p, info) => {
|
|
4319
|
+
progress.set(p);
|
|
4320
|
+
offset.set(info[axis].current);
|
|
4321
|
+
velocity.set(info[axis].velocity);
|
|
4322
|
+
}, {
|
|
4323
|
+
container,
|
|
4324
|
+
target,
|
|
4325
|
+
offset: options.offset,
|
|
4326
|
+
axis
|
|
4327
|
+
});
|
|
4328
|
+
});
|
|
4329
|
+
}, { injector });
|
|
4330
|
+
injector.get(DestroyRef).onDestroy(() => cancel?.());
|
|
4331
|
+
return {
|
|
4332
|
+
progress,
|
|
4333
|
+
offset,
|
|
4334
|
+
velocity
|
|
4335
|
+
};
|
|
4336
|
+
}
|
|
4337
|
+
function connect(sources, update, options) {
|
|
4338
|
+
const stops = sources.filter(isMotionSignal).map((s) => s.on(update));
|
|
4339
|
+
const plain = sources.filter((s) => !isMotionSignal(s));
|
|
4340
|
+
const injector = options?.injector ?? tryInject();
|
|
4341
|
+
if (plain.length) {
|
|
4342
|
+
if (!injector) throw new Error("ngx-motion: a plain Angular signal source needs an injection context or the `injector` option.");
|
|
4343
|
+
effect(() => {
|
|
4344
|
+
for (const s of plain) s();
|
|
4345
|
+
untracked(update);
|
|
4346
|
+
}, { injector });
|
|
4347
|
+
}
|
|
4348
|
+
if (stops.length && injector) injector.get(DestroyRef).onDestroy(() => stops.forEach((stop) => stop()));
|
|
4349
|
+
}
|
|
4350
|
+
function tryInject() {
|
|
4351
|
+
try {
|
|
4352
|
+
return inject(Injector);
|
|
4353
|
+
} catch {
|
|
4354
|
+
return;
|
|
4355
|
+
}
|
|
4356
|
+
}
|
|
4357
|
+
function injectorFor(fn, options) {
|
|
4358
|
+
if (options.injector) return options.injector;
|
|
4359
|
+
assertInInjectionContext(fn);
|
|
4360
|
+
return inject(Injector);
|
|
4361
|
+
}
|
|
4362
|
+
const TRANSFORMS = [
|
|
4363
|
+
"x",
|
|
4364
|
+
"y",
|
|
4365
|
+
"z",
|
|
4366
|
+
"scale",
|
|
4367
|
+
"scaleX",
|
|
4368
|
+
"scaleY",
|
|
4369
|
+
"rotate",
|
|
4370
|
+
"rotateX",
|
|
4371
|
+
"rotateY",
|
|
4372
|
+
"rotateZ",
|
|
4373
|
+
"skewX",
|
|
4374
|
+
"skewY"
|
|
4375
|
+
];
|
|
4376
|
+
const TRANSFORM_FN = {
|
|
4377
|
+
x: "translateX",
|
|
4378
|
+
y: "translateY",
|
|
4379
|
+
z: "translateZ"
|
|
4380
|
+
};
|
|
4381
|
+
const UNITLESS = /* @__PURE__ */ new Set([
|
|
4382
|
+
"opacity",
|
|
4383
|
+
"zIndex",
|
|
4384
|
+
"fontWeight",
|
|
4385
|
+
"lineHeight",
|
|
4386
|
+
"flex",
|
|
4387
|
+
"flexGrow",
|
|
4388
|
+
"flexShrink",
|
|
4389
|
+
"order",
|
|
4390
|
+
"zoom",
|
|
4391
|
+
"fillOpacity",
|
|
4392
|
+
"strokeOpacity"
|
|
4393
|
+
]);
|
|
4394
|
+
var MotionStyleDirective = class MotionStyleDirective {
|
|
4395
|
+
motionStyle = input(null, ...ngDevMode ? [{ debugName: "motionStyle" }] : /* istanbul ignore next */ []);
|
|
4396
|
+
el = inject(ElementRef).nativeElement;
|
|
4397
|
+
transform = /* @__PURE__ */ new Map();
|
|
4398
|
+
constructor() {
|
|
4399
|
+
effect((onCleanup) => {
|
|
4400
|
+
const styles = this.motionStyle() ?? {};
|
|
4401
|
+
const stops = [];
|
|
4402
|
+
for (const [key, v] of Object.entries(styles)) if (isMotionSignal(v)) {
|
|
4403
|
+
this.write(key, v.get());
|
|
4404
|
+
stops.push(v.on((value) => this.write(key, value)));
|
|
4405
|
+
} else if (isSignal(v) || typeof v === "function") {
|
|
4406
|
+
const value = v();
|
|
4407
|
+
untracked(() => this.write(key, value));
|
|
4408
|
+
} else this.write(key, v);
|
|
4409
|
+
onCleanup(() => {
|
|
4410
|
+
stops.forEach((stop) => stop());
|
|
4411
|
+
for (const key of Object.keys(styles)) if (!(key in (untracked(this.motionStyle) ?? {}))) this.write(key, null);
|
|
4412
|
+
});
|
|
4413
|
+
});
|
|
4414
|
+
}
|
|
4415
|
+
write(key, value) {
|
|
4416
|
+
if (TRANSFORMS.includes(key)) {
|
|
4417
|
+
if (value == null) this.transform.delete(key);
|
|
4418
|
+
else this.transform.set(key, value);
|
|
4419
|
+
this.el.style.transform = this.transformString();
|
|
4420
|
+
return;
|
|
4421
|
+
}
|
|
4422
|
+
const css = value == null ? "" : typeof value === "number" && !UNITLESS.has(key) && !key.startsWith("--") ? `${value}px` : String(value);
|
|
4423
|
+
if (key.startsWith("--")) this.el.style.setProperty(key, css);
|
|
4424
|
+
else this.el.style[key] = css;
|
|
4425
|
+
}
|
|
4426
|
+
transformString() {
|
|
4427
|
+
let out = "";
|
|
4428
|
+
for (const key of TRANSFORMS) {
|
|
4429
|
+
const v = this.transform.get(key);
|
|
4430
|
+
if (v === void 0) continue;
|
|
4431
|
+
const unit = typeof v !== "number" ? "" : key === "x" || key === "y" || key === "z" ? "px" : key.startsWith("scale") ? "" : "deg";
|
|
4432
|
+
out += `${TRANSFORM_FN[key] ?? key}(${v}${unit}) `;
|
|
4433
|
+
}
|
|
4434
|
+
return out.trim();
|
|
4435
|
+
}
|
|
4436
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
4437
|
+
minVersion: "12.0.0",
|
|
4438
|
+
version: "22.3.2",
|
|
4439
|
+
ngImport: i0,
|
|
4440
|
+
type: MotionStyleDirective,
|
|
4441
|
+
deps: [],
|
|
4442
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
4443
|
+
});
|
|
4444
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
4445
|
+
minVersion: "17.1.0",
|
|
4446
|
+
version: "22.3.2",
|
|
4447
|
+
type: MotionStyleDirective,
|
|
4448
|
+
isStandalone: true,
|
|
4449
|
+
selector: "[motionStyle]",
|
|
4450
|
+
inputs: { motionStyle: {
|
|
4451
|
+
classPropertyName: "motionStyle",
|
|
4452
|
+
publicName: "motionStyle",
|
|
4453
|
+
isSignal: true,
|
|
4454
|
+
isRequired: false,
|
|
4455
|
+
transformFunction: null
|
|
4456
|
+
} },
|
|
4457
|
+
ngImport: i0
|
|
4458
|
+
});
|
|
4459
|
+
};
|
|
4460
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
4461
|
+
minVersion: "12.0.0",
|
|
4462
|
+
version: "22.3.2",
|
|
4463
|
+
ngImport: i0,
|
|
4464
|
+
type: MotionStyleDirective,
|
|
4465
|
+
decorators: [{
|
|
4466
|
+
type: Directive,
|
|
4467
|
+
args: [{ selector: "[motionStyle]" }]
|
|
4468
|
+
}],
|
|
4469
|
+
ctorParameters: () => [],
|
|
4470
|
+
propDecorators: { motionStyle: [{
|
|
4471
|
+
type: i0.Input,
|
|
4472
|
+
args: [{
|
|
4473
|
+
isSignal: true,
|
|
4474
|
+
alias: "motionStyle",
|
|
4475
|
+
required: false
|
|
4476
|
+
}]
|
|
4477
|
+
}] }
|
|
4478
|
+
});
|
|
4479
|
+
export { MotionAnimationService, MotionDragDirective, MotionFollowPointerDirective, MotionIfDirective, MotionLayoutDirective, MotionLayoutRegistry, MotionMagneticDirective, MotionOneDirective, MotionOneService, MotionPanDirective, MotionPresenceDirective, MotionReorderGroupDirective, MotionReorderItemDirective, MotionScrollDirective, MotionStyleDirective, MotionTiltDirective, POINTER_SPRING, SCROLL_THROUGH, SCROLL_WHILE_VISIBLE, isMotionSignal, mapSignal, motionSignal, scrollSignal, springSignal, velocitySignal };
|
|
4158
4480
|
|
|
4159
4481
|
//# sourceMappingURL=hilux-ngx-motion.mjs.map
|