@fancyapps/ui
Version:
Robust JavaScript UI Component Library
1 lines • 1.29 kB
JavaScript
!/*! License details at fancyapps.com/license */function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).window=e.window||{})}(this,function(e){"use strict";e.Pins=()=>{let e,t=[];function n(){(function(){let n=e?.getContainer();if(!n)return;t=[];let o=Array.from(n.querySelectorAll(".f-panzoom__pin"));if(o.length)for(let e of o)t.push({x:e.dataset.x+"",y:e.dataset.y+"",el:e})})(),i()}function o(){i()}function i(){if(e&&t.length)for(let n of t){if(!n.el)continue;let{width:t,height:o}=e.getFullDim(),i=n.x+"",l=n.y+"",r=0,f=0,a=e.getTransform(),s=a.angle||0,d=a.flipX||0,u=a.flipY||0,p=a.x||0,c=a.y||0,y=a.scale||1,g=e?.getWrapper()?.getBoundingClientRect(),h=0,x=0;g&&(h=g.width,x=g.height),r=(i.includes("%")?h*(parseFloat(i)/100):parseFloat(i)/t*h)-.5*h,f=(l.includes("%")?x*(parseFloat(l)/100):parseFloat(l)/o*x)-.5*x;let m=new DOMMatrix([y,0,0,y,p,c]);m=(m=(m=m.scale(d,1)).scale(1,u)).rotate(s);let w=new DOMPoint(r,f).matrixTransform(m);r=w.x,f=w.y,n.el.style.transform=`translate3d(${r||0}px, ${f||0}px, 0)`}}return{init:function(t){(e=t).on("ready",n),e.on("render",o)},destroy:function(){e?.off("ready",n),e?.off("render",o),e=void 0}}}});