fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
2 lines • 1.18 kB
JavaScript
import{NONE as e}from"../../constants.min.mjs";import{getDocumentFromElement as t,getScrollLeftTop as n,getWindowFromElement as r}from"../../util/dom_misc.min.mjs";const i=(e,t,{width:n,height:r},i=1)=>{e.width=n,e.height=r,i>1&&(e.setAttribute(`width`,(n*i).toString()),e.setAttribute(`height`,(r*i).toString()),t.scale(i,i))},a=(e,{width:t,height:n})=>{t&&(e.style.width=typeof t==`number`?`${t}px`:t),n&&(e.style.height=typeof n==`number`?`${n}px`:n)};function o(e){var i;let a=e&&t(e),o={left:0,top:0};if(!a)return o;let s=((i=r(e))==null?void 0:i.getComputedStyle(e,null))||{};o.left+=parseInt(s.borderLeftWidth,10)||0,o.top+=parseInt(s.borderTopWidth,10)||0,o.left+=parseInt(s.paddingLeft,10)||0,o.top+=parseInt(s.paddingTop,10)||0;let c={left:0,top:0},l=a.documentElement;e.getBoundingClientRect!==void 0&&(c=e.getBoundingClientRect());let u=n(e);return{left:c.left+u.left-(l.clientLeft||0)+o.left,top:c.top+u.top-(l.clientTop||0)+o.top}}function s(t){return t.onselectstart!==void 0&&(t.onselectstart=()=>!1),t.style.userSelect=e,t}export{o as getElementOffset,s as makeElementUnselectable,a as setCSSDimensions,i as setCanvasDimensions};
//# sourceMappingURL=util.min.mjs.map