MCPcopy Index your code
hub / github.com/gridstack/gridstack.js / getValuesFromTransformedElement

Method getValuesFromTransformedElement

src/utils.ts:727–748  ·  view source on GitHub ↗

* defines an element that is used to get the offset and scale from grid transforms * returns the scale and offsets from said element

(parent: HTMLElement)

Source from the content-addressed store, hash-verified

725 * returns the scale and offsets from said element
726 */
727 public static getValuesFromTransformedElement(parent: HTMLElement): DragTransform {
728 const transformReference = document.createElement('div');
729 Utils.addElStyles(transformReference, {
730 opacity: '0',
731 position: 'fixed',
732 top: 0 + 'px',
733 left: 0 + 'px',
734 width: '1px',
735 height: '1px',
736 zIndex: '-999999',
737 });
738 parent.appendChild(transformReference);
739 const transformValues = transformReference.getBoundingClientRect();
740 parent.removeChild(transformReference);
741 transformReference.remove();
742 return {
743 xScale: 1 / transformValues.width,
744 yScale: 1 / transformValues.height,
745 xOffset: transformValues.left,
746 yOffset: transformValues.top,
747 }
748 }
749
750 /** swap the given object 2 field values */
751 public static swap(o: unknown, a: string, b: string): void {

Callers 4

_mouseMoveMethod · 0.80
_onStartMovingMethod · 0.80
_setupHelperMethod · 0.80
utils-spec.tsFile · 0.80

Calls 1

addElStylesMethod · 0.80

Tested by

no test coverage detected