UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 1.82 kB
import{reaction as o}from"mobx";import{createBookmarkCanvas as m,createImageDef as k,getClampedBoundsCanvas as c,getRotation as l}from"../../../../renderer";import{getRollValue as p}from"../../../../renderer";import{updateRectRotation as u}from"../../../../renderer";import{layersStore as a,uiState as s}from"../../../../store";import{BoothDrawerBaseWithoutPainter as f}from"./BoothDrawerBase";import{Rect as h}from"./Rect";export default function b(t,e){if(!s.kiosk)return new S(t,e)}class S extends f{rendererService;shape;bookmarkId;canvas;rect;padding;constructor(e,r){super(r),this.rendererService=e,this.padding=this.booth.borderWidth/2,this.rect=h.fromCoreRect(this.booth.rect,this.booth.rotate),this.canvas=m(11,devicePixelRatio),this.bookmarkId=`bookmark-${this.booth.id}`,this.shape=k(this.canvas,h.fromCoreRect(this.booth.rect,this.booth.rotate),{hidden:!r.bookmarked}),o(()=>[r.bookmarked,a.layersLoaded,this.booth.skipDim],()=>this.update(r.bookmarked),{fireImmediately:r.bookmarked}),o(()=>s.mapSettings,({roll:d})=>{p(d)&&this.rendererService.onRoll(`bookmark-roll-${this.bookmarkId}`,n=>{const i=l(n,this.rect.rotation);return i!==void 0&&(this.rect=u(this.rect,i),this.handleBookmarkScale()),this.shape})})}getShape=()=>this.shape;update(e){a.layersLoaded&&(this.shape.hidden=!e,this.shape.dim=this.booth.skipDim?!1:void 0,this.handleBookmarkScale(),this.shape.hidden?(this.rendererService.ptScaleRegistry.unregisterByName(this.bookmarkId),this.rendererService.rollRegistry.unregisterByName(`bookmark-roll-${this.bookmarkId}`)):this.rendererService.onPtScale(this.bookmarkId,this.handleBookmarkScale.bind(this)),this.rendererService.update(this.shape))}handleBookmarkScale(e){if(!this.shape.hidden)return this.shape.bounds=c(this.rect,this.canvas,this.padding,e||this.rendererService.scale),this.shape}}