@hilux/ngx-motion 1.0.6 → 1.0.7
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/package.json
CHANGED
|
@@ -133,10 +133,43 @@ export class MotionDirective implements OnDestroy, AfterViewInit, OnChanges {
|
|
|
133
133
|
private setupHoverAnimations() {
|
|
134
134
|
if (this.onHover) {
|
|
135
135
|
this.el.nativeElement.addEventListener('mouseenter', () => {
|
|
136
|
-
|
|
136
|
+
const currentStyles = getComputedStyle(this.el.nativeElement);
|
|
137
|
+
const currentState: { [key: string]: any } = {};
|
|
138
|
+
|
|
139
|
+
Object.keys(this.onHover).forEach((key: string) => {
|
|
140
|
+
currentState[key] = currentStyles[key as keyof CSSStyleDeclaration];
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const animation = this.builder.build([
|
|
144
|
+
style(currentState),
|
|
145
|
+
animate(`${this.duration} ${this.easing}`, style(this.onHover))
|
|
146
|
+
]);
|
|
147
|
+
|
|
148
|
+
if (this.player) {
|
|
149
|
+
this.player.destroy();
|
|
150
|
+
}
|
|
151
|
+
this.player = animation.create(this.el.nativeElement);
|
|
152
|
+
this.player.play();
|
|
137
153
|
});
|
|
154
|
+
|
|
138
155
|
this.el.nativeElement.addEventListener('mouseleave', () => {
|
|
139
|
-
|
|
156
|
+
const currentStyles = getComputedStyle(this.el.nativeElement);
|
|
157
|
+
const currentState: { [key: string]: any } = {};
|
|
158
|
+
|
|
159
|
+
Object.keys(this.onHover).forEach((key: string) => {
|
|
160
|
+
currentState[key] = currentStyles[key as keyof CSSStyleDeclaration];
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const animation = this.builder.build([
|
|
164
|
+
style(currentState),
|
|
165
|
+
animate(`${this.duration} ${this.easing}`, style(this.animate || this.initial))
|
|
166
|
+
]);
|
|
167
|
+
|
|
168
|
+
if (this.player) {
|
|
169
|
+
this.player.destroy();
|
|
170
|
+
}
|
|
171
|
+
this.player = animation.create(this.el.nativeElement);
|
|
172
|
+
this.player.play();
|
|
140
173
|
});
|
|
141
174
|
}
|
|
142
175
|
}
|