Skip to content

Commit c8584b9

Browse files
committed
feat(animation): Add scaleInCenter animation
1 parent 5273de2 commit c8584b9

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { EaseOut } from '../../easings.js';
2+
import { animation } from '../../types.js';
3+
4+
const baseOptions: KeyframeAnimationOptions = {
5+
duration: 350,
6+
easing: EaseOut.Quad,
7+
};
8+
9+
const scaleInCenter = (options = baseOptions) =>
10+
animation(
11+
[
12+
{ transform: 'scale(0)', opacity: 0 },
13+
{ transform: 'scale(1)', opacity: 1 },
14+
],
15+
options
16+
);
17+
18+
export { scaleInCenter };

src/components/tooltip/tooltip.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { LitElement, html, nothing } from 'lit';
22
import { property, query } from 'lit/decorators.js';
33
import { type Ref, createRef, ref } from 'lit/directives/ref.js';
44
import { addAnimationController } from '../../animations/player.js';
5-
import { fadeIn, fadeOut } from '../../animations/presets/fade/index.js';
5+
import { fadeOut } from '../../animations/presets/fade/index.js';
6+
import { scaleInCenter } from '../../animations/presets/scale/index.js';
67
import { watch } from '../common/decorators/watch.js';
78
import { registerComponent } from '../common/definitions/register.js';
89
import type { Constructor } from '../common/mixins/constructor.js';
@@ -246,7 +247,7 @@ export default class IgcTooltipComponent extends EventEmitterMixin<
246247
}
247248

248249
private async _toggleAnimation(dir: 'open' | 'close') {
249-
const animation = dir === 'open' ? fadeIn : fadeOut;
250+
const animation = dir === 'open' ? scaleInCenter : fadeOut;
250251
return this._animationPlayer.playExclusive(animation());
251252
}
252253

0 commit comments

Comments
 (0)