/*! * VERSION: 0.3.1 * DATE: 2018-08-27 * UPDATES AND DOCS AT: http://greensock.com * * @license Copyright (c) 2008-2019, GreenSock. All rights reserved. * This work is subject to the terms at http://greensock.com/standard-license or for * Club GreenSock members, the software agreement that was issued with your membership. * * @author: Jack Doyle, jack@greensock.com **/ /* eslint-disable */ import { _gsScope } from "./TweenLite.js"; export var DirectionalRotationPlugin = _gsScope._gsDefine.plugin({ propName: "directionalRotation", version: "0.3.1", API: 2, //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run. init: function(target, value, tween, index) { if (typeof(value) !== "object") { value = {rotation:value}; } this.finals = {}; var cap = (value.useRadians === true) ? Math.PI * 2 : 360, min = 0.000001, p, v, start, end, dif, split; for (p in value) { if (p !== "useRadians") { end = value[p]; if (typeof(end) === "function") { end = end(index, target); } split = (end + "").split("_"); v = split[0]; start = parseFloat( (typeof(target[p]) !== "function") ? target[p] : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() ); end = this.finals[p] = (typeof(v) === "string" && v.charAt(1) === "=") ? start + parseInt(v.charAt(0) + "1", 10) * Number(v.substr(2)) : Number(v) || 0; dif = end - start; if (split.length) { v = split.join("_"); if (v.indexOf("short") !== -1) { dif = dif % cap; if (dif !== dif % (cap / 2)) { dif = (dif < 0) ? dif + cap : dif - cap; } } if (v.indexOf("_cw") !== -1 && dif < 0) { dif = ((dif + cap * 9999999999) % cap) - ((dif / cap) | 0) * cap; } else if (v.indexOf("ccw") !== -1 && dif > 0) { dif = ((dif - cap * 9999999999) % cap) - ((dif / cap) | 0) * cap; } } if (dif > min || dif < -min) { this._addTween(target, p, start, start + dif, p); this._overwriteProps.push(p); } } } return true; }, //called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.) set: function(ratio) { var pt; if (ratio !== 1) { this._super.setRatio.call(this, ratio); } else { pt = this._firstPT; while (pt) { if (pt.f) { pt.t[pt.p](this.finals[pt.p]); } else { pt.t[pt.p] = this.finals[pt.p]; } pt = pt._next; } } } }); DirectionalRotationPlugin._autoCSS = true; export { DirectionalRotationPlugin as default };