@ethlete/core 1.0.0 → 1.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/esm2020/lib/directives/animatable/animatable.directive.mjs +51 -17
- package/esm2020/lib/directives/animated-lifecycle/animated-lifecycle.directive.mjs +3 -3
- package/fesm2015/ethlete-core.mjs +52 -18
- package/fesm2015/ethlete-core.mjs.map +1 -1
- package/fesm2020/ethlete-core.mjs +52 -18
- package/fesm2020/ethlete-core.mjs.map +1 -1
- package/lib/directives/animatable/animatable.directive.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, HostBinding, InjectionToken, Injectable, ElementRef, Inject, Optional,
|
|
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, combineLatest, pairwise, debounceTime, shareReplay, merge,
|
|
4
|
+
import { fromEvent, Observable, Subject, startWith, map, takeUntil, distinctUntilChanged, BehaviorSubject, filter, combineLatest, 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';
|
|
@@ -1024,25 +1024,56 @@ class AnimatableDirective {
|
|
|
1024
1024
|
this._elementRef = inject(ElementRef);
|
|
1025
1025
|
this._animationStart$ = new Subject();
|
|
1026
1026
|
this._animationEnd$ = new Subject();
|
|
1027
|
+
this._animatedElement$ = new BehaviorSubject(this._elementRef.nativeElement);
|
|
1027
1028
|
this.animationStart$ = this._animationStart$.asObservable().pipe(debounceTime(0));
|
|
1028
1029
|
this.animationEnd$ = this._animationEnd$.asObservable().pipe(debounceTime(0));
|
|
1029
1030
|
this._hostActiveAnimationCount$ = new BehaviorSubject(0);
|
|
1030
1031
|
this._totalActiveAnimationCount$ = new BehaviorSubject(0);
|
|
1031
1032
|
this.isAnimating$ = this._totalActiveAnimationCount$.pipe(map((count) => count > 0), debounceTime(0));
|
|
1032
1033
|
}
|
|
1034
|
+
set animatedElement(value) {
|
|
1035
|
+
let newElement = null;
|
|
1036
|
+
if (value === null || value === undefined) {
|
|
1037
|
+
newElement = this._elementRef.nativeElement;
|
|
1038
|
+
}
|
|
1039
|
+
else if (typeof value === 'string') {
|
|
1040
|
+
const el = document.querySelector(value);
|
|
1041
|
+
if (el) {
|
|
1042
|
+
newElement = el;
|
|
1043
|
+
}
|
|
1044
|
+
else {
|
|
1045
|
+
if (isDevMode()) {
|
|
1046
|
+
console.warn(`Element with selector ${value} not found. Animatable directive will use host element.`);
|
|
1047
|
+
}
|
|
1048
|
+
newElement = this._elementRef.nativeElement;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
else {
|
|
1052
|
+
newElement = value;
|
|
1053
|
+
}
|
|
1054
|
+
if (this._animatedElement$.value !== newElement) {
|
|
1055
|
+
this._animatedElement$.next(newElement);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1033
1058
|
ngOnInit() {
|
|
1034
|
-
|
|
1035
|
-
.pipe(tap(() => {
|
|
1036
|
-
|
|
1037
|
-
this._hostActiveAnimationCount$.next(
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1059
|
+
this._animatedElement$
|
|
1060
|
+
.pipe(tap((el) => {
|
|
1061
|
+
this._totalActiveAnimationCount$.next(this._totalActiveAnimationCount$.value - this._hostActiveAnimationCount$.value);
|
|
1062
|
+
this._hostActiveAnimationCount$.next(0);
|
|
1063
|
+
merge(fromEvent(el, 'animationstart'), fromEvent(el, 'transitionstart'))
|
|
1064
|
+
.pipe(tap(() => {
|
|
1065
|
+
const count = this._hostActiveAnimationCount$.value + 1;
|
|
1066
|
+
this._hostActiveAnimationCount$.next(count);
|
|
1067
|
+
this._totalActiveAnimationCount$.next(count);
|
|
1068
|
+
}), takeUntil(this._destroy$), takeUntil(this._animatedElement$.pipe(skip(1))))
|
|
1069
|
+
.subscribe();
|
|
1070
|
+
merge(fromEvent(el, 'animationend'), fromEvent(el, 'animationcancel'), fromEvent(el, 'transitionend'), fromEvent(el, 'transitioncancel'))
|
|
1071
|
+
.pipe(tap(() => {
|
|
1072
|
+
const count = this._hostActiveAnimationCount$.value - 1;
|
|
1073
|
+
this._hostActiveAnimationCount$.next(count);
|
|
1074
|
+
this._totalActiveAnimationCount$.next(count);
|
|
1075
|
+
}), takeUntil(this._destroy$), takeUntil(this._animatedElement$.pipe(skip(1))))
|
|
1076
|
+
.subscribe();
|
|
1046
1077
|
}), takeUntil(this._destroy$))
|
|
1047
1078
|
.subscribe();
|
|
1048
1079
|
this._totalActiveAnimationCount$
|
|
@@ -1067,7 +1098,7 @@ class AnimatableDirective {
|
|
|
1067
1098
|
}
|
|
1068
1099
|
}
|
|
1069
1100
|
AnimatableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: AnimatableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1070
|
-
AnimatableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.4", type: AnimatableDirective, isStandalone: true, selector: "[etAnimatable]", providers: [
|
|
1101
|
+
AnimatableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.4", type: AnimatableDirective, isStandalone: true, selector: "[etAnimatable]", inputs: { animatedElement: ["etAnimatable", "animatedElement"] }, providers: [
|
|
1071
1102
|
{
|
|
1072
1103
|
provide: ANIMATABLE_TOKEN,
|
|
1073
1104
|
useExisting: AnimatableDirective,
|
|
@@ -1088,7 +1119,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
|
|
|
1088
1119
|
DestroyService,
|
|
1089
1120
|
],
|
|
1090
1121
|
}]
|
|
1091
|
-
}]
|
|
1122
|
+
}], propDecorators: { animatedElement: [{
|
|
1123
|
+
type: Input,
|
|
1124
|
+
args: ['etAnimatable']
|
|
1125
|
+
}] } });
|
|
1092
1126
|
|
|
1093
1127
|
const ANIMATED_LIFECYCLE_TOKEN = new InjectionToken('ANIMATED_LIFECYCLE_DIRECTIVE_TOKEN');
|
|
1094
1128
|
const ANIMATION_CLASSES = {
|
|
@@ -1117,7 +1151,7 @@ class AnimatedLifecycleDirective {
|
|
|
1117
1151
|
}
|
|
1118
1152
|
enter(config) {
|
|
1119
1153
|
if (this.state !== 'init' && this.state !== 'left' && isDevMode()) {
|
|
1120
|
-
|
|
1154
|
+
console.warn('Tried to enter but the element is not in the initial state. This may result in unexpected behavior.', this);
|
|
1121
1155
|
}
|
|
1122
1156
|
this._state$.next('entering');
|
|
1123
1157
|
if (!config?.onlyTransition) {
|
|
@@ -1142,7 +1176,7 @@ class AnimatedLifecycleDirective {
|
|
|
1142
1176
|
}
|
|
1143
1177
|
leave(config) {
|
|
1144
1178
|
if (this.state !== 'entered' && this.state !== 'entering' && isDevMode()) {
|
|
1145
|
-
|
|
1179
|
+
console.warn('Tried to leave while already leaving or left. This may result in unexpected behavior.', this);
|
|
1146
1180
|
}
|
|
1147
1181
|
if (this._classList.contains(ANIMATION_CLASSES.enterFrom) ||
|
|
1148
1182
|
this._classList.contains(ANIMATION_CLASSES.enterActive) ||
|