-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1736 from exadel-inc/epic/esl-animate-4.0.0
epic: esl-animate documentation, mixin and cleanup (#1281)
- Loading branch information
Showing
10 changed files
with
600 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export type {ESLAnimateShape} from './core/esl-animate.shape'; | ||
|
||
export * from './core/esl-animate'; | ||
export * from './core/esl-animate-mixin'; | ||
export * from './core/esl-animate-service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {ESLMixinElement} from '../../esl-mixin-element/core'; | ||
import {ready, jsonAttr} from '../../esl-utils/decorators'; | ||
import {ExportNs} from '../../esl-utils/environment/export-ns'; | ||
|
||
import {ESLAnimateService} from './esl-animate-service'; | ||
import type {ESLAnimateConfig} from './esl-animate-service'; | ||
|
||
/** | ||
* ESLAnimateMixin - custom mixin element for quick {@link ESLAnimateService} attaching | ||
* | ||
* Use example: | ||
* `<div esl-animate>Content</div>` | ||
* | ||
* Supports additional parameters: | ||
* `<div esl-animate={repeat: true, ratio: 0.8, cls: 'in'}>Content</div>` | ||
*/ | ||
@ExportNs('AnimateMixin') | ||
export class ESLAnimateMixin extends ESLMixinElement { | ||
public static override is = 'esl-animate'; | ||
|
||
public static defaultConfig: ESLAnimateConfig = { | ||
force: true | ||
}; | ||
|
||
@jsonAttr({name: ESLAnimateMixin.is}) | ||
public options?: ESLAnimateConfig; | ||
|
||
protected mergeDefaultParams(): ESLAnimateConfig { | ||
const type = this.constructor as typeof ESLAnimateMixin; | ||
return Object.assign({}, type.defaultConfig, this.options); | ||
} | ||
|
||
@ready | ||
public override connectedCallback(): void { | ||
super.connectedCallback(); | ||
this.reanimate(); | ||
} | ||
|
||
@ready | ||
public override disconnectedCallback(): void { | ||
super.disconnectedCallback(); | ||
ESLAnimateService.unobserve(this.$host); | ||
} | ||
|
||
/** Reinitialize {@link ESLAnimateService} for target */ | ||
public reanimate(): void { | ||
ESLAnimateService.unobserve(this.$host); | ||
ESLAnimateService.observe(this.$host, this.mergeDefaultParams()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.