@hilux/ngx-motion 2.0.0 → 2.1.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 +161 -1
- package/fesm2022/hilux-ngx-motion.mjs +1782 -21
- package/fesm2022/hilux-ngx-motion.mjs.map +1 -1
- package/package.json +1 -1
- package/types/hilux-ngx-motion.d.ts +608 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { ChangeDetectorRef, DOCUMENT, DestroyRef, Directive, ElementRef, EventEmitter, HostListener, Inject, Injectable, Input, NgZone, Output, PLATFORM_ID, TemplateRef, ViewContainerRef, inject, signal } from "@angular/core";
|
|
2
|
+
import { ChangeDetectorRef, DOCUMENT, DestroyRef, Directive, ElementRef, EventEmitter, HostListener, Inject, Injectable, Injector, Input, NgZone, Output, PLATFORM_ID, TemplateRef, ViewContainerRef, afterNextRender, afterRenderEffect, effect, forwardRef, inject, input, isDevMode, 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, spring, stagger } from "motion";
|
|
6
|
+
import { animate, easeIn, easeInOut, easeOut, inView, scroll, spring, stagger } from "motion";
|
|
7
7
|
var MotionOneService = class MotionOneService {
|
|
8
8
|
document;
|
|
9
9
|
platformId;
|
|
@@ -389,6 +389,9 @@ var MotionAnimationOptionsService = class MotionAnimationOptionsService {
|
|
|
389
389
|
getStaggerValue(animateState, transition, defaultStaggerChildren = 0) {
|
|
390
390
|
return (animateState?.transition || transition || {}).staggerChildren ?? defaultStaggerChildren;
|
|
391
391
|
}
|
|
392
|
+
getDelayChildren(animateState, transition, defaultDelayChildren = 0) {
|
|
393
|
+
return (animateState?.transition || transition || {}).delayChildren ?? defaultDelayChildren;
|
|
394
|
+
}
|
|
392
395
|
getStaggerDirection(animateState, transition, defaultStaggerDirection = 1) {
|
|
393
396
|
return (animateState?.transition || transition || {}).staggerDirection ?? defaultStaggerDirection;
|
|
394
397
|
}
|
|
@@ -1139,7 +1142,7 @@ var MotionOneDirective = class MotionOneDirective {
|
|
|
1139
1142
|
}
|
|
1140
1143
|
}
|
|
1141
1144
|
childrenToPlay() {
|
|
1142
|
-
return this.getStaggerValue() === 0 ? this.motionChildren.filter((child) => !child.isRunInViewEnabled) : this.motionChildren;
|
|
1145
|
+
return this.getStaggerValue() === 0 ? this.motionChildren.filter((child) => !child.isRunInViewEnabled || child.isStaggeredChild) : this.motionChildren;
|
|
1143
1146
|
}
|
|
1144
1147
|
playAsChild() {
|
|
1145
1148
|
this.staggerDelay = void 0;
|
|
@@ -1206,7 +1209,7 @@ var MotionOneDirective = class MotionOneDirective {
|
|
|
1206
1209
|
applyStaggerToChildren() {
|
|
1207
1210
|
const staggerValue = this.getStaggerValue();
|
|
1208
1211
|
const staggerDirection = this.getStaggerDirection();
|
|
1209
|
-
const delayChildren = this.delayChildren;
|
|
1212
|
+
const delayChildren = this.animationOptions.getDelayChildren(this.getVariant(this.animate), this.transition, this.delayChildren);
|
|
1210
1213
|
const parentDelay = this.transition?.delay ?? 0;
|
|
1211
1214
|
const childDirectives = this.childrenToPlay();
|
|
1212
1215
|
const childCount = childDirectives.length;
|
|
@@ -1554,8 +1557,13 @@ var MotionOneDirective = class MotionOneDirective {
|
|
|
1554
1557
|
}
|
|
1555
1558
|
setupMotionOneInView() {
|
|
1556
1559
|
const margin = this.offset || MOTION_DEFAULTS.INVIEW_MARGIN;
|
|
1557
|
-
if (this.motionChildren.length > 0 && !this.isChild
|
|
1558
|
-
|
|
1560
|
+
if (this.motionChildren.length > 0 && (!this.isChild || !this.isStaggeredChild)) {
|
|
1561
|
+
if (this.isChild) {
|
|
1562
|
+
this.initChildren();
|
|
1563
|
+
this.motionChildren.forEach((child) => child.isStaggeredChild = true);
|
|
1564
|
+
}
|
|
1565
|
+
this.setupStaggerParentInView(margin);
|
|
1566
|
+
} else if (!this.isStaggeredChild) this.setupIndividualElementInView(margin);
|
|
1559
1567
|
}
|
|
1560
1568
|
setupStaggerParentInView(margin) {
|
|
1561
1569
|
this.stopInView();
|
|
@@ -1563,20 +1571,7 @@ var MotionOneDirective = class MotionOneDirective {
|
|
|
1563
1571
|
const childDirectives = this.motionChildren;
|
|
1564
1572
|
this.resetToInitialStylesBatch([this, ...childDirectives]);
|
|
1565
1573
|
let pending = null;
|
|
1566
|
-
if (childDirectives.length > 0) pending = this.schedule(() =>
|
|
1567
|
-
const staggerValue = this.getStaggerValue();
|
|
1568
|
-
childDirectives.forEach((child, index) => {
|
|
1569
|
-
const childAnimateStyles = child.extractStyleProperties(child.getVariant(child.animate));
|
|
1570
|
-
const options = child.getAnimationOptions();
|
|
1571
|
-
options.delay = index * staggerValue;
|
|
1572
|
-
child.animateSelf(childAnimateStyles, options);
|
|
1573
|
-
});
|
|
1574
|
-
const parentAnimateStyles = extractStyleProperties(this.getVariant(this.animate));
|
|
1575
|
-
if (Object.keys(parentAnimateStyles).length > 0) {
|
|
1576
|
-
const parentOptions = this.getAnimationOptions();
|
|
1577
|
-
this.animateSelf(parentAnimateStyles, parentOptions);
|
|
1578
|
-
}
|
|
1579
|
-
}, MOTION_DEFAULTS.STAGGER_TIMEOUT);
|
|
1574
|
+
if (childDirectives.length > 0) pending = this.schedule(() => this.applyStaggerToChildren(), MOTION_DEFAULTS.STAGGER_TIMEOUT);
|
|
1580
1575
|
if (this.runInViewRepeat === "always") return () => {
|
|
1581
1576
|
this.cancelScheduled(pending);
|
|
1582
1577
|
this.resetToInitialStylesBatch([this, ...childDirectives]);
|
|
@@ -2025,6 +2020,1772 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2025
2020
|
motionPresence: [{ type: Input }]
|
|
2026
2021
|
}
|
|
2027
2022
|
});
|
|
2028
|
-
|
|
2023
|
+
const SCROLL_WHILE_VISIBLE = ["start end", "end start"];
|
|
2024
|
+
const SCROLL_THROUGH = ["start start", "end end"];
|
|
2025
|
+
var MotionScrollDirective = class MotionScrollDirective {
|
|
2026
|
+
el = inject(ElementRef).nativeElement;
|
|
2027
|
+
motion = inject(MotionAnimationService);
|
|
2028
|
+
zone = inject(NgZone);
|
|
2029
|
+
motionScroll = input("", ...ngDevMode ? [{ debugName: "motionScroll" }] : /* istanbul ignore next */ []);
|
|
2030
|
+
scrollTarget = input("self", ...ngDevMode ? [{ debugName: "scrollTarget" }] : /* istanbul ignore next */ []);
|
|
2031
|
+
scrollContainer = input("auto", ...ngDevMode ? [{ debugName: "scrollContainer" }] : /* istanbul ignore next */ []);
|
|
2032
|
+
scrollOffset = input(void 0, ...ngDevMode ? [{ debugName: "scrollOffset" }] : /* istanbul ignore next */ []);
|
|
2033
|
+
scrollAxis = input("y", ...ngDevMode ? [{ debugName: "scrollAxis" }] : /* istanbul ignore next */ []);
|
|
2034
|
+
scrollTransition = input(void 0, ...ngDevMode ? [{ debugName: "scrollTransition" }] : /* istanbul ignore next */ []);
|
|
2035
|
+
respectReducedMotion = input(true, ...ngDevMode ? [{ debugName: "respectReducedMotion" }] : /* istanbul ignore next */ []);
|
|
2036
|
+
_progress = signal(0, ...ngDevMode ? [{ debugName: "_progress" }] : /* istanbul ignore next */ []);
|
|
2037
|
+
_velocity = signal(0, ...ngDevMode ? [{ debugName: "_velocity" }] : /* istanbul ignore next */ []);
|
|
2038
|
+
progress = this._progress.asReadonly();
|
|
2039
|
+
velocity = this._velocity.asReadonly();
|
|
2040
|
+
constructor() {
|
|
2041
|
+
afterRenderEffect((onCleanup) => {
|
|
2042
|
+
const keyframes = this.motionScroll();
|
|
2043
|
+
const targetInput = this.scrollTarget();
|
|
2044
|
+
const containerInput = this.scrollContainer();
|
|
2045
|
+
const axis = this.scrollAxis();
|
|
2046
|
+
const transition = this.scrollTransition();
|
|
2047
|
+
const respect = this.respectReducedMotion();
|
|
2048
|
+
const offsetInput = this.scrollOffset();
|
|
2049
|
+
untracked(() => {
|
|
2050
|
+
const container = containerInput === "page" ? void 0 : containerInput === "auto" ? scrollParent(this.el, axis) : containerInput;
|
|
2051
|
+
if (container && isDevMode() && getComputedStyle(container).position === "static") console.warn("[ngx-motion] motionScroll: the scroll container should be positioned (e.g. position: relative), otherwise scroll ranges are measured from the wrong origin.", container);
|
|
2052
|
+
const target = targetInput === "container" ? void 0 : targetInput === "self" ? this.el : targetInput;
|
|
2053
|
+
const options = {
|
|
2054
|
+
container,
|
|
2055
|
+
target,
|
|
2056
|
+
axis,
|
|
2057
|
+
offset: offsetInput ?? (target ? SCROLL_WHILE_VISIBLE : void 0)
|
|
2058
|
+
};
|
|
2059
|
+
const stops = [];
|
|
2060
|
+
stops.push(this.scroll((p, info) => {
|
|
2061
|
+
this._progress.set(p);
|
|
2062
|
+
this._velocity.set(info?.[axis]?.velocity ?? 0);
|
|
2063
|
+
}, options));
|
|
2064
|
+
const reduced = respect && typeof matchMedia !== "undefined" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
2065
|
+
if (keyframes && Object.keys(keyframes).length && !reduced) {
|
|
2066
|
+
const animation = this.motion.animate(this.el, keyframes, {
|
|
2067
|
+
ease: "linear",
|
|
2068
|
+
...transition,
|
|
2069
|
+
duration: 1
|
|
2070
|
+
});
|
|
2071
|
+
stops.push(this.scroll(animation, options));
|
|
2072
|
+
stops.push(() => animation.stop?.());
|
|
2073
|
+
}
|
|
2074
|
+
onCleanup(() => stops.forEach((stop) => stop()));
|
|
2075
|
+
});
|
|
2076
|
+
});
|
|
2077
|
+
}
|
|
2078
|
+
scroll(onScroll, options) {
|
|
2079
|
+
try {
|
|
2080
|
+
return this.zone.runOutsideAngular(() => scroll(onScroll, options));
|
|
2081
|
+
} catch (e) {
|
|
2082
|
+
console.error("[ngx-motion] motionScroll:", e);
|
|
2083
|
+
return () => {};
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
2087
|
+
minVersion: "12.0.0",
|
|
2088
|
+
version: "22.3.2",
|
|
2089
|
+
ngImport: i0,
|
|
2090
|
+
type: MotionScrollDirective,
|
|
2091
|
+
deps: [],
|
|
2092
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
2093
|
+
});
|
|
2094
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
2095
|
+
minVersion: "17.1.0",
|
|
2096
|
+
version: "22.3.2",
|
|
2097
|
+
type: MotionScrollDirective,
|
|
2098
|
+
isStandalone: true,
|
|
2099
|
+
selector: "[motionScroll]",
|
|
2100
|
+
inputs: {
|
|
2101
|
+
motionScroll: {
|
|
2102
|
+
classPropertyName: "motionScroll",
|
|
2103
|
+
publicName: "motionScroll",
|
|
2104
|
+
isSignal: true,
|
|
2105
|
+
isRequired: false,
|
|
2106
|
+
transformFunction: null
|
|
2107
|
+
},
|
|
2108
|
+
scrollTarget: {
|
|
2109
|
+
classPropertyName: "scrollTarget",
|
|
2110
|
+
publicName: "scrollTarget",
|
|
2111
|
+
isSignal: true,
|
|
2112
|
+
isRequired: false,
|
|
2113
|
+
transformFunction: null
|
|
2114
|
+
},
|
|
2115
|
+
scrollContainer: {
|
|
2116
|
+
classPropertyName: "scrollContainer",
|
|
2117
|
+
publicName: "scrollContainer",
|
|
2118
|
+
isSignal: true,
|
|
2119
|
+
isRequired: false,
|
|
2120
|
+
transformFunction: null
|
|
2121
|
+
},
|
|
2122
|
+
scrollOffset: {
|
|
2123
|
+
classPropertyName: "scrollOffset",
|
|
2124
|
+
publicName: "scrollOffset",
|
|
2125
|
+
isSignal: true,
|
|
2126
|
+
isRequired: false,
|
|
2127
|
+
transformFunction: null
|
|
2128
|
+
},
|
|
2129
|
+
scrollAxis: {
|
|
2130
|
+
classPropertyName: "scrollAxis",
|
|
2131
|
+
publicName: "scrollAxis",
|
|
2132
|
+
isSignal: true,
|
|
2133
|
+
isRequired: false,
|
|
2134
|
+
transformFunction: null
|
|
2135
|
+
},
|
|
2136
|
+
scrollTransition: {
|
|
2137
|
+
classPropertyName: "scrollTransition",
|
|
2138
|
+
publicName: "scrollTransition",
|
|
2139
|
+
isSignal: true,
|
|
2140
|
+
isRequired: false,
|
|
2141
|
+
transformFunction: null
|
|
2142
|
+
},
|
|
2143
|
+
respectReducedMotion: {
|
|
2144
|
+
classPropertyName: "respectReducedMotion",
|
|
2145
|
+
publicName: "respectReducedMotion",
|
|
2146
|
+
isSignal: true,
|
|
2147
|
+
isRequired: false,
|
|
2148
|
+
transformFunction: null
|
|
2149
|
+
}
|
|
2150
|
+
},
|
|
2151
|
+
exportAs: ["motionScroll"],
|
|
2152
|
+
ngImport: i0
|
|
2153
|
+
});
|
|
2154
|
+
};
|
|
2155
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
2156
|
+
minVersion: "12.0.0",
|
|
2157
|
+
version: "22.3.2",
|
|
2158
|
+
ngImport: i0,
|
|
2159
|
+
type: MotionScrollDirective,
|
|
2160
|
+
decorators: [{
|
|
2161
|
+
type: Directive,
|
|
2162
|
+
args: [{
|
|
2163
|
+
selector: "[motionScroll]",
|
|
2164
|
+
exportAs: "motionScroll"
|
|
2165
|
+
}]
|
|
2166
|
+
}],
|
|
2167
|
+
ctorParameters: () => [],
|
|
2168
|
+
propDecorators: {
|
|
2169
|
+
motionScroll: [{
|
|
2170
|
+
type: i0.Input,
|
|
2171
|
+
args: [{
|
|
2172
|
+
isSignal: true,
|
|
2173
|
+
alias: "motionScroll",
|
|
2174
|
+
required: false
|
|
2175
|
+
}]
|
|
2176
|
+
}],
|
|
2177
|
+
scrollTarget: [{
|
|
2178
|
+
type: i0.Input,
|
|
2179
|
+
args: [{
|
|
2180
|
+
isSignal: true,
|
|
2181
|
+
alias: "scrollTarget",
|
|
2182
|
+
required: false
|
|
2183
|
+
}]
|
|
2184
|
+
}],
|
|
2185
|
+
scrollContainer: [{
|
|
2186
|
+
type: i0.Input,
|
|
2187
|
+
args: [{
|
|
2188
|
+
isSignal: true,
|
|
2189
|
+
alias: "scrollContainer",
|
|
2190
|
+
required: false
|
|
2191
|
+
}]
|
|
2192
|
+
}],
|
|
2193
|
+
scrollOffset: [{
|
|
2194
|
+
type: i0.Input,
|
|
2195
|
+
args: [{
|
|
2196
|
+
isSignal: true,
|
|
2197
|
+
alias: "scrollOffset",
|
|
2198
|
+
required: false
|
|
2199
|
+
}]
|
|
2200
|
+
}],
|
|
2201
|
+
scrollAxis: [{
|
|
2202
|
+
type: i0.Input,
|
|
2203
|
+
args: [{
|
|
2204
|
+
isSignal: true,
|
|
2205
|
+
alias: "scrollAxis",
|
|
2206
|
+
required: false
|
|
2207
|
+
}]
|
|
2208
|
+
}],
|
|
2209
|
+
scrollTransition: [{
|
|
2210
|
+
type: i0.Input,
|
|
2211
|
+
args: [{
|
|
2212
|
+
isSignal: true,
|
|
2213
|
+
alias: "scrollTransition",
|
|
2214
|
+
required: false
|
|
2215
|
+
}]
|
|
2216
|
+
}],
|
|
2217
|
+
respectReducedMotion: [{
|
|
2218
|
+
type: i0.Input,
|
|
2219
|
+
args: [{
|
|
2220
|
+
isSignal: true,
|
|
2221
|
+
alias: "respectReducedMotion",
|
|
2222
|
+
required: false
|
|
2223
|
+
}]
|
|
2224
|
+
}]
|
|
2225
|
+
}
|
|
2226
|
+
});
|
|
2227
|
+
function scrollParent(el, axis) {
|
|
2228
|
+
for (let node = el.parentElement; node && node !== document.body && node !== document.documentElement; node = node.parentElement) {
|
|
2229
|
+
const overflow = getComputedStyle(node)[axis === "y" ? "overflowY" : "overflowX"];
|
|
2230
|
+
if (overflow === "auto" || overflow === "scroll" || overflow === "overlay") return node;
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
const POINTER_SPRING = {
|
|
2234
|
+
type: "spring",
|
|
2235
|
+
stiffness: 260,
|
|
2236
|
+
damping: 20,
|
|
2237
|
+
mass: .6
|
|
2238
|
+
};
|
|
2239
|
+
function reducedMotion() {
|
|
2240
|
+
return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
2241
|
+
}
|
|
2242
|
+
function listener() {
|
|
2243
|
+
const zone = inject(NgZone);
|
|
2244
|
+
const destroyRef = inject(DestroyRef);
|
|
2245
|
+
return (target, type, fn, options) => {
|
|
2246
|
+
const h = fn;
|
|
2247
|
+
zone.runOutsideAngular(() => target.addEventListener(type, h, options));
|
|
2248
|
+
destroyRef.onDestroy(() => target.removeEventListener(type, h, options));
|
|
2249
|
+
};
|
|
2250
|
+
}
|
|
2251
|
+
var MotionMagneticDirective = class MotionMagneticDirective {
|
|
2252
|
+
motionMagnetic = input("", ...ngDevMode ? [{ debugName: "motionMagnetic" }] : /* istanbul ignore next */ []);
|
|
2253
|
+
magneticRadius = input(24, ...ngDevMode ? [{ debugName: "magneticRadius" }] : /* istanbul ignore next */ []);
|
|
2254
|
+
magneticTransition = input(POINTER_SPRING, ...ngDevMode ? [{ debugName: "magneticTransition" }] : /* istanbul ignore next */ []);
|
|
2255
|
+
_active = signal(false, ...ngDevMode ? [{ debugName: "_active" }] : /* istanbul ignore next */ []);
|
|
2256
|
+
active = this._active.asReadonly();
|
|
2257
|
+
constructor() {
|
|
2258
|
+
const el = inject(ElementRef).nativeElement;
|
|
2259
|
+
const motion = inject(MotionAnimationService);
|
|
2260
|
+
const listen = listener();
|
|
2261
|
+
if (!isPlatformBrowser(inject(PLATFORM_ID))) return;
|
|
2262
|
+
afterNextRender(() => {
|
|
2263
|
+
if (reducedMotion()) return;
|
|
2264
|
+
let x = 0, y = 0;
|
|
2265
|
+
listen(document, "pointermove", (e) => {
|
|
2266
|
+
if (e.pointerType !== "mouse") return;
|
|
2267
|
+
const r = el.getBoundingClientRect();
|
|
2268
|
+
const left = r.left - x, top = r.top - y, reach = this.magneticRadius();
|
|
2269
|
+
const inside = e.clientX >= left - reach && e.clientX <= left + r.width + reach && e.clientY >= top - reach && e.clientY <= top + r.height + reach;
|
|
2270
|
+
if (!inside && !this._active()) return;
|
|
2271
|
+
const strength = this.motionMagnetic() === "" ? .3 : Number(this.motionMagnetic());
|
|
2272
|
+
x = inside ? (e.clientX - (left + r.width / 2)) * strength : 0;
|
|
2273
|
+
y = inside ? (e.clientY - (top + r.height / 2)) * strength : 0;
|
|
2274
|
+
this._active.set(inside);
|
|
2275
|
+
motion.animate(el, {
|
|
2276
|
+
x,
|
|
2277
|
+
y
|
|
2278
|
+
}, this.magneticTransition());
|
|
2279
|
+
}, { passive: true });
|
|
2280
|
+
});
|
|
2281
|
+
}
|
|
2282
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
2283
|
+
minVersion: "12.0.0",
|
|
2284
|
+
version: "22.3.2",
|
|
2285
|
+
ngImport: i0,
|
|
2286
|
+
type: MotionMagneticDirective,
|
|
2287
|
+
deps: [],
|
|
2288
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
2289
|
+
});
|
|
2290
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
2291
|
+
minVersion: "17.1.0",
|
|
2292
|
+
version: "22.3.2",
|
|
2293
|
+
type: MotionMagneticDirective,
|
|
2294
|
+
isStandalone: true,
|
|
2295
|
+
selector: "[motionMagnetic]",
|
|
2296
|
+
inputs: {
|
|
2297
|
+
motionMagnetic: {
|
|
2298
|
+
classPropertyName: "motionMagnetic",
|
|
2299
|
+
publicName: "motionMagnetic",
|
|
2300
|
+
isSignal: true,
|
|
2301
|
+
isRequired: false,
|
|
2302
|
+
transformFunction: null
|
|
2303
|
+
},
|
|
2304
|
+
magneticRadius: {
|
|
2305
|
+
classPropertyName: "magneticRadius",
|
|
2306
|
+
publicName: "magneticRadius",
|
|
2307
|
+
isSignal: true,
|
|
2308
|
+
isRequired: false,
|
|
2309
|
+
transformFunction: null
|
|
2310
|
+
},
|
|
2311
|
+
magneticTransition: {
|
|
2312
|
+
classPropertyName: "magneticTransition",
|
|
2313
|
+
publicName: "magneticTransition",
|
|
2314
|
+
isSignal: true,
|
|
2315
|
+
isRequired: false,
|
|
2316
|
+
transformFunction: null
|
|
2317
|
+
}
|
|
2318
|
+
},
|
|
2319
|
+
exportAs: ["motionMagnetic"],
|
|
2320
|
+
ngImport: i0
|
|
2321
|
+
});
|
|
2322
|
+
};
|
|
2323
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
2324
|
+
minVersion: "12.0.0",
|
|
2325
|
+
version: "22.3.2",
|
|
2326
|
+
ngImport: i0,
|
|
2327
|
+
type: MotionMagneticDirective,
|
|
2328
|
+
decorators: [{
|
|
2329
|
+
type: Directive,
|
|
2330
|
+
args: [{
|
|
2331
|
+
selector: "[motionMagnetic]",
|
|
2332
|
+
exportAs: "motionMagnetic"
|
|
2333
|
+
}]
|
|
2334
|
+
}],
|
|
2335
|
+
ctorParameters: () => [],
|
|
2336
|
+
propDecorators: {
|
|
2337
|
+
motionMagnetic: [{
|
|
2338
|
+
type: i0.Input,
|
|
2339
|
+
args: [{
|
|
2340
|
+
isSignal: true,
|
|
2341
|
+
alias: "motionMagnetic",
|
|
2342
|
+
required: false
|
|
2343
|
+
}]
|
|
2344
|
+
}],
|
|
2345
|
+
magneticRadius: [{
|
|
2346
|
+
type: i0.Input,
|
|
2347
|
+
args: [{
|
|
2348
|
+
isSignal: true,
|
|
2349
|
+
alias: "magneticRadius",
|
|
2350
|
+
required: false
|
|
2351
|
+
}]
|
|
2352
|
+
}],
|
|
2353
|
+
magneticTransition: [{
|
|
2354
|
+
type: i0.Input,
|
|
2355
|
+
args: [{
|
|
2356
|
+
isSignal: true,
|
|
2357
|
+
alias: "magneticTransition",
|
|
2358
|
+
required: false
|
|
2359
|
+
}]
|
|
2360
|
+
}]
|
|
2361
|
+
}
|
|
2362
|
+
});
|
|
2363
|
+
var MotionTiltDirective = class MotionTiltDirective {
|
|
2364
|
+
motionTilt = input("", ...ngDevMode ? [{ debugName: "motionTilt" }] : /* istanbul ignore next */ []);
|
|
2365
|
+
tiltScale = input(1.02, ...ngDevMode ? [{ debugName: "tiltScale" }] : /* istanbul ignore next */ []);
|
|
2366
|
+
tiltPerspective = input(900, ...ngDevMode ? [{ debugName: "tiltPerspective" }] : /* istanbul ignore next */ []);
|
|
2367
|
+
tiltTransition = input({
|
|
2368
|
+
type: "spring",
|
|
2369
|
+
stiffness: 300,
|
|
2370
|
+
damping: 26
|
|
2371
|
+
}, ...ngDevMode ? [{ debugName: "tiltTransition" }] : /* istanbul ignore next */ []);
|
|
2372
|
+
_hovering = signal(false, ...ngDevMode ? [{ debugName: "_hovering" }] : /* istanbul ignore next */ []);
|
|
2373
|
+
hovering = this._hovering.asReadonly();
|
|
2374
|
+
constructor() {
|
|
2375
|
+
const el = inject(ElementRef).nativeElement;
|
|
2376
|
+
const motion = inject(MotionAnimationService);
|
|
2377
|
+
const listen = listener();
|
|
2378
|
+
if (!isPlatformBrowser(inject(PLATFORM_ID))) return;
|
|
2379
|
+
afterNextRender(() => {
|
|
2380
|
+
const reduced = reducedMotion();
|
|
2381
|
+
const max = () => this.motionTilt() === "" ? 10 : Number(this.motionTilt());
|
|
2382
|
+
listen(el, "pointermove", (e) => {
|
|
2383
|
+
if (e.pointerType === "touch") return;
|
|
2384
|
+
const r = el.getBoundingClientRect();
|
|
2385
|
+
const px = Math.min(1, Math.max(0, (e.clientX - r.left) / r.width));
|
|
2386
|
+
const py = Math.min(1, Math.max(0, (e.clientY - r.top) / r.height));
|
|
2387
|
+
el.style.setProperty("--motion-pointer-x", `${(px * 100).toFixed(1)}%`);
|
|
2388
|
+
el.style.setProperty("--motion-pointer-y", `${(py * 100).toFixed(1)}%`);
|
|
2389
|
+
if (!this._hovering()) this._hovering.set(true);
|
|
2390
|
+
if (reduced) return;
|
|
2391
|
+
motion.animate(el, {
|
|
2392
|
+
rotateY: (px - .5) * 2 * max(),
|
|
2393
|
+
rotateX: -(py - .5) * 2 * max(),
|
|
2394
|
+
scale: this.tiltScale(),
|
|
2395
|
+
transformPerspective: this.tiltPerspective()
|
|
2396
|
+
}, this.tiltTransition());
|
|
2397
|
+
}, { passive: true });
|
|
2398
|
+
listen(el, "pointerleave", () => {
|
|
2399
|
+
this._hovering.set(false);
|
|
2400
|
+
if (!reduced) motion.animate(el, {
|
|
2401
|
+
rotateX: 0,
|
|
2402
|
+
rotateY: 0,
|
|
2403
|
+
scale: 1
|
|
2404
|
+
}, this.tiltTransition());
|
|
2405
|
+
});
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2408
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
2409
|
+
minVersion: "12.0.0",
|
|
2410
|
+
version: "22.3.2",
|
|
2411
|
+
ngImport: i0,
|
|
2412
|
+
type: MotionTiltDirective,
|
|
2413
|
+
deps: [],
|
|
2414
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
2415
|
+
});
|
|
2416
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
2417
|
+
minVersion: "17.1.0",
|
|
2418
|
+
version: "22.3.2",
|
|
2419
|
+
type: MotionTiltDirective,
|
|
2420
|
+
isStandalone: true,
|
|
2421
|
+
selector: "[motionTilt]",
|
|
2422
|
+
inputs: {
|
|
2423
|
+
motionTilt: {
|
|
2424
|
+
classPropertyName: "motionTilt",
|
|
2425
|
+
publicName: "motionTilt",
|
|
2426
|
+
isSignal: true,
|
|
2427
|
+
isRequired: false,
|
|
2428
|
+
transformFunction: null
|
|
2429
|
+
},
|
|
2430
|
+
tiltScale: {
|
|
2431
|
+
classPropertyName: "tiltScale",
|
|
2432
|
+
publicName: "tiltScale",
|
|
2433
|
+
isSignal: true,
|
|
2434
|
+
isRequired: false,
|
|
2435
|
+
transformFunction: null
|
|
2436
|
+
},
|
|
2437
|
+
tiltPerspective: {
|
|
2438
|
+
classPropertyName: "tiltPerspective",
|
|
2439
|
+
publicName: "tiltPerspective",
|
|
2440
|
+
isSignal: true,
|
|
2441
|
+
isRequired: false,
|
|
2442
|
+
transformFunction: null
|
|
2443
|
+
},
|
|
2444
|
+
tiltTransition: {
|
|
2445
|
+
classPropertyName: "tiltTransition",
|
|
2446
|
+
publicName: "tiltTransition",
|
|
2447
|
+
isSignal: true,
|
|
2448
|
+
isRequired: false,
|
|
2449
|
+
transformFunction: null
|
|
2450
|
+
}
|
|
2451
|
+
},
|
|
2452
|
+
exportAs: ["motionTilt"],
|
|
2453
|
+
ngImport: i0
|
|
2454
|
+
});
|
|
2455
|
+
};
|
|
2456
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
2457
|
+
minVersion: "12.0.0",
|
|
2458
|
+
version: "22.3.2",
|
|
2459
|
+
ngImport: i0,
|
|
2460
|
+
type: MotionTiltDirective,
|
|
2461
|
+
decorators: [{
|
|
2462
|
+
type: Directive,
|
|
2463
|
+
args: [{
|
|
2464
|
+
selector: "[motionTilt]",
|
|
2465
|
+
exportAs: "motionTilt"
|
|
2466
|
+
}]
|
|
2467
|
+
}],
|
|
2468
|
+
ctorParameters: () => [],
|
|
2469
|
+
propDecorators: {
|
|
2470
|
+
motionTilt: [{
|
|
2471
|
+
type: i0.Input,
|
|
2472
|
+
args: [{
|
|
2473
|
+
isSignal: true,
|
|
2474
|
+
alias: "motionTilt",
|
|
2475
|
+
required: false
|
|
2476
|
+
}]
|
|
2477
|
+
}],
|
|
2478
|
+
tiltScale: [{
|
|
2479
|
+
type: i0.Input,
|
|
2480
|
+
args: [{
|
|
2481
|
+
isSignal: true,
|
|
2482
|
+
alias: "tiltScale",
|
|
2483
|
+
required: false
|
|
2484
|
+
}]
|
|
2485
|
+
}],
|
|
2486
|
+
tiltPerspective: [{
|
|
2487
|
+
type: i0.Input,
|
|
2488
|
+
args: [{
|
|
2489
|
+
isSignal: true,
|
|
2490
|
+
alias: "tiltPerspective",
|
|
2491
|
+
required: false
|
|
2492
|
+
}]
|
|
2493
|
+
}],
|
|
2494
|
+
tiltTransition: [{
|
|
2495
|
+
type: i0.Input,
|
|
2496
|
+
args: [{
|
|
2497
|
+
isSignal: true,
|
|
2498
|
+
alias: "tiltTransition",
|
|
2499
|
+
required: false
|
|
2500
|
+
}]
|
|
2501
|
+
}]
|
|
2502
|
+
}
|
|
2503
|
+
});
|
|
2504
|
+
var MotionFollowPointerDirective = class MotionFollowPointerDirective {
|
|
2505
|
+
motionFollowPointer = input("", ...ngDevMode ? [{ debugName: "motionFollowPointer" }] : /* istanbul ignore next */ []);
|
|
2506
|
+
followTransition = input({
|
|
2507
|
+
type: "spring",
|
|
2508
|
+
stiffness: 180,
|
|
2509
|
+
damping: 22,
|
|
2510
|
+
mass: .7
|
|
2511
|
+
}, ...ngDevMode ? [{ debugName: "followTransition" }] : /* istanbul ignore next */ []);
|
|
2512
|
+
followHide = input(true, ...ngDevMode ? [{ debugName: "followHide" }] : /* istanbul ignore next */ []);
|
|
2513
|
+
_active = signal(false, ...ngDevMode ? [{ debugName: "_active" }] : /* istanbul ignore next */ []);
|
|
2514
|
+
active = this._active.asReadonly();
|
|
2515
|
+
constructor() {
|
|
2516
|
+
const el = inject(ElementRef).nativeElement;
|
|
2517
|
+
const motion = inject(MotionAnimationService);
|
|
2518
|
+
const listen = listener();
|
|
2519
|
+
if (!isPlatformBrowser(inject(PLATFORM_ID))) return;
|
|
2520
|
+
afterNextRender(() => {
|
|
2521
|
+
const reduced = reducedMotion();
|
|
2522
|
+
const mode = this.motionFollowPointer();
|
|
2523
|
+
const area = mode instanceof Element ? mode : mode === "window" ? null : el.parentElement;
|
|
2524
|
+
if (this.followHide()) motion.animate(el, {
|
|
2525
|
+
scale: 0,
|
|
2526
|
+
opacity: 0
|
|
2527
|
+
}, { duration: 0 });
|
|
2528
|
+
let placed = false;
|
|
2529
|
+
listen(area ?? document, "pointermove", (e) => {
|
|
2530
|
+
if (e.pointerType === "touch") return;
|
|
2531
|
+
const origin = el.offsetParent?.getBoundingClientRect() ?? {
|
|
2532
|
+
left: 0,
|
|
2533
|
+
top: 0
|
|
2534
|
+
};
|
|
2535
|
+
const x = e.clientX - origin.left - el.offsetLeft - el.offsetWidth / 2;
|
|
2536
|
+
const y = e.clientY - origin.top - el.offsetTop - el.offsetHeight / 2;
|
|
2537
|
+
motion.animate(el, {
|
|
2538
|
+
x,
|
|
2539
|
+
y
|
|
2540
|
+
}, reduced || !placed ? { duration: 0 } : this.followTransition());
|
|
2541
|
+
placed = true;
|
|
2542
|
+
if (!this._active()) {
|
|
2543
|
+
this._active.set(true);
|
|
2544
|
+
if (this.followHide()) motion.animate(el, {
|
|
2545
|
+
scale: 1,
|
|
2546
|
+
opacity: 1
|
|
2547
|
+
}, { duration: reduced ? 0 : .25 });
|
|
2548
|
+
}
|
|
2549
|
+
}, { passive: true });
|
|
2550
|
+
listen(area ?? document.documentElement, "pointerleave", () => {
|
|
2551
|
+
this._active.set(false);
|
|
2552
|
+
placed = false;
|
|
2553
|
+
if (this.followHide()) motion.animate(el, {
|
|
2554
|
+
scale: 0,
|
|
2555
|
+
opacity: 0
|
|
2556
|
+
}, { duration: reduced ? 0 : .2 });
|
|
2557
|
+
});
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2560
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
2561
|
+
minVersion: "12.0.0",
|
|
2562
|
+
version: "22.3.2",
|
|
2563
|
+
ngImport: i0,
|
|
2564
|
+
type: MotionFollowPointerDirective,
|
|
2565
|
+
deps: [],
|
|
2566
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
2567
|
+
});
|
|
2568
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
2569
|
+
minVersion: "17.1.0",
|
|
2570
|
+
version: "22.3.2",
|
|
2571
|
+
type: MotionFollowPointerDirective,
|
|
2572
|
+
isStandalone: true,
|
|
2573
|
+
selector: "[motionFollowPointer]",
|
|
2574
|
+
inputs: {
|
|
2575
|
+
motionFollowPointer: {
|
|
2576
|
+
classPropertyName: "motionFollowPointer",
|
|
2577
|
+
publicName: "motionFollowPointer",
|
|
2578
|
+
isSignal: true,
|
|
2579
|
+
isRequired: false,
|
|
2580
|
+
transformFunction: null
|
|
2581
|
+
},
|
|
2582
|
+
followTransition: {
|
|
2583
|
+
classPropertyName: "followTransition",
|
|
2584
|
+
publicName: "followTransition",
|
|
2585
|
+
isSignal: true,
|
|
2586
|
+
isRequired: false,
|
|
2587
|
+
transformFunction: null
|
|
2588
|
+
},
|
|
2589
|
+
followHide: {
|
|
2590
|
+
classPropertyName: "followHide",
|
|
2591
|
+
publicName: "followHide",
|
|
2592
|
+
isSignal: true,
|
|
2593
|
+
isRequired: false,
|
|
2594
|
+
transformFunction: null
|
|
2595
|
+
}
|
|
2596
|
+
},
|
|
2597
|
+
exportAs: ["motionFollowPointer"],
|
|
2598
|
+
ngImport: i0
|
|
2599
|
+
});
|
|
2600
|
+
};
|
|
2601
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
2602
|
+
minVersion: "12.0.0",
|
|
2603
|
+
version: "22.3.2",
|
|
2604
|
+
ngImport: i0,
|
|
2605
|
+
type: MotionFollowPointerDirective,
|
|
2606
|
+
decorators: [{
|
|
2607
|
+
type: Directive,
|
|
2608
|
+
args: [{
|
|
2609
|
+
selector: "[motionFollowPointer]",
|
|
2610
|
+
exportAs: "motionFollowPointer"
|
|
2611
|
+
}]
|
|
2612
|
+
}],
|
|
2613
|
+
ctorParameters: () => [],
|
|
2614
|
+
propDecorators: {
|
|
2615
|
+
motionFollowPointer: [{
|
|
2616
|
+
type: i0.Input,
|
|
2617
|
+
args: [{
|
|
2618
|
+
isSignal: true,
|
|
2619
|
+
alias: "motionFollowPointer",
|
|
2620
|
+
required: false
|
|
2621
|
+
}]
|
|
2622
|
+
}],
|
|
2623
|
+
followTransition: [{
|
|
2624
|
+
type: i0.Input,
|
|
2625
|
+
args: [{
|
|
2626
|
+
isSignal: true,
|
|
2627
|
+
alias: "followTransition",
|
|
2628
|
+
required: false
|
|
2629
|
+
}]
|
|
2630
|
+
}],
|
|
2631
|
+
followHide: [{
|
|
2632
|
+
type: i0.Input,
|
|
2633
|
+
args: [{
|
|
2634
|
+
isSignal: true,
|
|
2635
|
+
alias: "followHide",
|
|
2636
|
+
required: false
|
|
2637
|
+
}]
|
|
2638
|
+
}]
|
|
2639
|
+
}
|
|
2640
|
+
});
|
|
2641
|
+
const SETTLE = {
|
|
2642
|
+
type: "spring",
|
|
2643
|
+
stiffness: 380,
|
|
2644
|
+
damping: 38
|
|
2645
|
+
};
|
|
2646
|
+
var MotionDragDirective = class MotionDragDirective {
|
|
2647
|
+
motionDrag = input("", ...ngDevMode ? [{ debugName: "motionDrag" }] : /* istanbul ignore next */ []);
|
|
2648
|
+
dragConstraints = input(null, ...ngDevMode ? [{ debugName: "dragConstraints" }] : /* istanbul ignore next */ []);
|
|
2649
|
+
dragElastic = input(.35, ...ngDevMode ? [{ debugName: "dragElastic" }] : /* istanbul ignore next */ []);
|
|
2650
|
+
dragMomentum = input(true, ...ngDevMode ? [{ debugName: "dragMomentum" }] : /* istanbul ignore next */ []);
|
|
2651
|
+
dragSnap = input(null, ...ngDevMode ? [{ debugName: "dragSnap" }] : /* istanbul ignore next */ []);
|
|
2652
|
+
dragTransition = input(SETTLE, ...ngDevMode ? [{ debugName: "dragTransition" }] : /* istanbul ignore next */ []);
|
|
2653
|
+
dragThreshold = input(3, ...ngDevMode ? [{ debugName: "dragThreshold" }] : /* istanbul ignore next */ []);
|
|
2654
|
+
dragDisabled = input(false, ...ngDevMode ? [{ debugName: "dragDisabled" }] : /* istanbul ignore next */ []);
|
|
2655
|
+
dragStart = output();
|
|
2656
|
+
dragMove = output();
|
|
2657
|
+
dragEnd = output();
|
|
2658
|
+
_x = signal(0, ...ngDevMode ? [{ debugName: "_x" }] : /* istanbul ignore next */ []);
|
|
2659
|
+
_y = signal(0, ...ngDevMode ? [{ debugName: "_y" }] : /* istanbul ignore next */ []);
|
|
2660
|
+
_dragging = signal(false, ...ngDevMode ? [{ debugName: "_dragging" }] : /* istanbul ignore next */ []);
|
|
2661
|
+
x = this._x.asReadonly();
|
|
2662
|
+
y = this._y.asReadonly();
|
|
2663
|
+
dragging = this._dragging.asReadonly();
|
|
2664
|
+
el = inject(ElementRef).nativeElement;
|
|
2665
|
+
motion = inject(MotionAnimationService);
|
|
2666
|
+
zone = inject(NgZone);
|
|
2667
|
+
settle;
|
|
2668
|
+
raf = 0;
|
|
2669
|
+
start = {
|
|
2670
|
+
x: 0,
|
|
2671
|
+
y: 0
|
|
2672
|
+
};
|
|
2673
|
+
limits = {
|
|
2674
|
+
top: -Infinity,
|
|
2675
|
+
left: -Infinity,
|
|
2676
|
+
right: Infinity,
|
|
2677
|
+
bottom: Infinity
|
|
2678
|
+
};
|
|
2679
|
+
overrides = signal({}, ...ngDevMode ? [{ debugName: "overrides" }] : /* istanbul ignore next */ []);
|
|
2680
|
+
constructor() {
|
|
2681
|
+
const destroyRef = inject(DestroyRef);
|
|
2682
|
+
if (!isPlatformBrowser(inject(PLATFORM_ID))) return;
|
|
2683
|
+
afterNextRender(() => this.zone.runOutsideAngular(() => this.bind(destroyRef)));
|
|
2684
|
+
destroyRef.onDestroy(() => {
|
|
2685
|
+
cancelAnimationFrame(this.raf);
|
|
2686
|
+
this.settle?.stop();
|
|
2687
|
+
});
|
|
2688
|
+
}
|
|
2689
|
+
touchAction() {
|
|
2690
|
+
const axis = this.axis();
|
|
2691
|
+
return this.dragDisabled() ? null : axis === "x" ? "pan-y" : axis === "y" ? "pan-x" : "none";
|
|
2692
|
+
}
|
|
2693
|
+
moveTo(x, y = this._y(), transition = this.dragTransition()) {
|
|
2694
|
+
this.zone.runOutsideAngular(() => this.glide({
|
|
2695
|
+
x,
|
|
2696
|
+
y
|
|
2697
|
+
}, transition, {
|
|
2698
|
+
x: 0,
|
|
2699
|
+
y: 0
|
|
2700
|
+
}));
|
|
2701
|
+
}
|
|
2702
|
+
rebase(dx, dy) {
|
|
2703
|
+
if (!dx && !dy) return;
|
|
2704
|
+
this.start = {
|
|
2705
|
+
x: this.start.x - dx,
|
|
2706
|
+
y: this.start.y - dy
|
|
2707
|
+
};
|
|
2708
|
+
const x = this._x() - dx, y = this._y() - dy;
|
|
2709
|
+
this._x.set(x);
|
|
2710
|
+
this._y.set(y);
|
|
2711
|
+
this.motion.animate(this.el, {
|
|
2712
|
+
x,
|
|
2713
|
+
y
|
|
2714
|
+
}, { duration: 0 });
|
|
2715
|
+
if (this._dragging()) this.limits = this.bounds();
|
|
2716
|
+
}
|
|
2717
|
+
axis() {
|
|
2718
|
+
return this.overrides().axis ?? this.motionDrag();
|
|
2719
|
+
}
|
|
2720
|
+
axisX() {
|
|
2721
|
+
return this.axis() !== "y";
|
|
2722
|
+
}
|
|
2723
|
+
axisY() {
|
|
2724
|
+
return this.axis() !== "x";
|
|
2725
|
+
}
|
|
2726
|
+
read() {
|
|
2727
|
+
const m = new DOMMatrix(getComputedStyle(this.el).transform);
|
|
2728
|
+
return {
|
|
2729
|
+
x: m.m41,
|
|
2730
|
+
y: m.m42
|
|
2731
|
+
};
|
|
2732
|
+
}
|
|
2733
|
+
glide(to, t, velocity) {
|
|
2734
|
+
this.settle?.stop();
|
|
2735
|
+
const settle = this.motion.animate(this.el, to, {
|
|
2736
|
+
...t,
|
|
2737
|
+
x: {
|
|
2738
|
+
...t,
|
|
2739
|
+
velocity: velocity.x
|
|
2740
|
+
},
|
|
2741
|
+
y: {
|
|
2742
|
+
...t,
|
|
2743
|
+
velocity: velocity.y
|
|
2744
|
+
}
|
|
2745
|
+
});
|
|
2746
|
+
this.settle = settle;
|
|
2747
|
+
cancelAnimationFrame(this.raf);
|
|
2748
|
+
const tick = () => {
|
|
2749
|
+
if (this.settle !== settle) return;
|
|
2750
|
+
const p = this.read();
|
|
2751
|
+
this._x.set(p.x);
|
|
2752
|
+
this._y.set(p.y);
|
|
2753
|
+
this.raf = requestAnimationFrame(tick);
|
|
2754
|
+
};
|
|
2755
|
+
this.raf = requestAnimationFrame(tick);
|
|
2756
|
+
settle.then(() => {
|
|
2757
|
+
if (this.settle !== settle) return;
|
|
2758
|
+
cancelAnimationFrame(this.raf);
|
|
2759
|
+
this.settle = void 0;
|
|
2760
|
+
this._x.set(to.x);
|
|
2761
|
+
this._y.set(to.y);
|
|
2762
|
+
});
|
|
2763
|
+
}
|
|
2764
|
+
bounds() {
|
|
2765
|
+
const c = this.overrides().constraints ?? this.dragConstraints();
|
|
2766
|
+
const none = {
|
|
2767
|
+
top: -Infinity,
|
|
2768
|
+
left: -Infinity,
|
|
2769
|
+
right: Infinity,
|
|
2770
|
+
bottom: Infinity
|
|
2771
|
+
};
|
|
2772
|
+
if (!c) return none;
|
|
2773
|
+
if (c === "parent" || c instanceof Element) {
|
|
2774
|
+
const box = c === "parent" ? this.el.parentElement : c;
|
|
2775
|
+
if (!box) return none;
|
|
2776
|
+
const p = box.getBoundingClientRect();
|
|
2777
|
+
const r = this.el.getBoundingClientRect();
|
|
2778
|
+
const left = r.left - this._x(), top = r.top - this._y();
|
|
2779
|
+
const ax = p.left - left, bx = p.right - (left + r.width);
|
|
2780
|
+
const ay = p.top - top, by = p.bottom - (top + r.height);
|
|
2781
|
+
return {
|
|
2782
|
+
left: Math.min(ax, bx),
|
|
2783
|
+
right: Math.max(ax, bx),
|
|
2784
|
+
top: Math.min(ay, by),
|
|
2785
|
+
bottom: Math.max(ay, by)
|
|
2786
|
+
};
|
|
2787
|
+
}
|
|
2788
|
+
const b = c;
|
|
2789
|
+
return {
|
|
2790
|
+
top: b.top ?? -Infinity,
|
|
2791
|
+
left: b.left ?? -Infinity,
|
|
2792
|
+
right: b.right ?? Infinity,
|
|
2793
|
+
bottom: b.bottom ?? Infinity
|
|
2794
|
+
};
|
|
2795
|
+
}
|
|
2796
|
+
elastic(v, min, max) {
|
|
2797
|
+
const e = this.overrides().elastic ?? this.dragElastic();
|
|
2798
|
+
if (v < min) return min + (v - min) * e;
|
|
2799
|
+
if (v > max) return max + (v - max) * e;
|
|
2800
|
+
return v;
|
|
2801
|
+
}
|
|
2802
|
+
target(pos, v, min, max, snap) {
|
|
2803
|
+
const projected = this.overrides().momentum ?? this.dragMomentum() ? pos + v * .2 : pos;
|
|
2804
|
+
if (snap?.length) {
|
|
2805
|
+
const within = snap.filter((s) => s >= min && s <= max);
|
|
2806
|
+
const points = within.length ? within : snap;
|
|
2807
|
+
return points.reduce((best, s) => Math.abs(s - projected) < Math.abs(best - projected) ? s : best, points[0]);
|
|
2808
|
+
}
|
|
2809
|
+
return Math.min(max, Math.max(min, projected));
|
|
2810
|
+
}
|
|
2811
|
+
info(velocity) {
|
|
2812
|
+
const x = this._x(), y = this._y(), start = this.start;
|
|
2813
|
+
return {
|
|
2814
|
+
x,
|
|
2815
|
+
y,
|
|
2816
|
+
offset: {
|
|
2817
|
+
x: x - start.x,
|
|
2818
|
+
y: y - start.y
|
|
2819
|
+
},
|
|
2820
|
+
velocity
|
|
2821
|
+
};
|
|
2822
|
+
}
|
|
2823
|
+
bind(destroyRef) {
|
|
2824
|
+
const el = this.el;
|
|
2825
|
+
const on = (t, type, fn, opts) => {
|
|
2826
|
+
t.addEventListener(type, fn, opts);
|
|
2827
|
+
destroyRef.onDestroy(() => t.removeEventListener(type, fn, opts));
|
|
2828
|
+
};
|
|
2829
|
+
let pointer = null;
|
|
2830
|
+
let origin = {
|
|
2831
|
+
x: 0,
|
|
2832
|
+
y: 0
|
|
2833
|
+
}, last = {
|
|
2834
|
+
x: 0,
|
|
2835
|
+
y: 0,
|
|
2836
|
+
t: 0
|
|
2837
|
+
}, velocity = {
|
|
2838
|
+
x: 0,
|
|
2839
|
+
y: 0
|
|
2840
|
+
};
|
|
2841
|
+
let moved = false;
|
|
2842
|
+
let swallowClick = false;
|
|
2843
|
+
const set = (x, y) => {
|
|
2844
|
+
this._x.set(x);
|
|
2845
|
+
this._y.set(y);
|
|
2846
|
+
this.motion.animate(el, {
|
|
2847
|
+
x,
|
|
2848
|
+
y
|
|
2849
|
+
}, { duration: 0 });
|
|
2850
|
+
};
|
|
2851
|
+
on(el, "dragstart", (e) => e.preventDefault());
|
|
2852
|
+
on(el, "pointerdown", (e) => {
|
|
2853
|
+
if (this.dragDisabled() || e.button !== 0 || pointer !== null) return;
|
|
2854
|
+
pointer = e.pointerId;
|
|
2855
|
+
moved = false;
|
|
2856
|
+
this.settle?.stop();
|
|
2857
|
+
this.settle = void 0;
|
|
2858
|
+
cancelAnimationFrame(this.raf);
|
|
2859
|
+
const now = this.read();
|
|
2860
|
+
this._x.set(now.x);
|
|
2861
|
+
this._y.set(now.y);
|
|
2862
|
+
origin = {
|
|
2863
|
+
x: e.clientX,
|
|
2864
|
+
y: e.clientY
|
|
2865
|
+
};
|
|
2866
|
+
this.start = {
|
|
2867
|
+
x: now.x,
|
|
2868
|
+
y: now.y
|
|
2869
|
+
};
|
|
2870
|
+
last = {
|
|
2871
|
+
x: e.clientX,
|
|
2872
|
+
y: e.clientY,
|
|
2873
|
+
t: e.timeStamp
|
|
2874
|
+
};
|
|
2875
|
+
velocity = {
|
|
2876
|
+
x: 0,
|
|
2877
|
+
y: 0
|
|
2878
|
+
};
|
|
2879
|
+
});
|
|
2880
|
+
on(window, "pointermove", (e) => {
|
|
2881
|
+
if (e.pointerId !== pointer) return;
|
|
2882
|
+
const dx = this.axisX() ? e.clientX - origin.x : 0;
|
|
2883
|
+
const dy = this.axisY() ? e.clientY - origin.y : 0;
|
|
2884
|
+
if (!moved) {
|
|
2885
|
+
if (Math.hypot(dx, dy) < this.dragThreshold()) return;
|
|
2886
|
+
moved = true;
|
|
2887
|
+
this.limits = this.bounds();
|
|
2888
|
+
el.setPointerCapture(e.pointerId);
|
|
2889
|
+
this._dragging.set(true);
|
|
2890
|
+
this.dragStart.emit(this.info(velocity));
|
|
2891
|
+
}
|
|
2892
|
+
const dt = Math.max(1, e.timeStamp - last.t) / 1e3;
|
|
2893
|
+
velocity = {
|
|
2894
|
+
x: velocity.x * .2 + (e.clientX - last.x) / dt * .8,
|
|
2895
|
+
y: velocity.y * .2 + (e.clientY - last.y) / dt * .8
|
|
2896
|
+
};
|
|
2897
|
+
last = {
|
|
2898
|
+
x: e.clientX,
|
|
2899
|
+
y: e.clientY,
|
|
2900
|
+
t: e.timeStamp
|
|
2901
|
+
};
|
|
2902
|
+
const start = this.start, bounds = this.limits;
|
|
2903
|
+
set(this.axisX() ? this.elastic(start.x + dx, bounds.left, bounds.right) : start.x, this.axisY() ? this.elastic(start.y + dy, bounds.top, bounds.bottom) : start.y);
|
|
2904
|
+
this.dragMove.emit(this.info(velocity));
|
|
2905
|
+
});
|
|
2906
|
+
const end = (e) => {
|
|
2907
|
+
if (e.pointerId !== pointer) return;
|
|
2908
|
+
pointer = null;
|
|
2909
|
+
if (!moved) return;
|
|
2910
|
+
swallowClick = true;
|
|
2911
|
+
setTimeout(() => swallowClick = false);
|
|
2912
|
+
if (e.timeStamp - last.t > 80) velocity = {
|
|
2913
|
+
x: 0,
|
|
2914
|
+
y: 0
|
|
2915
|
+
};
|
|
2916
|
+
if (!this.axisX()) velocity.x = 0;
|
|
2917
|
+
if (!this.axisY()) velocity.y = 0;
|
|
2918
|
+
this._dragging.set(false);
|
|
2919
|
+
const snap = this.dragSnap(), bounds = this.limits, start = this.start;
|
|
2920
|
+
const x = this.target(this._x(), velocity.x, bounds.left, bounds.right, this.axisX() ? snap?.x : void 0);
|
|
2921
|
+
const y = this.target(this._y(), velocity.y, bounds.top, bounds.bottom, this.axisY() ? snap?.y : void 0);
|
|
2922
|
+
this.glide({
|
|
2923
|
+
x,
|
|
2924
|
+
y
|
|
2925
|
+
}, this.dragTransition(), velocity);
|
|
2926
|
+
this.dragEnd.emit({
|
|
2927
|
+
x,
|
|
2928
|
+
y,
|
|
2929
|
+
offset: {
|
|
2930
|
+
x: x - start.x,
|
|
2931
|
+
y: y - start.y
|
|
2932
|
+
},
|
|
2933
|
+
velocity
|
|
2934
|
+
});
|
|
2935
|
+
};
|
|
2936
|
+
on(window, "pointerup", end);
|
|
2937
|
+
on(window, "pointercancel", end);
|
|
2938
|
+
on(el, "click", (e) => {
|
|
2939
|
+
if (swallowClick) {
|
|
2940
|
+
e.preventDefault();
|
|
2941
|
+
e.stopPropagation();
|
|
2942
|
+
swallowClick = false;
|
|
2943
|
+
}
|
|
2944
|
+
}, { capture: true });
|
|
2945
|
+
}
|
|
2946
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
2947
|
+
minVersion: "12.0.0",
|
|
2948
|
+
version: "22.3.2",
|
|
2949
|
+
ngImport: i0,
|
|
2950
|
+
type: MotionDragDirective,
|
|
2951
|
+
deps: [],
|
|
2952
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
2953
|
+
});
|
|
2954
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
2955
|
+
minVersion: "17.1.0",
|
|
2956
|
+
version: "22.3.2",
|
|
2957
|
+
type: MotionDragDirective,
|
|
2958
|
+
isStandalone: true,
|
|
2959
|
+
selector: "[motionDrag]",
|
|
2960
|
+
inputs: {
|
|
2961
|
+
motionDrag: {
|
|
2962
|
+
classPropertyName: "motionDrag",
|
|
2963
|
+
publicName: "motionDrag",
|
|
2964
|
+
isSignal: true,
|
|
2965
|
+
isRequired: false,
|
|
2966
|
+
transformFunction: null
|
|
2967
|
+
},
|
|
2968
|
+
dragConstraints: {
|
|
2969
|
+
classPropertyName: "dragConstraints",
|
|
2970
|
+
publicName: "dragConstraints",
|
|
2971
|
+
isSignal: true,
|
|
2972
|
+
isRequired: false,
|
|
2973
|
+
transformFunction: null
|
|
2974
|
+
},
|
|
2975
|
+
dragElastic: {
|
|
2976
|
+
classPropertyName: "dragElastic",
|
|
2977
|
+
publicName: "dragElastic",
|
|
2978
|
+
isSignal: true,
|
|
2979
|
+
isRequired: false,
|
|
2980
|
+
transformFunction: null
|
|
2981
|
+
},
|
|
2982
|
+
dragMomentum: {
|
|
2983
|
+
classPropertyName: "dragMomentum",
|
|
2984
|
+
publicName: "dragMomentum",
|
|
2985
|
+
isSignal: true,
|
|
2986
|
+
isRequired: false,
|
|
2987
|
+
transformFunction: null
|
|
2988
|
+
},
|
|
2989
|
+
dragSnap: {
|
|
2990
|
+
classPropertyName: "dragSnap",
|
|
2991
|
+
publicName: "dragSnap",
|
|
2992
|
+
isSignal: true,
|
|
2993
|
+
isRequired: false,
|
|
2994
|
+
transformFunction: null
|
|
2995
|
+
},
|
|
2996
|
+
dragTransition: {
|
|
2997
|
+
classPropertyName: "dragTransition",
|
|
2998
|
+
publicName: "dragTransition",
|
|
2999
|
+
isSignal: true,
|
|
3000
|
+
isRequired: false,
|
|
3001
|
+
transformFunction: null
|
|
3002
|
+
},
|
|
3003
|
+
dragThreshold: {
|
|
3004
|
+
classPropertyName: "dragThreshold",
|
|
3005
|
+
publicName: "dragThreshold",
|
|
3006
|
+
isSignal: true,
|
|
3007
|
+
isRequired: false,
|
|
3008
|
+
transformFunction: null
|
|
3009
|
+
},
|
|
3010
|
+
dragDisabled: {
|
|
3011
|
+
classPropertyName: "dragDisabled",
|
|
3012
|
+
publicName: "dragDisabled",
|
|
3013
|
+
isSignal: true,
|
|
3014
|
+
isRequired: false,
|
|
3015
|
+
transformFunction: null
|
|
3016
|
+
}
|
|
3017
|
+
},
|
|
3018
|
+
outputs: {
|
|
3019
|
+
dragStart: "dragStart",
|
|
3020
|
+
dragMove: "dragMove",
|
|
3021
|
+
dragEnd: "dragEnd"
|
|
3022
|
+
},
|
|
3023
|
+
host: { properties: {
|
|
3024
|
+
"style.touch-action": "touchAction()",
|
|
3025
|
+
"class.motion-dragging": "dragging()"
|
|
3026
|
+
} },
|
|
3027
|
+
exportAs: ["motionDrag"],
|
|
3028
|
+
ngImport: i0
|
|
3029
|
+
});
|
|
3030
|
+
};
|
|
3031
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
3032
|
+
minVersion: "12.0.0",
|
|
3033
|
+
version: "22.3.2",
|
|
3034
|
+
ngImport: i0,
|
|
3035
|
+
type: MotionDragDirective,
|
|
3036
|
+
decorators: [{
|
|
3037
|
+
type: Directive,
|
|
3038
|
+
args: [{
|
|
3039
|
+
selector: "[motionDrag]",
|
|
3040
|
+
exportAs: "motionDrag",
|
|
3041
|
+
host: {
|
|
3042
|
+
"[style.touch-action]": "touchAction()",
|
|
3043
|
+
"[class.motion-dragging]": "dragging()"
|
|
3044
|
+
}
|
|
3045
|
+
}]
|
|
3046
|
+
}],
|
|
3047
|
+
ctorParameters: () => [],
|
|
3048
|
+
propDecorators: {
|
|
3049
|
+
motionDrag: [{
|
|
3050
|
+
type: i0.Input,
|
|
3051
|
+
args: [{
|
|
3052
|
+
isSignal: true,
|
|
3053
|
+
alias: "motionDrag",
|
|
3054
|
+
required: false
|
|
3055
|
+
}]
|
|
3056
|
+
}],
|
|
3057
|
+
dragConstraints: [{
|
|
3058
|
+
type: i0.Input,
|
|
3059
|
+
args: [{
|
|
3060
|
+
isSignal: true,
|
|
3061
|
+
alias: "dragConstraints",
|
|
3062
|
+
required: false
|
|
3063
|
+
}]
|
|
3064
|
+
}],
|
|
3065
|
+
dragElastic: [{
|
|
3066
|
+
type: i0.Input,
|
|
3067
|
+
args: [{
|
|
3068
|
+
isSignal: true,
|
|
3069
|
+
alias: "dragElastic",
|
|
3070
|
+
required: false
|
|
3071
|
+
}]
|
|
3072
|
+
}],
|
|
3073
|
+
dragMomentum: [{
|
|
3074
|
+
type: i0.Input,
|
|
3075
|
+
args: [{
|
|
3076
|
+
isSignal: true,
|
|
3077
|
+
alias: "dragMomentum",
|
|
3078
|
+
required: false
|
|
3079
|
+
}]
|
|
3080
|
+
}],
|
|
3081
|
+
dragSnap: [{
|
|
3082
|
+
type: i0.Input,
|
|
3083
|
+
args: [{
|
|
3084
|
+
isSignal: true,
|
|
3085
|
+
alias: "dragSnap",
|
|
3086
|
+
required: false
|
|
3087
|
+
}]
|
|
3088
|
+
}],
|
|
3089
|
+
dragTransition: [{
|
|
3090
|
+
type: i0.Input,
|
|
3091
|
+
args: [{
|
|
3092
|
+
isSignal: true,
|
|
3093
|
+
alias: "dragTransition",
|
|
3094
|
+
required: false
|
|
3095
|
+
}]
|
|
3096
|
+
}],
|
|
3097
|
+
dragThreshold: [{
|
|
3098
|
+
type: i0.Input,
|
|
3099
|
+
args: [{
|
|
3100
|
+
isSignal: true,
|
|
3101
|
+
alias: "dragThreshold",
|
|
3102
|
+
required: false
|
|
3103
|
+
}]
|
|
3104
|
+
}],
|
|
3105
|
+
dragDisabled: [{
|
|
3106
|
+
type: i0.Input,
|
|
3107
|
+
args: [{
|
|
3108
|
+
isSignal: true,
|
|
3109
|
+
alias: "dragDisabled",
|
|
3110
|
+
required: false
|
|
3111
|
+
}]
|
|
3112
|
+
}],
|
|
3113
|
+
dragStart: [{
|
|
3114
|
+
type: i0.Output,
|
|
3115
|
+
args: ["dragStart"]
|
|
3116
|
+
}],
|
|
3117
|
+
dragMove: [{
|
|
3118
|
+
type: i0.Output,
|
|
3119
|
+
args: ["dragMove"]
|
|
3120
|
+
}],
|
|
3121
|
+
dragEnd: [{
|
|
3122
|
+
type: i0.Output,
|
|
3123
|
+
args: ["dragEnd"]
|
|
3124
|
+
}]
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
const NEUTRAL = {
|
|
3128
|
+
x: 0,
|
|
3129
|
+
y: 0,
|
|
3130
|
+
z: 0,
|
|
3131
|
+
rotate: 0,
|
|
3132
|
+
rotateX: 0,
|
|
3133
|
+
rotateY: 0,
|
|
3134
|
+
rotateZ: 0,
|
|
3135
|
+
skew: 0,
|
|
3136
|
+
skewX: 0,
|
|
3137
|
+
skewY: 0,
|
|
3138
|
+
scale: 1,
|
|
3139
|
+
scaleX: 1,
|
|
3140
|
+
scaleY: 1,
|
|
3141
|
+
scaleZ: 1
|
|
3142
|
+
};
|
|
3143
|
+
const RELEASE = {
|
|
3144
|
+
type: "spring",
|
|
3145
|
+
stiffness: 500,
|
|
3146
|
+
damping: 35
|
|
3147
|
+
};
|
|
3148
|
+
var MotionPanDirective = class MotionPanDirective {
|
|
3149
|
+
motionPan = input("", ...ngDevMode ? [{ debugName: "motionPan" }] : /* istanbul ignore next */ []);
|
|
3150
|
+
panThreshold = input(3, ...ngDevMode ? [{ debugName: "panThreshold" }] : /* istanbul ignore next */ []);
|
|
3151
|
+
swipeDistance = input(50, ...ngDevMode ? [{ debugName: "swipeDistance" }] : /* istanbul ignore next */ []);
|
|
3152
|
+
swipeVelocity = input(500, ...ngDevMode ? [{ debugName: "swipeVelocity" }] : /* istanbul ignore next */ []);
|
|
3153
|
+
whilePan = input(null, ...ngDevMode ? [{ debugName: "whilePan" }] : /* istanbul ignore next */ []);
|
|
3154
|
+
panTransition = input(RELEASE, ...ngDevMode ? [{ debugName: "panTransition" }] : /* istanbul ignore next */ []);
|
|
3155
|
+
panDisabled = input(false, ...ngDevMode ? [{ debugName: "panDisabled" }] : /* istanbul ignore next */ []);
|
|
3156
|
+
panStart = output();
|
|
3157
|
+
pan = output();
|
|
3158
|
+
panEnd = output();
|
|
3159
|
+
swipe = output();
|
|
3160
|
+
_panning = signal(false, ...ngDevMode ? [{ debugName: "_panning" }] : /* istanbul ignore next */ []);
|
|
3161
|
+
panning = this._panning.asReadonly();
|
|
3162
|
+
el = inject(ElementRef).nativeElement;
|
|
3163
|
+
motion = inject(MotionAnimationService);
|
|
3164
|
+
zone = inject(NgZone);
|
|
3165
|
+
constructor() {
|
|
3166
|
+
const destroyRef = inject(DestroyRef);
|
|
3167
|
+
if (!isPlatformBrowser(inject(PLATFORM_ID))) return;
|
|
3168
|
+
afterNextRender(() => this.zone.runOutsideAngular(() => this.bind(destroyRef)));
|
|
3169
|
+
}
|
|
3170
|
+
touchAction() {
|
|
3171
|
+
const axis = this.motionPan();
|
|
3172
|
+
return this.panDisabled() ? null : axis === "x" ? "pan-y" : axis === "y" ? "pan-x" : "none";
|
|
3173
|
+
}
|
|
3174
|
+
static swipeOf(info, distance, speed, axis = "") {
|
|
3175
|
+
const horizontal = axis === "x" || axis !== "y" && Math.abs(info.offset.x) >= Math.abs(info.offset.y);
|
|
3176
|
+
const d = horizontal ? info.offset.x : info.offset.y;
|
|
3177
|
+
const v = horizontal ? info.velocity.x : info.velocity.y;
|
|
3178
|
+
if (Math.abs(d) < distance && (Math.abs(v) < speed || Math.sign(v) !== Math.sign(d))) return null;
|
|
3179
|
+
return horizontal ? d > 0 ? "right" : "left" : d > 0 ? "down" : "up";
|
|
3180
|
+
}
|
|
3181
|
+
bind(destroyRef) {
|
|
3182
|
+
const el = this.el;
|
|
3183
|
+
const on = (t, type, fn, opts) => {
|
|
3184
|
+
t.addEventListener(type, fn, opts);
|
|
3185
|
+
destroyRef.onDestroy(() => t.removeEventListener(type, fn, opts));
|
|
3186
|
+
};
|
|
3187
|
+
let pointer = null;
|
|
3188
|
+
let moved = false, swallowClick = false;
|
|
3189
|
+
let origin = {
|
|
3190
|
+
x: 0,
|
|
3191
|
+
y: 0
|
|
3192
|
+
}, last = {
|
|
3193
|
+
x: 0,
|
|
3194
|
+
y: 0,
|
|
3195
|
+
t: 0
|
|
3196
|
+
}, velocity = {
|
|
3197
|
+
x: 0,
|
|
3198
|
+
y: 0
|
|
3199
|
+
}, delta = {
|
|
3200
|
+
x: 0,
|
|
3201
|
+
y: 0
|
|
3202
|
+
};
|
|
3203
|
+
let rest = {};
|
|
3204
|
+
const info = (e) => {
|
|
3205
|
+
const axis = this.motionPan();
|
|
3206
|
+
return {
|
|
3207
|
+
point: {
|
|
3208
|
+
x: e.clientX,
|
|
3209
|
+
y: e.clientY
|
|
3210
|
+
},
|
|
3211
|
+
delta: {
|
|
3212
|
+
x: axis === "y" ? 0 : delta.x,
|
|
3213
|
+
y: axis === "x" ? 0 : delta.y
|
|
3214
|
+
},
|
|
3215
|
+
offset: {
|
|
3216
|
+
x: axis === "y" ? 0 : e.clientX - origin.x,
|
|
3217
|
+
y: axis === "x" ? 0 : e.clientY - origin.y
|
|
3218
|
+
},
|
|
3219
|
+
velocity: {
|
|
3220
|
+
x: axis === "y" ? 0 : velocity.x,
|
|
3221
|
+
y: axis === "x" ? 0 : velocity.y
|
|
3222
|
+
}
|
|
3223
|
+
};
|
|
3224
|
+
};
|
|
3225
|
+
const emit = (out, v) => this.zone.run(() => out.emit(v));
|
|
3226
|
+
on(el, "pointerdown", (e) => {
|
|
3227
|
+
if (this.panDisabled() || e.button !== 0 || pointer !== null) return;
|
|
3228
|
+
pointer = e.pointerId;
|
|
3229
|
+
moved = false;
|
|
3230
|
+
origin = {
|
|
3231
|
+
x: e.clientX,
|
|
3232
|
+
y: e.clientY
|
|
3233
|
+
};
|
|
3234
|
+
last = {
|
|
3235
|
+
x: e.clientX,
|
|
3236
|
+
y: e.clientY,
|
|
3237
|
+
t: e.timeStamp
|
|
3238
|
+
};
|
|
3239
|
+
velocity = {
|
|
3240
|
+
x: 0,
|
|
3241
|
+
y: 0
|
|
3242
|
+
};
|
|
3243
|
+
});
|
|
3244
|
+
on(window, "pointermove", (e) => {
|
|
3245
|
+
if (e.pointerId !== pointer) return;
|
|
3246
|
+
const axis = this.motionPan();
|
|
3247
|
+
const dx = axis === "y" ? 0 : e.clientX - origin.x, dy = axis === "x" ? 0 : e.clientY - origin.y;
|
|
3248
|
+
if (!moved) {
|
|
3249
|
+
if (Math.hypot(dx, dy) < this.panThreshold()) return;
|
|
3250
|
+
moved = true;
|
|
3251
|
+
el.setPointerCapture?.(e.pointerId);
|
|
3252
|
+
this._panning.set(true);
|
|
3253
|
+
const to = this.whilePan();
|
|
3254
|
+
if (to) {
|
|
3255
|
+
const { transition, ...styles } = to;
|
|
3256
|
+
rest = this.restingValues(styles);
|
|
3257
|
+
this.motion.animate(el, styles, transition ?? this.panTransition());
|
|
3258
|
+
}
|
|
3259
|
+
delta = {
|
|
3260
|
+
x: 0,
|
|
3261
|
+
y: 0
|
|
3262
|
+
};
|
|
3263
|
+
emit(this.panStart, info(e));
|
|
3264
|
+
}
|
|
3265
|
+
const dt = Math.max(1, e.timeStamp - last.t) / 1e3;
|
|
3266
|
+
delta = {
|
|
3267
|
+
x: e.clientX - last.x,
|
|
3268
|
+
y: e.clientY - last.y
|
|
3269
|
+
};
|
|
3270
|
+
velocity = {
|
|
3271
|
+
x: velocity.x * .2 + delta.x / dt * .8,
|
|
3272
|
+
y: velocity.y * .2 + delta.y / dt * .8
|
|
3273
|
+
};
|
|
3274
|
+
last = {
|
|
3275
|
+
x: e.clientX,
|
|
3276
|
+
y: e.clientY,
|
|
3277
|
+
t: e.timeStamp
|
|
3278
|
+
};
|
|
3279
|
+
emit(this.pan, info(e));
|
|
3280
|
+
});
|
|
3281
|
+
const end = (e) => {
|
|
3282
|
+
if (e.pointerId !== pointer) return;
|
|
3283
|
+
pointer = null;
|
|
3284
|
+
if (!moved) return;
|
|
3285
|
+
swallowClick = true;
|
|
3286
|
+
setTimeout(() => swallowClick = false);
|
|
3287
|
+
if (e.timeStamp - last.t > 80) velocity = {
|
|
3288
|
+
x: 0,
|
|
3289
|
+
y: 0
|
|
3290
|
+
};
|
|
3291
|
+
delta = {
|
|
3292
|
+
x: 0,
|
|
3293
|
+
y: 0
|
|
3294
|
+
};
|
|
3295
|
+
this._panning.set(false);
|
|
3296
|
+
if (this.whilePan()) this.motion.animate(el, rest, this.panTransition());
|
|
3297
|
+
const done = info(e);
|
|
3298
|
+
emit(this.panEnd, done);
|
|
3299
|
+
const direction = e.type === "pointerup" ? MotionPanDirective.swipeOf(done, this.swipeDistance(), this.swipeVelocity(), this.motionPan()) : null;
|
|
3300
|
+
if (direction) emit(this.swipe, {
|
|
3301
|
+
...done,
|
|
3302
|
+
direction
|
|
3303
|
+
});
|
|
3304
|
+
};
|
|
3305
|
+
on(window, "pointerup", end);
|
|
3306
|
+
on(window, "pointercancel", end);
|
|
3307
|
+
on(el, "click", (e) => {
|
|
3308
|
+
if (swallowClick) {
|
|
3309
|
+
e.preventDefault();
|
|
3310
|
+
e.stopPropagation();
|
|
3311
|
+
swallowClick = false;
|
|
3312
|
+
}
|
|
3313
|
+
}, { capture: true });
|
|
3314
|
+
}
|
|
3315
|
+
restingValues(to) {
|
|
3316
|
+
const style = getComputedStyle(this.el);
|
|
3317
|
+
const rest = {};
|
|
3318
|
+
for (const key of Object.keys(to)) if (key in NEUTRAL) rest[key] = NEUTRAL[key];
|
|
3319
|
+
else rest[key] = style.getPropertyValue(key.replace(/[A-Z]/g, (c) => "-" + c.toLowerCase())) || style[key];
|
|
3320
|
+
return rest;
|
|
3321
|
+
}
|
|
3322
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
3323
|
+
minVersion: "12.0.0",
|
|
3324
|
+
version: "22.3.2",
|
|
3325
|
+
ngImport: i0,
|
|
3326
|
+
type: MotionPanDirective,
|
|
3327
|
+
deps: [],
|
|
3328
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
3329
|
+
});
|
|
3330
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
3331
|
+
minVersion: "17.1.0",
|
|
3332
|
+
version: "22.3.2",
|
|
3333
|
+
type: MotionPanDirective,
|
|
3334
|
+
isStandalone: true,
|
|
3335
|
+
selector: "[motionPan]",
|
|
3336
|
+
inputs: {
|
|
3337
|
+
motionPan: {
|
|
3338
|
+
classPropertyName: "motionPan",
|
|
3339
|
+
publicName: "motionPan",
|
|
3340
|
+
isSignal: true,
|
|
3341
|
+
isRequired: false,
|
|
3342
|
+
transformFunction: null
|
|
3343
|
+
},
|
|
3344
|
+
panThreshold: {
|
|
3345
|
+
classPropertyName: "panThreshold",
|
|
3346
|
+
publicName: "panThreshold",
|
|
3347
|
+
isSignal: true,
|
|
3348
|
+
isRequired: false,
|
|
3349
|
+
transformFunction: null
|
|
3350
|
+
},
|
|
3351
|
+
swipeDistance: {
|
|
3352
|
+
classPropertyName: "swipeDistance",
|
|
3353
|
+
publicName: "swipeDistance",
|
|
3354
|
+
isSignal: true,
|
|
3355
|
+
isRequired: false,
|
|
3356
|
+
transformFunction: null
|
|
3357
|
+
},
|
|
3358
|
+
swipeVelocity: {
|
|
3359
|
+
classPropertyName: "swipeVelocity",
|
|
3360
|
+
publicName: "swipeVelocity",
|
|
3361
|
+
isSignal: true,
|
|
3362
|
+
isRequired: false,
|
|
3363
|
+
transformFunction: null
|
|
3364
|
+
},
|
|
3365
|
+
whilePan: {
|
|
3366
|
+
classPropertyName: "whilePan",
|
|
3367
|
+
publicName: "whilePan",
|
|
3368
|
+
isSignal: true,
|
|
3369
|
+
isRequired: false,
|
|
3370
|
+
transformFunction: null
|
|
3371
|
+
},
|
|
3372
|
+
panTransition: {
|
|
3373
|
+
classPropertyName: "panTransition",
|
|
3374
|
+
publicName: "panTransition",
|
|
3375
|
+
isSignal: true,
|
|
3376
|
+
isRequired: false,
|
|
3377
|
+
transformFunction: null
|
|
3378
|
+
},
|
|
3379
|
+
panDisabled: {
|
|
3380
|
+
classPropertyName: "panDisabled",
|
|
3381
|
+
publicName: "panDisabled",
|
|
3382
|
+
isSignal: true,
|
|
3383
|
+
isRequired: false,
|
|
3384
|
+
transformFunction: null
|
|
3385
|
+
}
|
|
3386
|
+
},
|
|
3387
|
+
outputs: {
|
|
3388
|
+
panStart: "panStart",
|
|
3389
|
+
pan: "pan",
|
|
3390
|
+
panEnd: "panEnd",
|
|
3391
|
+
swipe: "swipe"
|
|
3392
|
+
},
|
|
3393
|
+
host: { properties: {
|
|
3394
|
+
"style.touch-action": "touchAction()",
|
|
3395
|
+
"class.motion-panning": "panning()"
|
|
3396
|
+
} },
|
|
3397
|
+
exportAs: ["motionPan"],
|
|
3398
|
+
ngImport: i0
|
|
3399
|
+
});
|
|
3400
|
+
};
|
|
3401
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
3402
|
+
minVersion: "12.0.0",
|
|
3403
|
+
version: "22.3.2",
|
|
3404
|
+
ngImport: i0,
|
|
3405
|
+
type: MotionPanDirective,
|
|
3406
|
+
decorators: [{
|
|
3407
|
+
type: Directive,
|
|
3408
|
+
args: [{
|
|
3409
|
+
selector: "[motionPan]",
|
|
3410
|
+
exportAs: "motionPan",
|
|
3411
|
+
host: {
|
|
3412
|
+
"[style.touch-action]": "touchAction()",
|
|
3413
|
+
"[class.motion-panning]": "panning()"
|
|
3414
|
+
}
|
|
3415
|
+
}]
|
|
3416
|
+
}],
|
|
3417
|
+
ctorParameters: () => [],
|
|
3418
|
+
propDecorators: {
|
|
3419
|
+
motionPan: [{
|
|
3420
|
+
type: i0.Input,
|
|
3421
|
+
args: [{
|
|
3422
|
+
isSignal: true,
|
|
3423
|
+
alias: "motionPan",
|
|
3424
|
+
required: false
|
|
3425
|
+
}]
|
|
3426
|
+
}],
|
|
3427
|
+
panThreshold: [{
|
|
3428
|
+
type: i0.Input,
|
|
3429
|
+
args: [{
|
|
3430
|
+
isSignal: true,
|
|
3431
|
+
alias: "panThreshold",
|
|
3432
|
+
required: false
|
|
3433
|
+
}]
|
|
3434
|
+
}],
|
|
3435
|
+
swipeDistance: [{
|
|
3436
|
+
type: i0.Input,
|
|
3437
|
+
args: [{
|
|
3438
|
+
isSignal: true,
|
|
3439
|
+
alias: "swipeDistance",
|
|
3440
|
+
required: false
|
|
3441
|
+
}]
|
|
3442
|
+
}],
|
|
3443
|
+
swipeVelocity: [{
|
|
3444
|
+
type: i0.Input,
|
|
3445
|
+
args: [{
|
|
3446
|
+
isSignal: true,
|
|
3447
|
+
alias: "swipeVelocity",
|
|
3448
|
+
required: false
|
|
3449
|
+
}]
|
|
3450
|
+
}],
|
|
3451
|
+
whilePan: [{
|
|
3452
|
+
type: i0.Input,
|
|
3453
|
+
args: [{
|
|
3454
|
+
isSignal: true,
|
|
3455
|
+
alias: "whilePan",
|
|
3456
|
+
required: false
|
|
3457
|
+
}]
|
|
3458
|
+
}],
|
|
3459
|
+
panTransition: [{
|
|
3460
|
+
type: i0.Input,
|
|
3461
|
+
args: [{
|
|
3462
|
+
isSignal: true,
|
|
3463
|
+
alias: "panTransition",
|
|
3464
|
+
required: false
|
|
3465
|
+
}]
|
|
3466
|
+
}],
|
|
3467
|
+
panDisabled: [{
|
|
3468
|
+
type: i0.Input,
|
|
3469
|
+
args: [{
|
|
3470
|
+
isSignal: true,
|
|
3471
|
+
alias: "panDisabled",
|
|
3472
|
+
required: false
|
|
3473
|
+
}]
|
|
3474
|
+
}],
|
|
3475
|
+
panStart: [{
|
|
3476
|
+
type: i0.Output,
|
|
3477
|
+
args: ["panStart"]
|
|
3478
|
+
}],
|
|
3479
|
+
pan: [{
|
|
3480
|
+
type: i0.Output,
|
|
3481
|
+
args: ["pan"]
|
|
3482
|
+
}],
|
|
3483
|
+
panEnd: [{
|
|
3484
|
+
type: i0.Output,
|
|
3485
|
+
args: ["panEnd"]
|
|
3486
|
+
}],
|
|
3487
|
+
swipe: [{
|
|
3488
|
+
type: i0.Output,
|
|
3489
|
+
args: ["swipe"]
|
|
3490
|
+
}]
|
|
3491
|
+
}
|
|
3492
|
+
});
|
|
3493
|
+
const LAYOUT_SPRING = {
|
|
3494
|
+
type: "spring",
|
|
3495
|
+
stiffness: 550,
|
|
3496
|
+
damping: 45
|
|
3497
|
+
};
|
|
3498
|
+
var MotionReorderGroupDirective = class MotionReorderGroupDirective {
|
|
3499
|
+
motionReorderGroup = model.required(...ngDevMode ? [{ debugName: "motionReorderGroup" }] : /* istanbul ignore next */ []);
|
|
3500
|
+
reorderAxis = input("y", ...ngDevMode ? [{ debugName: "reorderAxis" }] : /* istanbul ignore next */ []);
|
|
3501
|
+
reorderTransition = input(LAYOUT_SPRING, ...ngDevMode ? [{ debugName: "reorderTransition" }] : /* istanbul ignore next */ []);
|
|
3502
|
+
reorderEnd = output();
|
|
3503
|
+
items = /* @__PURE__ */ new Set();
|
|
3504
|
+
motion = inject(MotionAnimationService);
|
|
3505
|
+
zone = inject(NgZone);
|
|
3506
|
+
injector = inject(Injector);
|
|
3507
|
+
pending = false;
|
|
3508
|
+
register(item) {
|
|
3509
|
+
this.items.add(item);
|
|
3510
|
+
return () => this.items.delete(item);
|
|
3511
|
+
}
|
|
3512
|
+
dragged(item, offset, direction) {
|
|
3513
|
+
if (this.pending || !direction) return;
|
|
3514
|
+
const values = this.motionReorderGroup();
|
|
3515
|
+
const i = values.indexOf(item.motionReorderItem());
|
|
3516
|
+
if (i < 0) return;
|
|
3517
|
+
const lo = this.pos(item.el) + offset, hi = lo + this.size(item.el);
|
|
3518
|
+
const neighbour = this.find(values[i + direction]);
|
|
3519
|
+
if (!neighbour) return;
|
|
3520
|
+
const middle = this.pos(neighbour.el) + this.size(neighbour.el) / 2;
|
|
3521
|
+
if (direction > 0 ? hi > middle : lo < middle) this.move(item, i + direction);
|
|
3522
|
+
}
|
|
3523
|
+
move(item, to) {
|
|
3524
|
+
const values = this.motionReorderGroup();
|
|
3525
|
+
const from = values.indexOf(item.motionReorderItem());
|
|
3526
|
+
if (from < 0 || to < 0 || to >= values.length || to === from || this.pending) return false;
|
|
3527
|
+
const before = new Map([...this.items].map((it) => [it, this.pos(it.el)]));
|
|
3528
|
+
const next = [...values];
|
|
3529
|
+
next.splice(to, 0, ...next.splice(from, 1));
|
|
3530
|
+
this.pending = true;
|
|
3531
|
+
this.zone.run(() => this.motionReorderGroup.set(next));
|
|
3532
|
+
afterNextRender(() => {
|
|
3533
|
+
this.pending = false;
|
|
3534
|
+
const axis = this.reorderAxis();
|
|
3535
|
+
for (const it of this.items) {
|
|
3536
|
+
const was = before.get(it);
|
|
3537
|
+
if (was === void 0) continue;
|
|
3538
|
+
const moved = this.pos(it.el) - was;
|
|
3539
|
+
if (!moved) continue;
|
|
3540
|
+
if (it === item && it.drag.dragging()) it.drag.rebase(axis === "x" ? moved : 0, axis === "y" ? moved : 0);
|
|
3541
|
+
else {
|
|
3542
|
+
const m = new DOMMatrix(getComputedStyle(it.el).transform);
|
|
3543
|
+
const now = (axis === "x" ? m.m41 : m.m42) - moved;
|
|
3544
|
+
it.el.style.transform = axis === "x" ? `translateX(${now}px)` : `translateY(${now}px)`;
|
|
3545
|
+
this.zone.runOutsideAngular(() => this.motion.animate(it.el, { [axis]: [now, 0] }, this.reorderTransition()));
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
}, { injector: this.injector });
|
|
3549
|
+
return true;
|
|
3550
|
+
}
|
|
3551
|
+
ended() {
|
|
3552
|
+
this.reorderEnd.emit(this.motionReorderGroup());
|
|
3553
|
+
}
|
|
3554
|
+
find(value) {
|
|
3555
|
+
if (value === void 0) return void 0;
|
|
3556
|
+
for (const it of this.items) if (it.motionReorderItem() === value) return it;
|
|
3557
|
+
}
|
|
3558
|
+
pos(el) {
|
|
3559
|
+
return this.reorderAxis() === "x" ? el.offsetLeft : el.offsetTop;
|
|
3560
|
+
}
|
|
3561
|
+
size(el) {
|
|
3562
|
+
return this.reorderAxis() === "x" ? el.offsetWidth : el.offsetHeight;
|
|
3563
|
+
}
|
|
3564
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
3565
|
+
minVersion: "12.0.0",
|
|
3566
|
+
version: "22.3.2",
|
|
3567
|
+
ngImport: i0,
|
|
3568
|
+
type: MotionReorderGroupDirective,
|
|
3569
|
+
deps: [],
|
|
3570
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
3571
|
+
});
|
|
3572
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
3573
|
+
minVersion: "17.1.0",
|
|
3574
|
+
version: "22.3.2",
|
|
3575
|
+
type: MotionReorderGroupDirective,
|
|
3576
|
+
isStandalone: true,
|
|
3577
|
+
selector: "[motionReorderGroup]",
|
|
3578
|
+
inputs: {
|
|
3579
|
+
motionReorderGroup: {
|
|
3580
|
+
classPropertyName: "motionReorderGroup",
|
|
3581
|
+
publicName: "motionReorderGroup",
|
|
3582
|
+
isSignal: true,
|
|
3583
|
+
isRequired: true,
|
|
3584
|
+
transformFunction: null
|
|
3585
|
+
},
|
|
3586
|
+
reorderAxis: {
|
|
3587
|
+
classPropertyName: "reorderAxis",
|
|
3588
|
+
publicName: "reorderAxis",
|
|
3589
|
+
isSignal: true,
|
|
3590
|
+
isRequired: false,
|
|
3591
|
+
transformFunction: null
|
|
3592
|
+
},
|
|
3593
|
+
reorderTransition: {
|
|
3594
|
+
classPropertyName: "reorderTransition",
|
|
3595
|
+
publicName: "reorderTransition",
|
|
3596
|
+
isSignal: true,
|
|
3597
|
+
isRequired: false,
|
|
3598
|
+
transformFunction: null
|
|
3599
|
+
}
|
|
3600
|
+
},
|
|
3601
|
+
outputs: {
|
|
3602
|
+
motionReorderGroup: "motionReorderGroupChange",
|
|
3603
|
+
reorderEnd: "reorderEnd"
|
|
3604
|
+
},
|
|
3605
|
+
exportAs: ["motionReorderGroup"],
|
|
3606
|
+
ngImport: i0
|
|
3607
|
+
});
|
|
3608
|
+
};
|
|
3609
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
3610
|
+
minVersion: "12.0.0",
|
|
3611
|
+
version: "22.3.2",
|
|
3612
|
+
ngImport: i0,
|
|
3613
|
+
type: MotionReorderGroupDirective,
|
|
3614
|
+
decorators: [{
|
|
3615
|
+
type: Directive,
|
|
3616
|
+
args: [{
|
|
3617
|
+
selector: "[motionReorderGroup]",
|
|
3618
|
+
exportAs: "motionReorderGroup"
|
|
3619
|
+
}]
|
|
3620
|
+
}],
|
|
3621
|
+
propDecorators: {
|
|
3622
|
+
motionReorderGroup: [{
|
|
3623
|
+
type: i0.Input,
|
|
3624
|
+
args: [{
|
|
3625
|
+
isSignal: true,
|
|
3626
|
+
alias: "motionReorderGroup",
|
|
3627
|
+
required: true
|
|
3628
|
+
}]
|
|
3629
|
+
}, {
|
|
3630
|
+
type: i0.Output,
|
|
3631
|
+
args: ["motionReorderGroupChange"]
|
|
3632
|
+
}],
|
|
3633
|
+
reorderAxis: [{
|
|
3634
|
+
type: i0.Input,
|
|
3635
|
+
args: [{
|
|
3636
|
+
isSignal: true,
|
|
3637
|
+
alias: "reorderAxis",
|
|
3638
|
+
required: false
|
|
3639
|
+
}]
|
|
3640
|
+
}],
|
|
3641
|
+
reorderTransition: [{
|
|
3642
|
+
type: i0.Input,
|
|
3643
|
+
args: [{
|
|
3644
|
+
isSignal: true,
|
|
3645
|
+
alias: "reorderTransition",
|
|
3646
|
+
required: false
|
|
3647
|
+
}]
|
|
3648
|
+
}],
|
|
3649
|
+
reorderEnd: [{
|
|
3650
|
+
type: i0.Output,
|
|
3651
|
+
args: ["reorderEnd"]
|
|
3652
|
+
}]
|
|
3653
|
+
}
|
|
3654
|
+
});
|
|
3655
|
+
var MotionReorderItemDirective = class MotionReorderItemDirective {
|
|
3656
|
+
motionReorderItem = input.required(...ngDevMode ? [{ debugName: "motionReorderItem" }] : /* istanbul ignore next */ []);
|
|
3657
|
+
drag = inject(MotionDragDirective, { self: true });
|
|
3658
|
+
el = inject(ElementRef).nativeElement;
|
|
3659
|
+
group = inject(forwardRef(() => MotionReorderGroupDirective));
|
|
3660
|
+
constructor() {
|
|
3661
|
+
const unregister = this.group.register(this);
|
|
3662
|
+
inject(DestroyRef).onDestroy(unregister);
|
|
3663
|
+
effect(() => {
|
|
3664
|
+
this.drag.overrides.set({
|
|
3665
|
+
axis: this.group.reorderAxis(),
|
|
3666
|
+
constraints: {
|
|
3667
|
+
top: 0,
|
|
3668
|
+
right: 0,
|
|
3669
|
+
bottom: 0,
|
|
3670
|
+
left: 0
|
|
3671
|
+
},
|
|
3672
|
+
elastic: 1,
|
|
3673
|
+
momentum: false
|
|
3674
|
+
});
|
|
3675
|
+
});
|
|
3676
|
+
let last = 0;
|
|
3677
|
+
this.drag.dragStart.subscribe(() => last = 0);
|
|
3678
|
+
this.drag.dragMove.subscribe(() => {
|
|
3679
|
+
const offset = this.offset();
|
|
3680
|
+
const direction = Math.sign(offset - last);
|
|
3681
|
+
last = offset;
|
|
3682
|
+
this.group.dragged(this, offset, direction);
|
|
3683
|
+
});
|
|
3684
|
+
this.drag.dragEnd.subscribe(() => this.group.ended());
|
|
3685
|
+
}
|
|
3686
|
+
raised() {
|
|
3687
|
+
return this.drag.dragging() || this.drag.x() !== 0 || this.drag.y() !== 0;
|
|
3688
|
+
}
|
|
3689
|
+
onKey(e) {
|
|
3690
|
+
if (!e.altKey || e.target !== this.el) return;
|
|
3691
|
+
const step = this.group.reorderAxis() === "y" ? e.key === "ArrowUp" ? -1 : e.key === "ArrowDown" ? 1 : 0 : e.key === "ArrowLeft" ? -1 : e.key === "ArrowRight" ? 1 : 0;
|
|
3692
|
+
if (!step) return;
|
|
3693
|
+
e.preventDefault();
|
|
3694
|
+
const i = this.group.motionReorderGroup().indexOf(this.motionReorderItem());
|
|
3695
|
+
if (this.group.move(this, i + step)) afterNextRender(() => {
|
|
3696
|
+
this.el.focus();
|
|
3697
|
+
this.group.ended();
|
|
3698
|
+
}, { injector: this.injector });
|
|
3699
|
+
}
|
|
3700
|
+
injector = inject(Injector);
|
|
3701
|
+
offset() {
|
|
3702
|
+
return this.group.reorderAxis() === "x" ? this.drag.x() : this.drag.y();
|
|
3703
|
+
}
|
|
3704
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
3705
|
+
minVersion: "12.0.0",
|
|
3706
|
+
version: "22.3.2",
|
|
3707
|
+
ngImport: i0,
|
|
3708
|
+
type: MotionReorderItemDirective,
|
|
3709
|
+
deps: [],
|
|
3710
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
3711
|
+
});
|
|
3712
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
3713
|
+
minVersion: "17.1.0",
|
|
3714
|
+
version: "22.3.2",
|
|
3715
|
+
type: MotionReorderItemDirective,
|
|
3716
|
+
isStandalone: true,
|
|
3717
|
+
selector: "[motionReorderItem]",
|
|
3718
|
+
inputs: { motionReorderItem: {
|
|
3719
|
+
classPropertyName: "motionReorderItem",
|
|
3720
|
+
publicName: "motionReorderItem",
|
|
3721
|
+
isSignal: true,
|
|
3722
|
+
isRequired: true,
|
|
3723
|
+
transformFunction: null
|
|
3724
|
+
} },
|
|
3725
|
+
host: {
|
|
3726
|
+
listeners: { "keydown": "onKey($event)" },
|
|
3727
|
+
properties: {
|
|
3728
|
+
"style.position": "\"relative\"",
|
|
3729
|
+
"style.z-index": "raised() ? 1 : null"
|
|
3730
|
+
}
|
|
3731
|
+
},
|
|
3732
|
+
exportAs: ["motionReorderItem"],
|
|
3733
|
+
hostDirectives: [{
|
|
3734
|
+
directive: MotionDragDirective,
|
|
3735
|
+
inputs: [
|
|
3736
|
+
"dragTransition",
|
|
3737
|
+
"dragTransition",
|
|
3738
|
+
"dragDisabled",
|
|
3739
|
+
"dragDisabled"
|
|
3740
|
+
],
|
|
3741
|
+
outputs: [
|
|
3742
|
+
"dragStart",
|
|
3743
|
+
"dragStart",
|
|
3744
|
+
"dragMove",
|
|
3745
|
+
"dragMove",
|
|
3746
|
+
"dragEnd",
|
|
3747
|
+
"dragEnd"
|
|
3748
|
+
]
|
|
3749
|
+
}],
|
|
3750
|
+
ngImport: i0
|
|
3751
|
+
});
|
|
3752
|
+
};
|
|
3753
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
3754
|
+
minVersion: "12.0.0",
|
|
3755
|
+
version: "22.3.2",
|
|
3756
|
+
ngImport: i0,
|
|
3757
|
+
type: MotionReorderItemDirective,
|
|
3758
|
+
decorators: [{
|
|
3759
|
+
type: Directive,
|
|
3760
|
+
args: [{
|
|
3761
|
+
selector: "[motionReorderItem]",
|
|
3762
|
+
exportAs: "motionReorderItem",
|
|
3763
|
+
hostDirectives: [{
|
|
3764
|
+
directive: MotionDragDirective,
|
|
3765
|
+
inputs: ["dragTransition", "dragDisabled"],
|
|
3766
|
+
outputs: [
|
|
3767
|
+
"dragStart",
|
|
3768
|
+
"dragMove",
|
|
3769
|
+
"dragEnd"
|
|
3770
|
+
]
|
|
3771
|
+
}],
|
|
3772
|
+
host: {
|
|
3773
|
+
"[style.position]": "\"relative\"",
|
|
3774
|
+
"[style.z-index]": "raised() ? 1 : null",
|
|
3775
|
+
"(keydown)": "onKey($event)"
|
|
3776
|
+
}
|
|
3777
|
+
}]
|
|
3778
|
+
}],
|
|
3779
|
+
ctorParameters: () => [],
|
|
3780
|
+
propDecorators: { motionReorderItem: [{
|
|
3781
|
+
type: i0.Input,
|
|
3782
|
+
args: [{
|
|
3783
|
+
isSignal: true,
|
|
3784
|
+
alias: "motionReorderItem",
|
|
3785
|
+
required: true
|
|
3786
|
+
}]
|
|
3787
|
+
}] }
|
|
3788
|
+
});
|
|
3789
|
+
export { MotionAnimationService, MotionDragDirective, MotionFollowPointerDirective, MotionIfDirective, MotionMagneticDirective, MotionOneDirective, MotionOneService, MotionPanDirective, MotionPresenceDirective, MotionReorderGroupDirective, MotionReorderItemDirective, MotionScrollDirective, MotionTiltDirective, POINTER_SPRING, SCROLL_THROUGH, SCROLL_WHILE_VISIBLE };
|
|
2029
3790
|
|
|
2030
3791
|
//# sourceMappingURL=hilux-ngx-motion.mjs.map
|