UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) • 921 B
import{__decorate as l}from"tslib";import{easeQuadInOut as P}from"d3-ease";import{observable as A,reaction as b}from"mobx";import{registerPlanDisposer as g}from"../../../../plan-lifecycle.js";import{eventScopedCache as h}from"../../../../tools/event-scoped-cache.js";const s=h();export default class a{constructor(t){this.selectBgAnimationPart=0,B(()=>t.selected,r=>this.selectBgAnimationPart=P(r),1e3,8,!0)}static get(t){let r=s().get(t);return r||(r=new a(t),s().set(t,r)),r}}l([A],a.prototype,"selectBgAnimationPart",void 0);function B(c,t,r,i,m){const p=m?u:f;i%2===1&&i++,g(b(c,()=>{if(c()){const o=performance.now(),e=o+i*r,n=()=>{if(c()){if(performance.now()>=e){t(1);return}t(p(o,r)),window.requestAnimationFrame(n)}};n()}else t(0)},{fireImmediately:!0}));function f(o,e){return(performance.now()-o)%e/1e3}function u(o,e){const d=((performance.now()-o)%(e*2)-e)/1e3;return 1-Math.abs(Math.abs(d)-e/1e3)/(e/1e3)}}