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

Function _originToPoint

esm/MotionPathPlugin.js:90–119  ·  view source on GitHub ↗
(element, origin, parentMatrix)

Source from the content-addressed store, hash-verified

88},
89 _numExp = /[-+\.]*\d+\.?(?:e-|e\+)?\d*/g,
90 _originToPoint = function _originToPoint(element, origin, parentMatrix) {
91 // origin is an array of normalized values (0-1) in relation to the width/height, so [0.5, 0.5] would be the center. It can also be "auto" in which case it will be the top left unless it's a <path>, when it will start at the beginning of the path itself.
92 var m = getGlobalMatrix(element),
93 x = 0,
94 y = 0,
95 svg;
96
97 if ((element.tagName + "").toLowerCase() === "svg") {
98 svg = element.viewBox.baseVal;
99 svg.width || (svg = {
100 width: +element.getAttribute("width"),
101 height: +element.getAttribute("height")
102 });
103 } else {
104 svg = origin && element.getBBox && element.getBBox();
105 }
106
107 if (origin && origin !== "auto") {
108 x = origin.push ? origin[0] * (svg ? svg.width : element.offsetWidth || 0) : origin.x;
109 y = origin.push ? origin[1] * (svg ? svg.height : element.offsetHeight || 0) : origin.y;
110 }
111
112 return parentMatrix.apply(x || y ? m.apply({
113 x: x,
114 y: y
115 }) : {
116 x: m.e,
117 y: m.f
118 });
119},
120 _getAlignMatrix = function _getAlignMatrix(fromElement, toElement, fromOrigin, toOrigin) {
121 var parentMatrix = getGlobalMatrix(fromElement.parentNode, true, true),
122 m = parentMatrix.clone().multiply(getGlobalMatrix(toElement)),

Callers 1

_getAlignMatrixFunction · 0.70

Calls 2

getGlobalMatrixFunction · 0.90
applyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…