Created
May 5, 2021 16:59
-
-
Save Vac1911/0d26b268ca38651cd53562a6f4bd618f to your computer and use it in GitHub Desktop.
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
const i=new WeakMap;class t{constructor(t,s){this.startPaused=!1,this.disabled=!1,this.flips=new Set,this.pendingComplete=!1,this.host=t,this.flipOptions=s.flipOptions||{},this.startPaused=!!s.startPaused,this.disabled=!!s.disabled,this.onComplete=s.onComplete,i.set(this.host,this)}async add(i){var t,s;this.flips.add(i),this.startPaused&&(null===(t=i.animation)||void 0===t||t.pause()),this.pendingComplete=!0,await i.finished,this.pendingComplete&&!this.isAnimating&&(this.pendingComplete=!1,null===(s=this.onComplete)||void 0===s||s.call(this))}remove(i){this.flips.delete(i)}pause(){this.flips.forEach((i=>{var t;return null===(t=i.animation)||void 0===t?void 0:t.pause()}))}play(){this.flips.forEach((i=>{var t;return null===(t=i.animation)||void 0===t?void 0:t.play()}))}cancel(){this.flips.forEach((i=>{var t;return null===(t=i.animation)||void 0===t?void 0:t.cancel()})),this.flips.clear()}finish(){this.flips.forEach((i=>{var t;return null===(t=i.animation)||void 0===t?void 0:t.finish()})),this.flips.clear()}togglePlay(){this.isPlaying?this.pause():this.play()}get isAnimating(){return this.flips.size>0}get isPlaying(){return Array.from(this.flips).some((i=>{var t;return"running"===(null===(t=i.animation)||void 0===t?void 0:t.playState)}))}async finished(){await Promise.all(Array.from(this.flips).map((i=>i.finished)))}}export{t as FlipController,i as flipControllers}; | |
//# sourceMappingURL=flip-controller.js.map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put this file into your
node_modules/@lit-labs/motion
folder. Make sure this file is namedflip-controller.js