UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 794 B
import{createLineDef as d}from"../../renderer";import{animateLineSegments as A}from"../../renderer/engine-core/animation";export function createRouteLineManager(s,m,r){let e=null,n=null,i=null;return{setRouteLines(f,h,l){const o=s.touchLayer(l.linesLayer),a=s.touchLayer(l.animatedLinesLayer);n=o,i=a;const p=l.resetAnimation??!0;let u=0;e&&(p||(u=e.getProgress()),e.stop(),e=null);const y=f.map(t=>d(t,r.passed)),c=h.map(t=>d(t,r.remaining));if(o.children=[...y,...c],!c.length){a.children=[];return}const L=c.map(t=>({...t,color:r.active}));e=A(L,(t,g,D)=>{a.children=D?[]:[...L.slice(0,g),t],m.update(a)},()=>m.scale,u)??null},clearLines(){e&&(e.stop(),e=null),n&&(n.children=[],s.touchedLayers.set(n.name,n)),i&&(i.children=[],s.touchedLayers.set(i.name,i))},destroy(){this.clearLines()}}}