智慧水务管理系统 - 精河县供水工程综合管理平台

Animation.js 39KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243
  1. import {
  2. Color,
  3. defined,
  4. destroyObject,
  5. DeveloperError,
  6. getElement,
  7. } from "@cesium/engine";
  8. import subscribeAndEvaluate from "../subscribeAndEvaluate.js";
  9. const svgNS = "http://www.w3.org/2000/svg";
  10. const xlinkNS = "http://www.w3.org/1999/xlink";
  11. let widgetForDrag;
  12. const gradientEnabledColor0 = Color.fromCssColorString(
  13. "rgba(247,250,255,0.384)",
  14. );
  15. const gradientEnabledColor1 = Color.fromCssColorString(
  16. "rgba(143,191,255,0.216)",
  17. );
  18. const gradientEnabledColor2 = Color.fromCssColorString(
  19. "rgba(153,197,255,0.098)",
  20. );
  21. const gradientEnabledColor3 = Color.fromCssColorString(
  22. "rgba(255,255,255,0.086)",
  23. );
  24. const gradientDisabledColor0 = Color.fromCssColorString(
  25. "rgba(255,255,255,0.267)",
  26. );
  27. const gradientDisabledColor1 = Color.fromCssColorString("rgba(255,255,255,0)");
  28. const gradientKnobColor = Color.fromCssColorString("rgba(66,67,68,0.3)");
  29. const gradientPointerColor = Color.fromCssColorString("rgba(0,0,0,0.5)");
  30. function getElementColor(element) {
  31. return Color.fromCssColorString(
  32. window.getComputedStyle(element).getPropertyValue("color"),
  33. );
  34. }
  35. const svgIconsById = {
  36. animation_pathReset: {
  37. tagName: "path",
  38. transform: "translate(16,16) scale(0.85) translate(-16,-16)",
  39. d: "M24.316,5.318,9.833,13.682,9.833,5.5,5.5,5.5,5.5,25.5,9.833,25.5,9.833,17.318,24.316,25.682z",
  40. },
  41. animation_pathPause: {
  42. tagName: "path",
  43. transform: "translate(16,16) scale(0.85) translate(-16,-16)",
  44. d: "M13,5.5,7.5,5.5,7.5,25.5,13,25.5zM24.5,5.5,19,5.5,19,25.5,24.5,25.5z",
  45. },
  46. animation_pathPlay: {
  47. tagName: "path",
  48. transform: "translate(16,16) scale(0.85) translate(-16,-16)",
  49. d: "M6.684,25.682L24.316,15.5L6.684,5.318V25.682z",
  50. },
  51. animation_pathPlayReverse: {
  52. tagName: "path",
  53. transform: "translate(16,16) scale(-0.85,0.85) translate(-16,-16)",
  54. d: "M6.684,25.682L24.316,15.5L6.684,5.318V25.682z",
  55. },
  56. animation_pathLoop: {
  57. tagName: "path",
  58. transform: "translate(16,16) scale(0.85) translate(-16,-16)",
  59. d: "M24.249,15.499c-0.009,4.832-3.918,8.741-8.75,8.75c-2.515,0-4.768-1.064-6.365-2.763l2.068-1.442l-7.901-3.703l0.744,8.694l2.193-1.529c2.244,2.594,5.562,4.242,9.26,4.242c6.767,0,12.249-5.482,12.249-12.249H24.249zM15.499,6.75c2.516,0,4.769,1.065,6.367,2.764l-2.068,1.443l7.901,3.701l-0.746-8.693l-2.192,1.529c-2.245-2.594-5.562-4.245-9.262-4.245C8.734,3.25,3.25,8.734,3.249,15.499H6.75C6.758,10.668,10.668,6.758,15.499,6.75z",
  60. },
  61. animation_pathClock: {
  62. tagName: "path",
  63. transform: "translate(16,16) scale(0.85) translate(-16,-15.5)",
  64. d: "M15.5,2.374C8.251,2.375,2.376,8.251,2.374,15.5C2.376,22.748,8.251,28.623,15.5,28.627c7.249-0.004,13.124-5.879,13.125-13.127C28.624,8.251,22.749,2.375,15.5,2.374zM15.5,25.623C9.909,25.615,5.385,21.09,5.375,15.5C5.385,9.909,9.909,5.384,15.5,5.374c5.59,0.01,10.115,4.535,10.124,10.125C25.615,21.09,21.091,25.615,15.5,25.623zM8.625,15.5c-0.001-0.552-0.448-0.999-1.001-1c-0.553,0-1,0.448-1,1c0,0.553,0.449,1,1,1C8.176,16.5,8.624,16.053,8.625,15.5zM8.179,18.572c-0.478,0.277-0.642,0.889-0.365,1.367c0.275,0.479,0.889,0.641,1.365,0.365c0.479-0.275,0.643-0.887,0.367-1.367C9.27,18.461,8.658,18.297,8.179,18.572zM9.18,10.696c-0.479-0.276-1.09-0.112-1.366,0.366s-0.111,1.09,0.365,1.366c0.479,0.276,1.09,0.113,1.367-0.366C9.821,11.584,9.657,10.973,9.18,10.696zM22.822,12.428c0.478-0.275,0.643-0.888,0.366-1.366c-0.275-0.478-0.89-0.642-1.366-0.366c-0.479,0.278-0.642,0.89-0.366,1.367C21.732,12.54,22.344,12.705,22.822,12.428zM12.062,21.455c-0.478-0.275-1.089-0.111-1.366,0.367c-0.275,0.479-0.111,1.09,0.366,1.365c0.478,0.277,1.091,0.111,1.365-0.365C12.704,22.344,12.54,21.732,12.062,21.455zM12.062,9.545c0.479-0.276,0.642-0.888,0.366-1.366c-0.276-0.478-0.888-0.642-1.366-0.366s-0.642,0.888-0.366,1.366C10.973,9.658,11.584,9.822,12.062,9.545zM22.823,18.572c-0.48-0.275-1.092-0.111-1.367,0.365c-0.275,0.479-0.112,1.092,0.367,1.367c0.477,0.275,1.089,0.113,1.365-0.365C23.464,19.461,23.3,18.848,22.823,18.572zM19.938,7.813c-0.477-0.276-1.091-0.111-1.365,0.366c-0.275,0.48-0.111,1.091,0.366,1.367s1.089,0.112,1.366-0.366C20.581,8.702,20.418,8.089,19.938,7.813zM23.378,14.5c-0.554,0.002-1.001,0.45-1.001,1c0.001,0.552,0.448,1,1.001,1c0.551,0,1-0.447,1-1C24.378,14.949,23.929,14.5,23.378,14.5zM15.501,6.624c-0.552,0-1,0.448-1,1l-0.466,7.343l-3.004,1.96c-0.478,0.277-0.642,0.889-0.365,1.365c0.275,0.479,0.889,0.643,1.365,0.367l3.305-1.676C15.39,16.99,15.444,17,15.501,17c0.828,0,1.5-0.671,1.5-1.5l-0.5-7.876C16.501,7.072,16.053,6.624,15.501,6.624zM15.501,22.377c-0.552,0-1,0.447-1,1s0.448,1,1,1s1-0.447,1-1S16.053,22.377,15.501,22.377zM18.939,21.455c-0.479,0.277-0.643,0.889-0.366,1.367c0.275,0.477,0.888,0.643,1.366,0.365c0.478-0.275,0.642-0.889,0.366-1.365C20.028,21.344,19.417,21.18,18.939,21.455z",
  65. },
  66. animation_pathWingButton: {
  67. tagName: "path",
  68. d: "m 4.5,0.5 c -2.216,0 -4,1.784 -4,4 l 0,24 c 0,2.216 1.784,4 4,4 l 13.71875,0 C 22.478584,27.272785 27.273681,22.511272 32.5,18.25 l 0,-13.75 c 0,-2.216 -1.784,-4 -4,-4 l -24,0 z",
  69. },
  70. animation_pathPointer: {
  71. tagName: "path",
  72. d: "M-15,-65,-15,-55,15,-55,15,-65,0,-95z",
  73. },
  74. animation_pathSwooshFX: {
  75. tagName: "path",
  76. d: "m 85,0 c 0,16.617 -4.813944,35.356 -13.131081,48.4508 h 6.099803 c 8.317138,-13.0948 13.13322,-28.5955 13.13322,-45.2124 0,-46.94483 -38.402714,-85.00262 -85.7743869,-85.00262 -1.0218522,0 -2.0373001,0.0241 -3.0506131,0.0589 45.958443,1.59437 82.723058,35.77285 82.723058,81.70532 z",
  77. },
  78. };
  79. //Dynamically builds an SVG element from a JSON object.
  80. function svgFromObject(obj) {
  81. const ele = document.createElementNS(svgNS, obj.tagName);
  82. for (const field in obj) {
  83. if (obj.hasOwnProperty(field) && field !== "tagName") {
  84. if (field === "children") {
  85. const len = obj.children.length;
  86. for (let i = 0; i < len; ++i) {
  87. ele.appendChild(svgFromObject(obj.children[i]));
  88. }
  89. } else if (field.indexOf("xlink:") === 0) {
  90. ele.setAttributeNS(xlinkNS, field.substring(6), obj[field]);
  91. } else if (field === "textContent") {
  92. ele.textContent = obj[field];
  93. } else {
  94. ele.setAttribute(field, obj[field]);
  95. }
  96. }
  97. }
  98. return ele;
  99. }
  100. function svgText(x, y, msg) {
  101. const text = document.createElementNS(svgNS, "text");
  102. text.setAttribute("x", x);
  103. text.setAttribute("y", y);
  104. text.setAttribute("class", "cesium-animation-svgText");
  105. const tspan = document.createElementNS(svgNS, "tspan");
  106. tspan.textContent = msg;
  107. text.appendChild(tspan);
  108. return text;
  109. }
  110. function setShuttleRingPointer(shuttleRingPointer, knobOuter, angle) {
  111. shuttleRingPointer.setAttribute(
  112. "transform",
  113. `translate(100,100) rotate(${angle})`,
  114. );
  115. knobOuter.setAttribute("transform", `rotate(${angle})`);
  116. }
  117. const makeColorStringScratch = new Color();
  118. function makeColorString(background, gradient) {
  119. const gradientAlpha = gradient.alpha;
  120. const backgroundAlpha = 1.0 - gradientAlpha;
  121. makeColorStringScratch.red =
  122. background.red * backgroundAlpha + gradient.red * gradientAlpha;
  123. makeColorStringScratch.green =
  124. background.green * backgroundAlpha + gradient.green * gradientAlpha;
  125. makeColorStringScratch.blue =
  126. background.blue * backgroundAlpha + gradient.blue * gradientAlpha;
  127. return makeColorStringScratch.toCssColorString();
  128. }
  129. function rectButton(x, y, path) {
  130. const iconInfo = svgIconsById[path];
  131. const button = {
  132. tagName: "g",
  133. class: "cesium-animation-rectButton",
  134. transform: `translate(${x},${y})`,
  135. children: [
  136. {
  137. tagName: "rect",
  138. class: "cesium-animation-buttonGlow",
  139. width: 32,
  140. height: 32,
  141. rx: 2,
  142. ry: 2,
  143. },
  144. {
  145. tagName: "rect",
  146. class: "cesium-animation-buttonMain",
  147. width: 32,
  148. height: 32,
  149. rx: 4,
  150. ry: 4,
  151. },
  152. {
  153. class: "cesium-animation-buttonPath",
  154. id: path,
  155. tagName: iconInfo.tagName,
  156. transform: iconInfo.transform,
  157. d: iconInfo.d,
  158. },
  159. {
  160. tagName: "title",
  161. textContent: "",
  162. },
  163. ],
  164. };
  165. return svgFromObject(button);
  166. }
  167. function wingButton(x, y, path) {
  168. const buttonIconInfo = svgIconsById[path];
  169. const wingIconInfo = svgIconsById["animation_pathWingButton"];
  170. const button = {
  171. tagName: "g",
  172. class: "cesium-animation-rectButton",
  173. transform: `translate(${x},${y})`,
  174. children: [
  175. {
  176. class: "cesium-animation-buttonGlow",
  177. id: "animation_pathWingButton",
  178. tagName: wingIconInfo.tagName,
  179. d: wingIconInfo.d,
  180. },
  181. {
  182. class: "cesium-animation-buttonMain",
  183. id: "animation_pathWingButton",
  184. tagName: wingIconInfo.tagName,
  185. d: wingIconInfo.d,
  186. },
  187. {
  188. class: "cesium-animation-buttonPath",
  189. id: path,
  190. tagName: buttonIconInfo.tagName,
  191. transform: buttonIconInfo.transform,
  192. d: buttonIconInfo.d,
  193. },
  194. {
  195. tagName: "title",
  196. textContent: "",
  197. },
  198. ],
  199. };
  200. return svgFromObject(button);
  201. }
  202. function setShuttleRingFromMouseOrTouch(widget, e) {
  203. const viewModel = widget._viewModel;
  204. const shuttleRingDragging = viewModel.shuttleRingDragging;
  205. if (shuttleRingDragging && widgetForDrag !== widget) {
  206. return;
  207. }
  208. if (
  209. e.type === "mousedown" ||
  210. (shuttleRingDragging && e.type === "mousemove") ||
  211. (e.type === "touchstart" && e.touches.length === 1) ||
  212. (shuttleRingDragging && e.type === "touchmove" && e.touches.length === 1)
  213. ) {
  214. const centerX = widget._centerX;
  215. const centerY = widget._centerY;
  216. const svg = widget._svgNode;
  217. const rect = svg.getBoundingClientRect();
  218. let clientX;
  219. let clientY;
  220. if (e.type === "touchstart" || e.type === "touchmove") {
  221. clientX = e.touches[0].clientX;
  222. clientY = e.touches[0].clientY;
  223. } else {
  224. clientX = e.clientX;
  225. clientY = e.clientY;
  226. }
  227. if (
  228. !shuttleRingDragging &&
  229. (clientX > rect.right ||
  230. clientX < rect.left ||
  231. clientY < rect.top ||
  232. clientY > rect.bottom)
  233. ) {
  234. return;
  235. }
  236. const pointerRect = widget._shuttleRingPointer.getBoundingClientRect();
  237. const x = clientX - centerX - rect.left;
  238. const y = clientY - centerY - rect.top;
  239. let angle = (Math.atan2(y, x) * 180) / Math.PI + 90;
  240. if (angle > 180) {
  241. angle -= 360;
  242. }
  243. const shuttleRingAngle = viewModel.shuttleRingAngle;
  244. if (
  245. shuttleRingDragging ||
  246. (clientX < pointerRect.right &&
  247. clientX > pointerRect.left &&
  248. clientY > pointerRect.top &&
  249. clientY < pointerRect.bottom)
  250. ) {
  251. widgetForDrag = widget;
  252. viewModel.shuttleRingDragging = true;
  253. viewModel.shuttleRingAngle = angle;
  254. } else if (angle < shuttleRingAngle) {
  255. viewModel.slower();
  256. } else if (angle > shuttleRingAngle) {
  257. viewModel.faster();
  258. }
  259. e.preventDefault();
  260. } else {
  261. if (widget === widgetForDrag) {
  262. widgetForDrag = undefined;
  263. }
  264. viewModel.shuttleRingDragging = false;
  265. }
  266. }
  267. //This is a private class for treating an SVG element like a button.
  268. //If we ever need a general purpose SVG button, we can make this generic.
  269. function SvgButton(svgElement, viewModel) {
  270. this._viewModel = viewModel;
  271. this.svgElement = svgElement;
  272. this._enabled = undefined;
  273. this._toggled = undefined;
  274. const that = this;
  275. this._clickFunction = function () {
  276. const command = that._viewModel.command;
  277. if (command.canExecute) {
  278. command();
  279. }
  280. };
  281. svgElement.addEventListener("click", this._clickFunction, true);
  282. //TODO: Since the animation widget uses SVG and has no HTML backing,
  283. //we need to wire everything up manually. Knockout can supposedly
  284. //bind to SVG, so we we figure that out we can modify our SVG
  285. //to include the binding information directly.
  286. this._subscriptions = [
  287. //
  288. subscribeAndEvaluate(viewModel, "toggled", this.setToggled, this), //
  289. subscribeAndEvaluate(viewModel, "tooltip", this.setTooltip, this), //
  290. subscribeAndEvaluate(
  291. viewModel.command,
  292. "canExecute",
  293. this.setEnabled,
  294. this,
  295. ),
  296. ];
  297. }
  298. SvgButton.prototype.destroy = function () {
  299. this.svgElement.removeEventListener("click", this._clickFunction, true);
  300. const subscriptions = this._subscriptions;
  301. for (let i = 0, len = subscriptions.length; i < len; i++) {
  302. subscriptions[i].dispose();
  303. }
  304. destroyObject(this);
  305. };
  306. SvgButton.prototype.isDestroyed = function () {
  307. return false;
  308. };
  309. SvgButton.prototype.setEnabled = function (enabled) {
  310. if (this._enabled !== enabled) {
  311. this._enabled = enabled;
  312. if (!enabled) {
  313. this.svgElement.setAttribute("class", "cesium-animation-buttonDisabled");
  314. return;
  315. }
  316. if (this._toggled) {
  317. this.svgElement.setAttribute(
  318. "class",
  319. "cesium-animation-rectButton cesium-animation-buttonToggled",
  320. );
  321. return;
  322. }
  323. this.svgElement.setAttribute("class", "cesium-animation-rectButton");
  324. }
  325. };
  326. SvgButton.prototype.setToggled = function (toggled) {
  327. if (this._toggled !== toggled) {
  328. this._toggled = toggled;
  329. if (this._enabled) {
  330. if (toggled) {
  331. this.svgElement.setAttribute(
  332. "class",
  333. "cesium-animation-rectButton cesium-animation-buttonToggled",
  334. );
  335. } else {
  336. this.svgElement.setAttribute("class", "cesium-animation-rectButton");
  337. }
  338. }
  339. }
  340. };
  341. SvgButton.prototype.setTooltip = function (tooltip) {
  342. this.svgElement.getElementsByTagName("title")[0].textContent = tooltip;
  343. };
  344. /**
  345. * <span style="display: block; text-align: center;">
  346. * <img src="Images/AnimationWidget.png" width="211" height="142" alt="" />
  347. * <br />Animation widget
  348. * </span>
  349. * <br /><br />
  350. * The Animation widget provides buttons for play, pause, and reverse, along with the
  351. * current time and date, surrounded by a "shuttle ring" for controlling the speed of animation.
  352. * <br /><br />
  353. * The "shuttle ring" concept is borrowed from video editing, where typically a
  354. * "jog wheel" can be rotated to move past individual animation frames very slowly, and
  355. * a surrounding shuttle ring can be twisted to control direction and speed of fast playback.
  356. * Cesium typically treats time as continuous (not broken into pre-defined animation frames),
  357. * so this widget offers no jog wheel. Instead, the shuttle ring is capable of both fast and
  358. * very slow playback. Click and drag the shuttle ring pointer itself (shown above in green),
  359. * or click in the rest of the ring area to nudge the pointer to the next preset speed in that direction.
  360. * <br /><br />
  361. * The Animation widget also provides a "realtime" button (in the upper-left) that keeps
  362. * animation time in sync with the end user's system clock, typically displaying
  363. * "today" or "right now." This mode is not available in {@link ClockRange.CLAMPED} or
  364. * {@link ClockRange.LOOP_STOP} mode if the current time is outside of {@link Clock}'s startTime and endTime.
  365. *
  366. * @alias Animation
  367. * @constructor
  368. *
  369. * @param {Element|string} container The DOM element or ID that will contain the widget.
  370. * @param {AnimationViewModel} viewModel The view model used by this widget.
  371. *
  372. * @exception {DeveloperError} Element with id "container" does not exist in the document.
  373. *
  374. *
  375. * @example
  376. * // In HTML head, include a link to Animation.css stylesheet,
  377. * // and in the body, include: <div id="animationContainer"></div>
  378. *
  379. * const clock = new Cesium.Clock();
  380. * const clockViewModel = new Cesium.ClockViewModel(clock);
  381. * const viewModel = new Cesium.AnimationViewModel(clockViewModel);
  382. * const widget = new Cesium.Animation('animationContainer', viewModel);
  383. *
  384. * function tick() {
  385. * clock.tick();
  386. * requestAnimationFrame(tick);
  387. * }
  388. * requestAnimationFrame(tick);
  389. *
  390. * @see AnimationViewModel
  391. * @see Clock
  392. */
  393. function Animation(container, viewModel) {
  394. //>>includeStart('debug', pragmas.debug);
  395. if (!defined(container)) {
  396. throw new DeveloperError("container is required.");
  397. }
  398. if (!defined(viewModel)) {
  399. throw new DeveloperError("viewModel is required.");
  400. }
  401. //>>includeEnd('debug');
  402. container = getElement(container);
  403. this._viewModel = viewModel;
  404. this._container = container;
  405. this._centerX = 0;
  406. this._centerY = 0;
  407. this._defsElement = undefined;
  408. this._svgNode = undefined;
  409. this._topG = undefined;
  410. this._lastHeight = undefined;
  411. this._lastWidth = undefined;
  412. const ownerDocument = container.ownerDocument;
  413. // Firefox requires SVG references to be included directly, not imported from external CSS.
  414. // Also, CSS minifiers get confused by this being in an external CSS file.
  415. const cssStyle = document.createElement("style");
  416. cssStyle.textContent =
  417. ".cesium-animation-rectButton .cesium-animation-buttonGlow { filter: url(#animation_blurred); }\
  418. .cesium-animation-rectButton .cesium-animation-buttonMain { fill: url(#animation_buttonNormal); }\
  419. .cesium-animation-buttonToggled .cesium-animation-buttonMain { fill: url(#animation_buttonToggled); }\
  420. .cesium-animation-rectButton:hover .cesium-animation-buttonMain { fill: url(#animation_buttonHovered); }\
  421. .cesium-animation-buttonDisabled .cesium-animation-buttonMain { fill: url(#animation_buttonDisabled); }\
  422. .cesium-animation-shuttleRingG .cesium-animation-shuttleRingSwoosh { fill: url(#animation_shuttleRingSwooshGradient); }\
  423. .cesium-animation-shuttleRingG:hover .cesium-animation-shuttleRingSwoosh { fill: url(#animation_shuttleRingSwooshHovered); }\
  424. .cesium-animation-shuttleRingPointer { fill: url(#animation_shuttleRingPointerGradient); }\
  425. .cesium-animation-shuttleRingPausePointer { fill: url(#animation_shuttleRingPointerPaused); }\
  426. .cesium-animation-knobOuter { fill: url(#animation_knobOuter); }\
  427. .cesium-animation-knobInner { fill: url(#animation_knobInner); }";
  428. ownerDocument.head.insertBefore(cssStyle, ownerDocument.head.childNodes[0]);
  429. const themeEle = document.createElement("div");
  430. themeEle.className = "cesium-animation-theme";
  431. themeEle.innerHTML =
  432. '<div class="cesium-animation-themeNormal"></div>\
  433. <div class="cesium-animation-themeHover"></div>\
  434. <div class="cesium-animation-themeSelect"></div>\
  435. <div class="cesium-animation-themeDisabled"></div>\
  436. <div class="cesium-animation-themeKnob"></div>\
  437. <div class="cesium-animation-themePointer"></div>\
  438. <div class="cesium-animation-themeSwoosh"></div>\
  439. <div class="cesium-animation-themeSwooshHover"></div>';
  440. this._theme = themeEle;
  441. this._themeNormal = themeEle.childNodes[0];
  442. this._themeHover = themeEle.childNodes[1];
  443. this._themeSelect = themeEle.childNodes[2];
  444. this._themeDisabled = themeEle.childNodes[3];
  445. this._themeKnob = themeEle.childNodes[4];
  446. this._themePointer = themeEle.childNodes[5];
  447. this._themeSwoosh = themeEle.childNodes[6];
  448. this._themeSwooshHover = themeEle.childNodes[7];
  449. const svg = document.createElementNS(svgNS, "svg:svg");
  450. this._svgNode = svg;
  451. // Define the XLink namespace that SVG uses
  452. svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", xlinkNS);
  453. const topG = document.createElementNS(svgNS, "g");
  454. this._topG = topG;
  455. this._realtimeSVG = new SvgButton(
  456. wingButton(3, 4, "animation_pathClock"),
  457. viewModel.playRealtimeViewModel,
  458. );
  459. this._playReverseSVG = new SvgButton(
  460. rectButton(44, 99, "animation_pathPlayReverse"),
  461. viewModel.playReverseViewModel,
  462. );
  463. this._playForwardSVG = new SvgButton(
  464. rectButton(124, 99, "animation_pathPlay"),
  465. viewModel.playForwardViewModel,
  466. );
  467. this._pauseSVG = new SvgButton(
  468. rectButton(84, 99, "animation_pathPause"),
  469. viewModel.pauseViewModel,
  470. );
  471. const buttonsG = document.createElementNS(svgNS, "g");
  472. buttonsG.appendChild(this._realtimeSVG.svgElement);
  473. buttonsG.appendChild(this._playReverseSVG.svgElement);
  474. buttonsG.appendChild(this._playForwardSVG.svgElement);
  475. buttonsG.appendChild(this._pauseSVG.svgElement);
  476. const shuttleRingBackPanel = svgFromObject({
  477. tagName: "circle",
  478. class: "cesium-animation-shuttleRingBack",
  479. cx: 100,
  480. cy: 100,
  481. r: 99,
  482. });
  483. this._shuttleRingBackPanel = shuttleRingBackPanel;
  484. const swooshIconInfo = svgIconsById["animation_pathSwooshFX"];
  485. const shuttleRingPointerIconInfo = svgIconsById["animation_pathPointer"];
  486. const shuttleRingSwooshG = svgFromObject({
  487. tagName: "g",
  488. class: "cesium-animation-shuttleRingSwoosh",
  489. children: [
  490. {
  491. tagName: swooshIconInfo.tagName,
  492. transform: "translate(100,97) scale(-1,1)",
  493. id: "animation_pathSwooshFX",
  494. d: swooshIconInfo.d,
  495. },
  496. {
  497. tagName: swooshIconInfo.tagName,
  498. transform: "translate(100,97)",
  499. id: "animation_pathSwooshFX",
  500. d: swooshIconInfo.d,
  501. },
  502. {
  503. tagName: "line",
  504. x1: 100,
  505. y1: 8,
  506. x2: 100,
  507. y2: 22,
  508. },
  509. ],
  510. });
  511. this._shuttleRingSwooshG = shuttleRingSwooshG;
  512. this._shuttleRingPointer = svgFromObject({
  513. class: "cesium-animation-shuttleRingPointer",
  514. id: "animation_pathPointer",
  515. tagName: shuttleRingPointerIconInfo.tagName,
  516. d: shuttleRingPointerIconInfo.d,
  517. });
  518. const knobG = svgFromObject({
  519. tagName: "g",
  520. transform: "translate(100,100)",
  521. });
  522. this._knobOuter = svgFromObject({
  523. tagName: "circle",
  524. class: "cesium-animation-knobOuter",
  525. cx: 0,
  526. cy: 0,
  527. r: 71,
  528. });
  529. const knobInnerAndShieldSize = 61;
  530. const knobInner = svgFromObject({
  531. tagName: "circle",
  532. class: "cesium-animation-knobInner",
  533. cx: 0,
  534. cy: 0,
  535. r: knobInnerAndShieldSize,
  536. });
  537. this._knobDate = svgText(0, -24, "");
  538. this._knobTime = svgText(0, -7, "");
  539. this._knobStatus = svgText(0, -41, "");
  540. // widget shield catches clicks on the knob itself (even while DOM elements underneath are changing).
  541. const knobShield = svgFromObject({
  542. tagName: "circle",
  543. class: "cesium-animation-blank",
  544. cx: 0,
  545. cy: 0,
  546. r: knobInnerAndShieldSize,
  547. });
  548. const shuttleRingBackG = document.createElementNS(svgNS, "g");
  549. shuttleRingBackG.setAttribute("class", "cesium-animation-shuttleRingG");
  550. container.appendChild(themeEle);
  551. topG.appendChild(shuttleRingBackG);
  552. topG.appendChild(knobG);
  553. topG.appendChild(buttonsG);
  554. shuttleRingBackG.appendChild(shuttleRingBackPanel);
  555. shuttleRingBackG.appendChild(shuttleRingSwooshG);
  556. shuttleRingBackG.appendChild(this._shuttleRingPointer);
  557. knobG.appendChild(this._knobOuter);
  558. knobG.appendChild(knobInner);
  559. knobG.appendChild(this._knobDate);
  560. knobG.appendChild(this._knobTime);
  561. knobG.appendChild(this._knobStatus);
  562. knobG.appendChild(knobShield);
  563. svg.appendChild(topG);
  564. container.appendChild(svg);
  565. const that = this;
  566. function mouseCallback(e) {
  567. setShuttleRingFromMouseOrTouch(that, e);
  568. }
  569. this._mouseCallback = mouseCallback;
  570. shuttleRingBackPanel.addEventListener("mousedown", mouseCallback, true);
  571. shuttleRingBackPanel.addEventListener("touchstart", mouseCallback, true);
  572. shuttleRingSwooshG.addEventListener("mousedown", mouseCallback, true);
  573. shuttleRingSwooshG.addEventListener("touchstart", mouseCallback, true);
  574. ownerDocument.addEventListener("mousemove", mouseCallback, true);
  575. ownerDocument.addEventListener("touchmove", mouseCallback, true);
  576. ownerDocument.addEventListener("mouseup", mouseCallback, true);
  577. ownerDocument.addEventListener("touchend", mouseCallback, true);
  578. ownerDocument.addEventListener("touchcancel", mouseCallback, true);
  579. this._shuttleRingPointer.addEventListener("mousedown", mouseCallback, true);
  580. this._shuttleRingPointer.addEventListener("touchstart", mouseCallback, true);
  581. this._knobOuter.addEventListener("mousedown", mouseCallback, true);
  582. this._knobOuter.addEventListener("touchstart", mouseCallback, true);
  583. //TODO: Since the animation widget uses SVG and has no HTML backing,
  584. //we need to wire everything up manually. Knockout can supposedly
  585. //bind to SVG, so we we figure that out we can modify our SVG
  586. //to include the binding information directly.
  587. const timeNode = this._knobTime.childNodes[0];
  588. const dateNode = this._knobDate.childNodes[0];
  589. const statusNode = this._knobStatus.childNodes[0];
  590. let isPaused;
  591. this._subscriptions = [
  592. //
  593. subscribeAndEvaluate(viewModel.pauseViewModel, "toggled", function (value) {
  594. if (isPaused !== value) {
  595. isPaused = value;
  596. if (isPaused) {
  597. that._shuttleRingPointer.setAttribute(
  598. "class",
  599. "cesium-animation-shuttleRingPausePointer",
  600. );
  601. } else {
  602. that._shuttleRingPointer.setAttribute(
  603. "class",
  604. "cesium-animation-shuttleRingPointer",
  605. );
  606. }
  607. }
  608. }),
  609. subscribeAndEvaluate(viewModel, "shuttleRingAngle", function (value) {
  610. setShuttleRingPointer(that._shuttleRingPointer, that._knobOuter, value);
  611. }),
  612. subscribeAndEvaluate(viewModel, "dateLabel", function (value) {
  613. if (dateNode.textContent !== value) {
  614. dateNode.textContent = value;
  615. }
  616. }),
  617. subscribeAndEvaluate(viewModel, "timeLabel", function (value) {
  618. if (timeNode.textContent !== value) {
  619. timeNode.textContent = value;
  620. }
  621. }),
  622. subscribeAndEvaluate(viewModel, "multiplierLabel", function (value) {
  623. if (statusNode.textContent !== value) {
  624. statusNode.textContent = value;
  625. }
  626. }),
  627. ];
  628. this.applyThemeChanges();
  629. this.resize();
  630. }
  631. Object.defineProperties(Animation.prototype, {
  632. /**
  633. * Gets the parent container.
  634. *
  635. * @memberof Animation.prototype
  636. * @type {Element}
  637. * @readonly
  638. */
  639. container: {
  640. get: function () {
  641. return this._container;
  642. },
  643. },
  644. /**
  645. * Gets the view model.
  646. *
  647. * @memberof Animation.prototype
  648. * @type {AnimationViewModel}
  649. * @readonly
  650. */
  651. viewModel: {
  652. get: function () {
  653. return this._viewModel;
  654. },
  655. },
  656. });
  657. /**
  658. * @returns {boolean} true if the object has been destroyed, false otherwise.
  659. */
  660. Animation.prototype.isDestroyed = function () {
  661. return false;
  662. };
  663. /**
  664. * Destroys the animation widget. Should be called if permanently
  665. * removing the widget from layout.
  666. */
  667. Animation.prototype.destroy = function () {
  668. if (defined(this._observer)) {
  669. this._observer.disconnect();
  670. this._observer = undefined;
  671. }
  672. const doc = this._container.ownerDocument;
  673. const mouseCallback = this._mouseCallback;
  674. this._shuttleRingBackPanel.removeEventListener(
  675. "mousedown",
  676. mouseCallback,
  677. true,
  678. );
  679. this._shuttleRingBackPanel.removeEventListener(
  680. "touchstart",
  681. mouseCallback,
  682. true,
  683. );
  684. this._shuttleRingSwooshG.removeEventListener(
  685. "mousedown",
  686. mouseCallback,
  687. true,
  688. );
  689. this._shuttleRingSwooshG.removeEventListener(
  690. "touchstart",
  691. mouseCallback,
  692. true,
  693. );
  694. doc.removeEventListener("mousemove", mouseCallback, true);
  695. doc.removeEventListener("touchmove", mouseCallback, true);
  696. doc.removeEventListener("mouseup", mouseCallback, true);
  697. doc.removeEventListener("touchend", mouseCallback, true);
  698. doc.removeEventListener("touchcancel", mouseCallback, true);
  699. this._shuttleRingPointer.removeEventListener(
  700. "mousedown",
  701. mouseCallback,
  702. true,
  703. );
  704. this._shuttleRingPointer.removeEventListener(
  705. "touchstart",
  706. mouseCallback,
  707. true,
  708. );
  709. this._knobOuter.removeEventListener("mousedown", mouseCallback, true);
  710. this._knobOuter.removeEventListener("touchstart", mouseCallback, true);
  711. this._container.removeChild(this._svgNode);
  712. this._container.removeChild(this._theme);
  713. this._realtimeSVG.destroy();
  714. this._playReverseSVG.destroy();
  715. this._playForwardSVG.destroy();
  716. this._pauseSVG.destroy();
  717. const subscriptions = this._subscriptions;
  718. for (let i = 0, len = subscriptions.length; i < len; i++) {
  719. subscriptions[i].dispose();
  720. }
  721. return destroyObject(this);
  722. };
  723. /**
  724. * Resizes the widget to match the container size.
  725. * This function should be called whenever the container size is changed.
  726. */
  727. Animation.prototype.resize = function () {
  728. const parentWidth = this._container.clientWidth;
  729. const parentHeight = this._container.clientHeight;
  730. if (parentWidth === this._lastWidth && parentHeight === this._lastHeight) {
  731. return;
  732. }
  733. const svg = this._svgNode;
  734. //The width and height as the SVG was originally drawn.
  735. const baseWidth = 200;
  736. const baseHeight = 132;
  737. let width = parentWidth;
  738. let height = parentHeight;
  739. if (parentWidth === 0 && parentHeight === 0) {
  740. width = baseWidth;
  741. height = baseHeight;
  742. } else if (parentWidth === 0) {
  743. height = parentHeight;
  744. width = baseWidth * (parentHeight / baseHeight);
  745. } else if (parentHeight === 0) {
  746. width = parentWidth;
  747. height = baseHeight * (parentWidth / baseWidth);
  748. }
  749. const scaleX = width / baseWidth;
  750. const scaleY = height / baseHeight;
  751. svg.style.cssText = `width: ${width}px; height: ${height}px; position: absolute; bottom: 0; left: 0; overflow: hidden;`;
  752. svg.setAttribute("width", width);
  753. svg.setAttribute("height", height);
  754. svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
  755. this._topG.setAttribute("transform", `scale(${scaleX},${scaleY})`);
  756. this._centerX = Math.max(1, 100.0 * scaleX);
  757. this._centerY = Math.max(1, 100.0 * scaleY);
  758. this._lastHeight = parentWidth;
  759. this._lastWidth = parentHeight;
  760. };
  761. /**
  762. * Updates the widget to reflect any modified CSS rules for theming.
  763. *
  764. * @example
  765. * //Switch to the cesium-lighter theme.
  766. * document.body.className = 'cesium-lighter';
  767. * animation.applyThemeChanges();
  768. */
  769. Animation.prototype.applyThemeChanges = function () {
  770. // Since we rely on computed styles for themeing, we can't actually
  771. // do anything if the container has not yet been added to the DOM.
  772. // Set up an observer to be notified when it is added and apply
  773. // the changes at that time.
  774. const doc = this._container.ownerDocument;
  775. if (!doc.body.contains(this._container)) {
  776. if (defined(this._observer)) {
  777. //Already listening.
  778. return;
  779. }
  780. const that = this;
  781. that._observer = new MutationObserver(function () {
  782. if (doc.body.contains(that._container)) {
  783. that._observer.disconnect();
  784. that._observer = undefined;
  785. that.applyThemeChanges();
  786. }
  787. });
  788. that._observer.observe(doc, { childList: true, subtree: true });
  789. return;
  790. }
  791. const buttonNormalBackColor = getElementColor(this._themeNormal);
  792. const buttonHoverBackColor = getElementColor(this._themeHover);
  793. const buttonToggledBackColor = getElementColor(this._themeSelect);
  794. const buttonDisabledBackColor = getElementColor(this._themeDisabled);
  795. const knobBackColor = getElementColor(this._themeKnob);
  796. const pointerColor = getElementColor(this._themePointer);
  797. const swooshColor = getElementColor(this._themeSwoosh);
  798. const swooshHoverColor = getElementColor(this._themeSwooshHover);
  799. const defsElement = svgFromObject({
  800. tagName: "defs",
  801. children: [
  802. {
  803. id: "animation_buttonNormal",
  804. tagName: "linearGradient",
  805. x1: "50%",
  806. y1: "0%",
  807. x2: "50%",
  808. y2: "100%",
  809. children: [
  810. //add a 'stop-opacity' field to make translucent.
  811. {
  812. tagName: "stop",
  813. offset: "0%",
  814. "stop-color": makeColorString(
  815. buttonNormalBackColor,
  816. gradientEnabledColor0,
  817. ),
  818. },
  819. {
  820. tagName: "stop",
  821. offset: "12%",
  822. "stop-color": makeColorString(
  823. buttonNormalBackColor,
  824. gradientEnabledColor1,
  825. ),
  826. },
  827. {
  828. tagName: "stop",
  829. offset: "46%",
  830. "stop-color": makeColorString(
  831. buttonNormalBackColor,
  832. gradientEnabledColor2,
  833. ),
  834. },
  835. {
  836. tagName: "stop",
  837. offset: "81%",
  838. "stop-color": makeColorString(
  839. buttonNormalBackColor,
  840. gradientEnabledColor3,
  841. ),
  842. },
  843. ],
  844. },
  845. {
  846. id: "animation_buttonHovered",
  847. tagName: "linearGradient",
  848. x1: "50%",
  849. y1: "0%",
  850. x2: "50%",
  851. y2: "100%",
  852. children: [
  853. {
  854. tagName: "stop",
  855. offset: "0%",
  856. "stop-color": makeColorString(
  857. buttonHoverBackColor,
  858. gradientEnabledColor0,
  859. ),
  860. },
  861. {
  862. tagName: "stop",
  863. offset: "12%",
  864. "stop-color": makeColorString(
  865. buttonHoverBackColor,
  866. gradientEnabledColor1,
  867. ),
  868. },
  869. {
  870. tagName: "stop",
  871. offset: "46%",
  872. "stop-color": makeColorString(
  873. buttonHoverBackColor,
  874. gradientEnabledColor2,
  875. ),
  876. },
  877. {
  878. tagName: "stop",
  879. offset: "81%",
  880. "stop-color": makeColorString(
  881. buttonHoverBackColor,
  882. gradientEnabledColor3,
  883. ),
  884. },
  885. ],
  886. },
  887. {
  888. id: "animation_buttonToggled",
  889. tagName: "linearGradient",
  890. x1: "50%",
  891. y1: "0%",
  892. x2: "50%",
  893. y2: "100%",
  894. children: [
  895. {
  896. tagName: "stop",
  897. offset: "0%",
  898. "stop-color": makeColorString(
  899. buttonToggledBackColor,
  900. gradientEnabledColor0,
  901. ),
  902. },
  903. {
  904. tagName: "stop",
  905. offset: "12%",
  906. "stop-color": makeColorString(
  907. buttonToggledBackColor,
  908. gradientEnabledColor1,
  909. ),
  910. },
  911. {
  912. tagName: "stop",
  913. offset: "46%",
  914. "stop-color": makeColorString(
  915. buttonToggledBackColor,
  916. gradientEnabledColor2,
  917. ),
  918. },
  919. {
  920. tagName: "stop",
  921. offset: "81%",
  922. "stop-color": makeColorString(
  923. buttonToggledBackColor,
  924. gradientEnabledColor3,
  925. ),
  926. },
  927. ],
  928. },
  929. {
  930. id: "animation_buttonDisabled",
  931. tagName: "linearGradient",
  932. x1: "50%",
  933. y1: "0%",
  934. x2: "50%",
  935. y2: "100%",
  936. children: [
  937. {
  938. tagName: "stop",
  939. offset: "0%",
  940. "stop-color": makeColorString(
  941. buttonDisabledBackColor,
  942. gradientDisabledColor0,
  943. ),
  944. },
  945. {
  946. tagName: "stop",
  947. offset: "75%",
  948. "stop-color": makeColorString(
  949. buttonDisabledBackColor,
  950. gradientDisabledColor1,
  951. ),
  952. },
  953. ],
  954. },
  955. {
  956. id: "animation_blurred",
  957. tagName: "filter",
  958. width: "200%",
  959. height: "200%",
  960. x: "-50%",
  961. y: "-50%",
  962. children: [
  963. {
  964. tagName: "feGaussianBlur",
  965. stdDeviation: 4,
  966. in: "SourceGraphic",
  967. },
  968. ],
  969. },
  970. {
  971. id: "animation_shuttleRingSwooshGradient",
  972. tagName: "linearGradient",
  973. x1: "50%",
  974. y1: "0%",
  975. x2: "50%",
  976. y2: "100%",
  977. children: [
  978. {
  979. tagName: "stop",
  980. offset: "0%",
  981. "stop-opacity": 0.2,
  982. "stop-color": swooshColor.toCssColorString(),
  983. },
  984. {
  985. tagName: "stop",
  986. offset: "85%",
  987. "stop-opacity": 0.85,
  988. "stop-color": swooshColor.toCssColorString(),
  989. },
  990. {
  991. tagName: "stop",
  992. offset: "95%",
  993. "stop-opacity": 0.05,
  994. "stop-color": swooshColor.toCssColorString(),
  995. },
  996. ],
  997. },
  998. {
  999. id: "animation_shuttleRingSwooshHovered",
  1000. tagName: "linearGradient",
  1001. x1: "50%",
  1002. y1: "0%",
  1003. x2: "50%",
  1004. y2: "100%",
  1005. children: [
  1006. {
  1007. tagName: "stop",
  1008. offset: "0%",
  1009. "stop-opacity": 0.2,
  1010. "stop-color": swooshHoverColor.toCssColorString(),
  1011. },
  1012. {
  1013. tagName: "stop",
  1014. offset: "85%",
  1015. "stop-opacity": 0.85,
  1016. "stop-color": swooshHoverColor.toCssColorString(),
  1017. },
  1018. {
  1019. tagName: "stop",
  1020. offset: "95%",
  1021. "stop-opacity": 0.05,
  1022. "stop-color": swooshHoverColor.toCssColorString(),
  1023. },
  1024. ],
  1025. },
  1026. {
  1027. id: "animation_shuttleRingPointerGradient",
  1028. tagName: "linearGradient",
  1029. x1: "0%",
  1030. y1: "50%",
  1031. x2: "100%",
  1032. y2: "50%",
  1033. children: [
  1034. {
  1035. tagName: "stop",
  1036. offset: "0%",
  1037. "stop-color": pointerColor.toCssColorString(),
  1038. },
  1039. {
  1040. tagName: "stop",
  1041. offset: "40%",
  1042. "stop-color": pointerColor.toCssColorString(),
  1043. },
  1044. {
  1045. tagName: "stop",
  1046. offset: "60%",
  1047. "stop-color": makeColorString(pointerColor, gradientPointerColor),
  1048. },
  1049. {
  1050. tagName: "stop",
  1051. offset: "100%",
  1052. "stop-color": makeColorString(pointerColor, gradientPointerColor),
  1053. },
  1054. ],
  1055. },
  1056. {
  1057. id: "animation_shuttleRingPointerPaused",
  1058. tagName: "linearGradient",
  1059. x1: "0%",
  1060. y1: "50%",
  1061. x2: "100%",
  1062. y2: "50%",
  1063. children: [
  1064. {
  1065. tagName: "stop",
  1066. offset: "0%",
  1067. "stop-color": "#CCC",
  1068. },
  1069. {
  1070. tagName: "stop",
  1071. offset: "40%",
  1072. "stop-color": "#CCC",
  1073. },
  1074. {
  1075. tagName: "stop",
  1076. offset: "60%",
  1077. "stop-color": "#555",
  1078. },
  1079. {
  1080. tagName: "stop",
  1081. offset: "100%",
  1082. "stop-color": "#555",
  1083. },
  1084. ],
  1085. },
  1086. {
  1087. id: "animation_knobOuter",
  1088. tagName: "linearGradient",
  1089. x1: "20%",
  1090. y1: "0%",
  1091. x2: "90%",
  1092. y2: "100%",
  1093. children: [
  1094. {
  1095. tagName: "stop",
  1096. offset: "5%",
  1097. "stop-color": makeColorString(knobBackColor, gradientEnabledColor0),
  1098. },
  1099. {
  1100. tagName: "stop",
  1101. offset: "60%",
  1102. "stop-color": makeColorString(knobBackColor, gradientKnobColor),
  1103. },
  1104. {
  1105. tagName: "stop",
  1106. offset: "85%",
  1107. "stop-color": makeColorString(knobBackColor, gradientEnabledColor1),
  1108. },
  1109. ],
  1110. },
  1111. {
  1112. id: "animation_knobInner",
  1113. tagName: "linearGradient",
  1114. x1: "20%",
  1115. y1: "0%",
  1116. x2: "90%",
  1117. y2: "100%",
  1118. children: [
  1119. {
  1120. tagName: "stop",
  1121. offset: "5%",
  1122. "stop-color": makeColorString(knobBackColor, gradientKnobColor),
  1123. },
  1124. {
  1125. tagName: "stop",
  1126. offset: "60%",
  1127. "stop-color": makeColorString(knobBackColor, gradientEnabledColor0),
  1128. },
  1129. {
  1130. tagName: "stop",
  1131. offset: "85%",
  1132. "stop-color": makeColorString(knobBackColor, gradientEnabledColor3),
  1133. },
  1134. ],
  1135. },
  1136. ],
  1137. });
  1138. if (!defined(this._defsElement)) {
  1139. this._svgNode.appendChild(defsElement);
  1140. } else {
  1141. this._svgNode.replaceChild(defsElement, this._defsElement);
  1142. }
  1143. this._defsElement = defsElement;
  1144. };
  1145. export default Animation;