fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
3 lines (2 loc) • 1.45 kB
JavaScript
import{NONE as t,LEFT as e,TOP as o}from"../../constants.min.mjs";import{getDocumentFromElement as n,getWindowFromElement as i,getScrollLeftTop as c}from"../../util/dom_misc.min.mjs";import{setStyle as l}from"../../util/dom_style.min.mjs";const r=function(t,e,o){let{width:n,height:i}=o,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;t.width=n,t.height=i,c>1&&(t.setAttribute("width",(n*c).toString()),t.setAttribute("height",(i*c).toString()),e.scale(c,c))};function s(e,o){const n=o?"manipulation":t;l(e,{"touch-action":n,"-ms-touch-action":n})}const d=(t,e)=>{let{width:o,height:n}=e;o&&(t.style.width="number"==typeof o?"".concat(o,"px"):o),n&&(t.style.height="number"==typeof n?"".concat(n,"px"):n)};function u(t){var l;let r={left:0,top:0};const s=t&&n(t),d={left:0,top:0},u={borderLeftWidth:e,borderTopWidth:o,paddingLeft:e,paddingTop:o};if(!s)return d;const m=(null===(l=i(t))||void 0===l?void 0:l.getComputedStyle(t,null))||{};for(const t in u)d[u[t]]+=parseInt(m[t],10)||0;const p=s.documentElement;void 0!==t.getBoundingClientRect&&(r=t.getBoundingClientRect());const f=c(t);return{left:r.left+f.left-(p.clientLeft||0)+d.left,top:r.top+f.top-(p.clientTop||0)+d.top}}function m(e){return void 0!==e.onselectstart&&(e.onselectstart=()=>!1),e.style.userSelect=t,e}export{s as allowTouchScrolling,u as getElementOffset,m as makeElementUnselectable,d as setCSSDimensions,r as setCanvasDimensions};
//# sourceMappingURL=util.min.mjs.map