@ethlete/core 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/directives/animatable/animatable.directive.mjs +6 -4
- package/esm2020/lib/directives/animatable/index.mjs +2 -0
- package/esm2020/lib/directives/animated-lifecycle/animated-lifecycle.directive.mjs +2 -2
- package/esm2020/lib/utils/animation.utils.mjs +69 -2
- package/fesm2015/ethlete-core.mjs +72 -3
- package/fesm2015/ethlete-core.mjs.map +1 -1
- package/fesm2020/ethlete-core.mjs +72 -3
- package/fesm2020/ethlete-core.mjs.map +1 -1
- package/lib/directives/animatable/index.d.ts +1 -0
- package/lib/utils/animation.utils.d.ts +12 -0
- package/package.json +1 -1
|
@@ -362,6 +362,73 @@ const fromNextFrame = () => {
|
|
|
362
362
|
const forceReflow = (element = document.body) => {
|
|
363
363
|
return element.offsetHeight;
|
|
364
364
|
};
|
|
365
|
+
const createFlipAnimation = (config) => {
|
|
366
|
+
const { element: el, duration = 250, easing = 'cubic-bezier(0.4, 0, 0.2, 1)' } = config;
|
|
367
|
+
let initialRect = el.getBoundingClientRect();
|
|
368
|
+
let animation = null;
|
|
369
|
+
const onStart$ = new Subject();
|
|
370
|
+
const onFinish$ = new Subject();
|
|
371
|
+
const onCancel$ = new Subject();
|
|
372
|
+
const onAnimationFinish = () => {
|
|
373
|
+
cleanup();
|
|
374
|
+
onFinish$.next();
|
|
375
|
+
};
|
|
376
|
+
const onAnimationCancel = () => {
|
|
377
|
+
cleanup();
|
|
378
|
+
onCancel$.next();
|
|
379
|
+
};
|
|
380
|
+
const cleanup = () => {
|
|
381
|
+
if (!animation) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
animation.removeEventListener('finish', onAnimationFinish);
|
|
385
|
+
animation.removeEventListener('cancel', onAnimationCancel);
|
|
386
|
+
};
|
|
387
|
+
const updateInit = () => {
|
|
388
|
+
initialRect = el.getBoundingClientRect();
|
|
389
|
+
};
|
|
390
|
+
const play = () => {
|
|
391
|
+
const lastRect = el.getBoundingClientRect();
|
|
392
|
+
const delta = {
|
|
393
|
+
x: initialRect.left - lastRect.left,
|
|
394
|
+
y: initialRect.top - lastRect.top,
|
|
395
|
+
scaleX: initialRect.width / lastRect.width,
|
|
396
|
+
scaleY: initialRect.height / lastRect.height,
|
|
397
|
+
};
|
|
398
|
+
animation = el.animate([
|
|
399
|
+
{
|
|
400
|
+
transformOrigin: 'top left',
|
|
401
|
+
transform: `
|
|
402
|
+
translate(${delta.x}px, ${delta.y}px)
|
|
403
|
+
scale(${delta.scaleX}, ${delta.scaleY})
|
|
404
|
+
`,
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
transformOrigin: 'top left',
|
|
408
|
+
transform: 'none',
|
|
409
|
+
},
|
|
410
|
+
], {
|
|
411
|
+
duration,
|
|
412
|
+
easing,
|
|
413
|
+
fill: 'both',
|
|
414
|
+
});
|
|
415
|
+
animation.addEventListener('finish', onAnimationFinish);
|
|
416
|
+
animation.addEventListener('cancel', onAnimationCancel);
|
|
417
|
+
onStart$.next();
|
|
418
|
+
};
|
|
419
|
+
const cancel = () => {
|
|
420
|
+
animation?.cancel();
|
|
421
|
+
cleanup();
|
|
422
|
+
};
|
|
423
|
+
return {
|
|
424
|
+
updateInit,
|
|
425
|
+
play,
|
|
426
|
+
cancel,
|
|
427
|
+
onStart$: onStart$.asObservable(),
|
|
428
|
+
onFinish$: onFinish$.asObservable(),
|
|
429
|
+
onCancel$: onCancel$.asObservable(),
|
|
430
|
+
};
|
|
431
|
+
};
|
|
365
432
|
|
|
366
433
|
const clamp = (value, min = 0, max = 100) => {
|
|
367
434
|
return Math.max(min, Math.min(max, value));
|
|
@@ -1061,14 +1128,16 @@ class AnimatableDirective {
|
|
|
1061
1128
|
this._totalActiveAnimationCount$.next(this._totalActiveAnimationCount$.value - this._hostActiveAnimationCount$.value);
|
|
1062
1129
|
this._hostActiveAnimationCount$.next(0);
|
|
1063
1130
|
merge(fromEvent(el, 'animationstart'), fromEvent(el, 'transitionstart'))
|
|
1064
|
-
.pipe(
|
|
1131
|
+
.pipe(filter((e) => e.target === el), // skip events from children
|
|
1132
|
+
tap(() => {
|
|
1065
1133
|
const count = this._hostActiveAnimationCount$.value + 1;
|
|
1066
1134
|
this._hostActiveAnimationCount$.next(count);
|
|
1067
1135
|
this._totalActiveAnimationCount$.next(count);
|
|
1068
1136
|
}), takeUntil(this._destroy$), takeUntil(this._animatedElement$.pipe(skip(1))))
|
|
1069
1137
|
.subscribe();
|
|
1070
1138
|
merge(fromEvent(el, 'animationend'), fromEvent(el, 'animationcancel'), fromEvent(el, 'transitionend'), fromEvent(el, 'transitioncancel'))
|
|
1071
|
-
.pipe(
|
|
1139
|
+
.pipe(filter((e) => e.target === el), // skip events from children
|
|
1140
|
+
tap(() => {
|
|
1072
1141
|
const count = this._hostActiveAnimationCount$.value - 1;
|
|
1073
1142
|
this._hostActiveAnimationCount$.next(count);
|
|
1074
1143
|
this._totalActiveAnimationCount$.next(count);
|
|
@@ -2444,5 +2513,5 @@ const Validators = {
|
|
|
2444
2513
|
* Generated bundle index. Do not edit.
|
|
2445
2514
|
*/
|
|
2446
2515
|
|
|
2447
|
-
export { ANIMATABLE_TOKEN, ANIMATED_LIFECYCLE_TOKEN, AnimatableDirective, AnimatedLifecycleDirective, ClickObserverFactory, ClickObserverService, ClickOutsideDirective, ContentObserverService, CursorDragScrollDirective, DEFAULT_VIEWPORT_CONFIG, DestroyService, FocusVisibleService, IS_ARRAY_NOT_EMPTY, IS_EMAIL, IsArrayNotEmpty, IsEmail, LetContext, LetDirective, MUST_MATCH, Memo, MustMatch, MutationObserverFactory, NormalizeGameResultTypePipe, NormalizeMatchParticipantsPipe, NormalizeMatchScorePipe, NormalizeMatchStatePipe, NormalizeMatchTypePipe, OBSERVE_SCROLL_STATE, ObserveContentDirective, ObserveResizeDirective, ObserveScrollStateDirective, RepeatDirective, ResizeObserverFactory, ResizeObserverService, RouterStateService, SCROLL_OBSERVER_FIRST_ELEMENT_CLASS, SCROLL_OBSERVER_IGNORE_TARGET_CLASS, SCROLL_OBSERVER_LAST_ELEMENT_CLASS, SEO_DIRECTIVE_TOKEN, ScrollObserverFirstElementDirective, ScrollObserverIgnoreTargetDirective, ScrollObserverLastElementDirective, SeoDirective, StructuredDataComponent, ToArrayPipe, TypedQueryList, VIEWPORT_CONFIG, Validators, ViewportService, clamp, clone, createMediaQueryObservable, createReactiveBindings, deleteCookie, elementCanScroll, equal, forceReflow, fromNextFrame, getCookie, getDomain, getGroupMatchPoints, getGroupMatchScore, getKnockoutMatchScore, getMatchScoreSubLine, hasCookie, isGroupMatch, isKnockoutMatch, mergeSeoConfig, nextFrame, normalizeGameResultType, normalizeMatchParticipant, normalizeMatchParticipants, normalizeMatchScore, normalizeMatchState, normalizeMatchType, provideViewportConfig, routerDisableScrollTop, setCookie, toArray, toArrayTrackByFn };
|
|
2516
|
+
export { ANIMATABLE_TOKEN, ANIMATED_LIFECYCLE_TOKEN, AnimatableDirective, AnimatedLifecycleDirective, ClickObserverFactory, ClickObserverService, ClickOutsideDirective, ContentObserverService, CursorDragScrollDirective, DEFAULT_VIEWPORT_CONFIG, DestroyService, FocusVisibleService, IS_ARRAY_NOT_EMPTY, IS_EMAIL, IsArrayNotEmpty, IsEmail, LetContext, LetDirective, MUST_MATCH, Memo, MustMatch, MutationObserverFactory, NormalizeGameResultTypePipe, NormalizeMatchParticipantsPipe, NormalizeMatchScorePipe, NormalizeMatchStatePipe, NormalizeMatchTypePipe, OBSERVE_SCROLL_STATE, ObserveContentDirective, ObserveResizeDirective, ObserveScrollStateDirective, RepeatDirective, ResizeObserverFactory, ResizeObserverService, RouterStateService, SCROLL_OBSERVER_FIRST_ELEMENT_CLASS, SCROLL_OBSERVER_IGNORE_TARGET_CLASS, SCROLL_OBSERVER_LAST_ELEMENT_CLASS, SEO_DIRECTIVE_TOKEN, ScrollObserverFirstElementDirective, ScrollObserverIgnoreTargetDirective, ScrollObserverLastElementDirective, SeoDirective, StructuredDataComponent, ToArrayPipe, TypedQueryList, VIEWPORT_CONFIG, Validators, ViewportService, clamp, clone, createFlipAnimation, createMediaQueryObservable, createReactiveBindings, deleteCookie, elementCanScroll, equal, forceReflow, fromNextFrame, getCookie, getDomain, getGroupMatchPoints, getGroupMatchScore, getKnockoutMatchScore, getMatchScoreSubLine, hasCookie, isGroupMatch, isKnockoutMatch, mergeSeoConfig, nextFrame, normalizeGameResultType, normalizeMatchParticipant, normalizeMatchParticipants, normalizeMatchScore, normalizeMatchState, normalizeMatchType, provideViewportConfig, routerDisableScrollTop, setCookie, toArray, toArrayTrackByFn };
|
|
2448
2517
|
//# sourceMappingURL=ethlete-core.mjs.map
|