@ethlete/core 1.1.1 → 1.3.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { inject, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, HostBinding, InjectionToken, Injectable, ElementRef, Inject, Optional, isDevMode, Directive, EventEmitter, Output, NgZone, Pipe, QueryList } from '@angular/core';
|
|
3
3
|
import { DomSanitizer, Meta, Title } from '@angular/platform-browser';
|
|
4
|
-
import { fromEvent, Observable, Subject, startWith, map, takeUntil, distinctUntilChanged, BehaviorSubject, filter,
|
|
4
|
+
import { fromEvent, Observable, Subject, combineLatest, startWith, map, takeUntil, distinctUntilChanged, BehaviorSubject, filter, pairwise, debounceTime, shareReplay, tap, merge, skip, switchMap, take } from 'rxjs';
|
|
5
5
|
import { coerceElement, coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
|
|
6
6
|
import { DOCUMENT } from '@angular/common';
|
|
7
7
|
import { Router, NavigationEnd } from '@angular/router';
|
|
@@ -362,6 +362,97 @@ const fromNextFrame = () => {
|
|
|
362
362
|
const forceReflow = (element = document.body) => {
|
|
363
363
|
return element.offsetHeight;
|
|
364
364
|
};
|
|
365
|
+
const createFlipAnimationGroup = (config) => {
|
|
366
|
+
const { elements, duration = 250, easing = 'cubic-bezier(0.4, 0, 0.2, 1)' } = config;
|
|
367
|
+
const flips = elements.map((el) => createFlipAnimation({ element: el, duration, easing }));
|
|
368
|
+
const onStart$ = combineLatest(flips.map((animation) => animation.onStart$));
|
|
369
|
+
const onFinish$ = combineLatest(flips.map((animation) => animation.onFinish$));
|
|
370
|
+
const onCancel$ = combineLatest(flips.map((animation) => animation.onCancel$));
|
|
371
|
+
const updateInit = () => {
|
|
372
|
+
flips.forEach((animation) => animation.updateInit());
|
|
373
|
+
};
|
|
374
|
+
const play = () => {
|
|
375
|
+
flips.forEach((animation) => animation.play());
|
|
376
|
+
};
|
|
377
|
+
const cancel = () => {
|
|
378
|
+
flips.forEach((animation) => animation.cancel());
|
|
379
|
+
};
|
|
380
|
+
return {
|
|
381
|
+
updateInit,
|
|
382
|
+
play,
|
|
383
|
+
cancel,
|
|
384
|
+
onStart$,
|
|
385
|
+
onFinish$,
|
|
386
|
+
onCancel$,
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
const createFlipAnimation = (config) => {
|
|
390
|
+
const { element: el, duration = 250, easing = 'cubic-bezier(0.4, 0, 0.2, 1)' } = config;
|
|
391
|
+
let initialRect = el.getBoundingClientRect();
|
|
392
|
+
let animation = null;
|
|
393
|
+
const onStart$ = new Subject();
|
|
394
|
+
const onFinish$ = new Subject();
|
|
395
|
+
const onCancel$ = new Subject();
|
|
396
|
+
const onAnimationFinish = () => {
|
|
397
|
+
cleanup();
|
|
398
|
+
onFinish$.next();
|
|
399
|
+
};
|
|
400
|
+
const onAnimationCancel = () => {
|
|
401
|
+
cleanup();
|
|
402
|
+
onCancel$.next();
|
|
403
|
+
};
|
|
404
|
+
const cleanup = () => {
|
|
405
|
+
if (!animation) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
animation.removeEventListener('finish', onAnimationFinish);
|
|
409
|
+
animation.removeEventListener('cancel', onAnimationCancel);
|
|
410
|
+
};
|
|
411
|
+
const updateInit = () => {
|
|
412
|
+
initialRect = el.getBoundingClientRect();
|
|
413
|
+
};
|
|
414
|
+
const play = () => {
|
|
415
|
+
const lastRect = el.getBoundingClientRect();
|
|
416
|
+
const delta = {
|
|
417
|
+
x: initialRect.left - lastRect.left,
|
|
418
|
+
y: initialRect.top - lastRect.top,
|
|
419
|
+
scaleX: initialRect.width / lastRect.width,
|
|
420
|
+
scaleY: initialRect.height / lastRect.height,
|
|
421
|
+
};
|
|
422
|
+
animation = el.animate([
|
|
423
|
+
{
|
|
424
|
+
transformOrigin: 'top left',
|
|
425
|
+
transform: `
|
|
426
|
+
translate(${delta.x}px, ${delta.y}px)
|
|
427
|
+
scale(${delta.scaleX}, ${delta.scaleY})
|
|
428
|
+
`,
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
transformOrigin: 'top left',
|
|
432
|
+
transform: 'none',
|
|
433
|
+
},
|
|
434
|
+
], {
|
|
435
|
+
duration,
|
|
436
|
+
easing,
|
|
437
|
+
fill: 'both',
|
|
438
|
+
});
|
|
439
|
+
animation.addEventListener('finish', onAnimationFinish);
|
|
440
|
+
animation.addEventListener('cancel', onAnimationCancel);
|
|
441
|
+
onStart$.next();
|
|
442
|
+
};
|
|
443
|
+
const cancel = () => {
|
|
444
|
+
animation?.cancel();
|
|
445
|
+
cleanup();
|
|
446
|
+
};
|
|
447
|
+
return {
|
|
448
|
+
updateInit,
|
|
449
|
+
play,
|
|
450
|
+
cancel,
|
|
451
|
+
onStart$: onStart$.asObservable(),
|
|
452
|
+
onFinish$: onFinish$.asObservable(),
|
|
453
|
+
onCancel$: onCancel$.asObservable(),
|
|
454
|
+
};
|
|
455
|
+
};
|
|
365
456
|
|
|
366
457
|
const clamp = (value, min = 0, max = 100) => {
|
|
367
458
|
return Math.max(min, Math.min(max, value));
|
|
@@ -2446,5 +2537,5 @@ const Validators = {
|
|
|
2446
2537
|
* Generated bundle index. Do not edit.
|
|
2447
2538
|
*/
|
|
2448
2539
|
|
|
2449
|
-
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 };
|
|
2540
|
+
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, createFlipAnimationGroup, 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 };
|
|
2450
2541
|
//# sourceMappingURL=ethlete-core.mjs.map
|