@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 1.62 kB
JavaScript
import{Rect as d}from"@expofp/geometry";import{update as p}from"@expofp/renderer";import{createImageDef as k}from"../../../../engine/defs";import{getClampedBoundsCanvas as u,getQuarterTurns as c,getRollValue as l,rotateRectByQuarters as f}from"../../../../engine/update-def";import{layersStore as i,uiState as a}from"../../../../store";import{planReaction as s}from"../../../../utils/plan-reactions.js";import{BoothDrawerBaseWithoutPainter as b}from"./BoothDrawerBase";import{bookmarkCanvasCssSize as B,createBookmarkCanvas as g}from"./canvases";export default function y(o){if(!a.kiosk)return new BoothBookmarkDrawer(o)}export class BoothBookmarkDrawer extends b{constructor(t){super(t),this.getShape=()=>this.shape,this.padding=this.booth.borderWidth/2,this.rect=new d(this.booth.rect.center,this.booth.rect.size,this.booth.rotate,this.booth.elevation),this.canvas=g(h,devicePixelRatio),this.bookmarkId=`bookmark-${this.booth.id}`,this.shape=k(this.canvas,this.rect,{hidden:!t.bookmarked}),this.shape.onScale=({pixelSize:e})=>this.layOutBookmark(e),s(()=>[t.bookmarked,i.layersLoaded,this.booth.skipDim],()=>this.update(t.bookmarked),{fireImmediately:t.bookmarked}),s(()=>a.mapSettings,({roll:e})=>{l(e??0)&&(this.shape.onRoll=({roll:n,pixelSize:m})=>{const r=c(n,this.rect.rotation);if(r!==0)return this.rect=f(this.rect,r),this.layOutBookmark(m),[this.shape]})},{fireImmediately:!0})}update(t){i.layersLoaded&&(this.shape.hidden=!t,this.shape.dim=this.booth.skipDim?0:void 0,p(this.shape))}layOutBookmark(t){return this.shape.bounds=u(this.rect,B(h),this.padding,t),this.shape.hidden?[]:[this.shape]}}const h=11;