MCPcopy
hub / github.com/greensock/GSAP / getGlobalMatrix

Function getGlobalMatrix

esm/utils/matrix.js:398–428  ·  view source on GitHub ↗
(element, inverse, adjustGOffset, includeScrollInFixed)

Source from the content-addressed store, hash-verified

396// ty = m.b * x + m.d * y + m.f
397
398export function getGlobalMatrix(element, inverse, adjustGOffset, includeScrollInFixed) {
399 // adjustGOffset is typically used only when grabbing an element's PARENT's global matrix, and it ignores the x/y offset of any SVG <g> elements because they behave in a special way.
400 if (!element || !element.parentNode || (_doc || _setDoc(element)).documentElement === element) {
401 return new Matrix2D();
402 }
403
404 var zeroScales = _forceNonZeroScale(element),
405 svg = _svgOwner(element),
406 temps = svg ? _svgTemps : _divTemps,
407 container = _placeSiblings(element, adjustGOffset),
408 b1 = temps[0].getBoundingClientRect(),
409 b2 = temps[1].getBoundingClientRect(),
410 b3 = temps[2].getBoundingClientRect(),
411 parent = container.parentNode,
412 isFixed = !includeScrollInFixed && _isFixed(element),
413 m = new Matrix2D((b2.left - b1.left) / 100, (b2.top - b1.top) / 100, (b3.left - b1.left) / 100, (b3.top - b1.top) / 100, b1.left + (isFixed ? 0 : _getDocScrollLeft()), b1.top + (isFixed ? 0 : _getDocScrollTop()));
414
415 parent.removeChild(container);
416
417 if (zeroScales) {
418 b1 = zeroScales.length;
419
420 while (b1--) {
421 b2 = zeroScales[b1];
422 b2.scaleX = b2.scaleY = 0;
423 b2.renderTransform(1, b2);
424 }
425 }
426
427 return inverse ? m.inverse() : m;
428}
429export { _getDocScrollTop, _getDocScrollLeft, _setDoc, _isFixed, _getCTM }; // export function getMatrix(element) {
430// _doc || _setDoc(element);
431// let m = (_win.getComputedStyle(element)[_transformProp] + "").substr(7).match(/[-.]*\d+[.e\-+]*\d*[e\-\+]*\d*/g),

Callers 13

_originToPointFunction · 0.90
_getAlignMatrixFunction · 0.90
_getElementBoundsFunction · 0.90
updateMatrixFunction · 0.90
recordStartPositionsFunction · 0.90
DraggableFunction · 0.90
_getInverseGlobalMatrixFunction · 0.90
_makeAbsoluteFunction · 0.90
_fitFunction · 0.90
_fromToFunction · 0.90
Flip.jsFile · 0.90

Calls 9

inverseMethod · 0.95
getBoundingClientRectMethod · 0.80
_setDocFunction · 0.70
_forceNonZeroScaleFunction · 0.70
_svgOwnerFunction · 0.70
_placeSiblingsFunction · 0.70
_isFixedFunction · 0.70
_getDocScrollLeftFunction · 0.70
_getDocScrollTopFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…