Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.8 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * VERSION: 0.3.1
  3. * DATE: 2018-08-27
  4. * UPDATES AND DOCS AT: http://greensock.com
  5. *
  6. * @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
  7. * This work is subject to the terms at http://greensock.com/standard-license or for
  8. * Club GreenSock members, the software agreement that was issued with your membership.
  9. *
  10. * @author: Jack Doyle, jack@greensock.com
  11. **/
  12. /* eslint-disable */
  13. import { _gsScope } from "./TweenLite.js";
  14. export var DirectionalRotationPlugin = _gsScope._gsDefine.plugin({
  15. propName: "directionalRotation",
  16. version: "0.3.1",
  17. API: 2,
  18. //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
  19. init: function(target, value, tween, index) {
  20. if (typeof(value) !== "object") {
  21. value = {rotation:value};
  22. }
  23. this.finals = {};
  24. var cap = (value.useRadians === true) ? Math.PI * 2 : 360,
  25. min = 0.000001,
  26. p, v, start, end, dif, split;
  27. for (p in value) {
  28. if (p !== "useRadians") {
  29. end = value[p];
  30. if (typeof(end) === "function") {
  31. end = end(index, target);
  32. }
  33. split = (end + "").split("_");
  34. v = split[0];
  35. start = parseFloat( (typeof(target[p]) !== "function") ? target[p] : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() );
  36. end = this.finals[p] = (typeof(v) === "string" && v.charAt(1) === "=") ? start + parseInt(v.charAt(0) + "1", 10) * Number(v.substr(2)) : Number(v) || 0;
  37. dif = end - start;
  38. if (split.length) {
  39. v = split.join("_");
  40. if (v.indexOf("short") !== -1) {
  41. dif = dif % cap;
  42. if (dif !== dif % (cap / 2)) {
  43. dif = (dif < 0) ? dif + cap : dif - cap;
  44. }
  45. }
  46. if (v.indexOf("_cw") !== -1 && dif < 0) {
  47. dif = ((dif + cap * 9999999999) % cap) - ((dif / cap) | 0) * cap;
  48. } else if (v.indexOf("ccw") !== -1 && dif > 0) {
  49. dif = ((dif - cap * 9999999999) % cap) - ((dif / cap) | 0) * cap;
  50. }
  51. }
  52. if (dif > min || dif < -min) {
  53. this._addTween(target, p, start, start + dif, p);
  54. this._overwriteProps.push(p);
  55. }
  56. }
  57. }
  58. return true;
  59. },
  60. //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.)
  61. set: function(ratio) {
  62. var pt;
  63. if (ratio !== 1) {
  64. this._super.setRatio.call(this, ratio);
  65. } else {
  66. pt = this._firstPT;
  67. while (pt) {
  68. if (pt.f) {
  69. pt.t[pt.p](this.finals[pt.p]);
  70. } else {
  71. pt.t[pt.p] = this.finals[pt.p];
  72. }
  73. pt = pt._next;
  74. }
  75. }
  76. }
  77. });
  78. DirectionalRotationPlugin._autoCSS = true;
  79. export { DirectionalRotationPlugin as default };