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

Function MotionPathHelper

esm/MotionPathHelper.js:157–359  ·  view source on GitHub ↗
(targetOrTween, vars)

Source from the content-addressed store, hash-verified

155
156export var MotionPathHelper = /*#__PURE__*/function () {
157 function MotionPathHelper(targetOrTween, vars) {
158 var _this = this;
159
160 if (vars === void 0) {
161 vars = {};
162 }
163
164 if (!MotionPathPlugin) {
165 _initCore(vars.gsap, 1);
166 }
167
168 var copyButton = _createElement("div"),
169 self = this,
170 offset = {
171 x: 0,
172 y: 0
173 },
174 target,
175 path,
176 isSVG,
177 startX,
178 startY,
179 position,
180 svg,
181 animation,
182 svgNamespace,
183 temp,
184 matrix,
185 refreshPath,
186 animationToScrub,
187 createdSVG;
188
189 if (targetOrTween instanceof gsap.core.Tween) {
190 animation = targetOrTween;
191 target = animation.targets()[0];
192 } else {
193 target = gsap.utils.toArray(targetOrTween)[0];
194 animation = _findMotionPathTween(target);
195 }
196
197 path = _parsePath(vars.path, target, vars);
198 this.offset = offset;
199 position = _getPositionOnPage(target);
200 startX = parseFloat(gsap.getProperty(target, "x", "px"));
201 startY = parseFloat(gsap.getProperty(target, "y", "px"));
202 isSVG = target.getCTM && target.tagName.toLowerCase() !== "svg";
203
204 if (animation && !path) {
205 path = _parsePath(animation.vars.motionPath.path || animation.vars.motionPath, target, animation.vars.motionPath);
206 }
207
208 copyButton.setAttribute("class", "copy-motion-path");
209 copyButton.style.cssText = "border-radius:8px; background-color:rgba(85, 85, 85, 0.7); color:#fff; cursor:pointer; padding:6px 12px; font-family:Signika Negative, Arial, sans-serif; position:fixed; left:50%; transform:translate(-50%, 0); font-size:19px; bottom:10px";
210 copyButton.innerText = "COPY MOTION PATH";
211 copyButton._gsHelper = self;
212
213 (gsap.utils.toArray(vars.container)[0] || _body).appendChild(copyButton);
214

Callers

nothing calls this directly

Calls 15

targetsMethod · 0.80
getPropertyMethod · 0.80
pauseMethod · 0.80
restartMethod · 0.80
delayMethod · 0.80
repeatDelayMethod · 0.80
repeatMethod · 0.80
_initCoreFunction · 0.70
_createElementFunction · 0.70
_findMotionPathTweenFunction · 0.70
_parsePathFunction · 0.70
_getPositionOnPageFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…