vislite 1.2.0-alpha.2 → 1.2.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG +266 -254
  2. package/lib/Buffer/index.es.js +1 -1
  3. package/lib/Buffer/index.es.min.js +1 -1
  4. package/lib/Canvas/index.es.js +16 -5
  5. package/lib/Canvas/index.es.min.js +2 -2
  6. package/lib/Cardinal/index.es.js +1 -1
  7. package/lib/Cardinal/index.es.min.js +1 -1
  8. package/lib/Eoap/index.es.js +1 -1
  9. package/lib/Eoap/index.es.min.js +1 -1
  10. package/lib/Hermite/index.es.js +1 -1
  11. package/lib/Hermite/index.es.min.js +1 -1
  12. package/lib/Matrix4/index.es.js +1 -1
  13. package/lib/Matrix4/index.es.min.js +1 -1
  14. package/lib/Mercator/index.es.js +1 -1
  15. package/lib/Mercator/index.es.min.js +1 -1
  16. package/lib/RawCanvas/index.es.js +15 -4
  17. package/lib/RawCanvas/index.es.min.js +2 -2
  18. package/lib/SVG/index.es.js +12 -8
  19. package/lib/SVG/index.es.min.js +2 -2
  20. package/lib/Shader/index.es.js +1 -1
  21. package/lib/Shader/index.es.min.js +1 -1
  22. package/lib/Texture/index.es.js +1 -1
  23. package/lib/Texture/index.es.min.js +1 -1
  24. package/lib/TreeLayout/index.es.js +38 -8
  25. package/lib/TreeLayout/index.es.min.js +2 -2
  26. package/lib/animation/index.es.js +38 -8
  27. package/lib/animation/index.es.min.js +2 -2
  28. package/lib/assemble/index.es.js +1 -1
  29. package/lib/assemble/index.es.min.js +1 -1
  30. package/lib/getLoopColors/index.es.js +1 -1
  31. package/lib/getLoopColors/index.es.min.js +1 -1
  32. package/lib/getWebGLContext/index.es.js +1 -1
  33. package/lib/getWebGLContext/index.es.min.js +1 -1
  34. package/lib/index.umd.js +88 -36
  35. package/lib/index.umd.min.js +2 -2
  36. package/lib/initOption/index.es.js +1 -1
  37. package/lib/initOption/index.es.min.js +1 -1
  38. package/lib/mergeOption/index.es.js +1 -1
  39. package/lib/mergeOption/index.es.min.js +1 -1
  40. package/lib/move/index.es.js +1 -1
  41. package/lib/move/index.es.min.js +1 -1
  42. package/lib/rotate/index.es.js +1 -1
  43. package/lib/rotate/index.es.min.js +1 -1
  44. package/lib/ruler/index.es.js +1 -1
  45. package/lib/ruler/index.es.min.js +1 -1
  46. package/lib/scale/index.es.js +1 -1
  47. package/lib/scale/index.es.min.js +1 -1
  48. package/lib/throttle/index.es.js +25 -25
  49. package/lib/throttle/index.es.min.js +2 -2
  50. package/miniprogram/ui-canvas/index.js +115 -115
  51. package/package/animation/index.ts +1 -1
  52. package/package/throttle/index.ts +1 -1
  53. package/package.json +7 -2
  54. package/src/Canvas.ts +84 -84
  55. package/src/common/canvas/gradient.ts +32 -24
  56. package/src/common/canvas/index.ts +182 -177
  57. package/src/common/canvas/painter.ts +9 -3
  58. package/src/common/svg/config.ts +194 -190
  59. package/src/common/svg/index.ts +350 -347
  60. package/src/common/svg/tool.ts +42 -44
  61. package/src/layout/TreeLayout.ts +1 -1
  62. package/types/Canvas.d.ts +10 -1
  63. package/types/CanvasConfig.d.ts +116 -106
  64. package/types/SVGConfig.d.ts +89 -79
  65. package/types/animation.d.ts +2 -6
  66. package/types/index.d.ts +160 -158
  67. package/types/painterConfig.d.ts +5 -3
  68. package/types/throttle.d.ts +2 -4
  69. package/types/throttleOption.d.ts +1 -22
  70. package/types/uni-canvas.d.ts +4 -0
  71. package/src/animation.ts +0 -99
  72. package/src/throttle.ts +0 -53
@@ -1,14 +1,28 @@
1
1
  /*!
2
- * animation of VISLite JavaScript Library v1.2.0-alpha.2
2
+ * animation of VISLite JavaScript Library v1.2.0-alpha.4
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
+ //当前正在运动的动画的tick函数堆栈
5
6
  var $timers = [];
7
+ //唯一定时器的定时间隔
6
8
  var $interval = 13;
9
+ //定时器ID
7
10
  var $timerId;
8
- function animation (doback, duration, callback) {
9
- if (duration === void 0) { duration = 400; }
10
- if (callback === void 0) { callback = function () { }; }
11
+
12
+ /**
13
+ * 动画轮播
14
+ * @param {function} doback 轮询函数,有一个形参deep,0-1,表示执行进度
15
+ * @param {number} duration 动画时长,可选
16
+ * @param {function} callback 动画结束回调,可选,有一个形参deep,0-1,表示执行进度
17
+ *
18
+ * @returns {function} 返回一个函数,调用该函数,可以提前结束动画
19
+ */
20
+ function animation(doback, duration, callback) {
21
+ if (arguments.length < 2) duration = 400;
22
+ if (arguments.length < 3) callback = function () { };
23
+
11
24
  var clock = {
25
+ //把tick函数推入堆栈
12
26
  "timer": function (tick, duration, callback) {
13
27
  if (!tick) {
14
28
  throw new Error('Tick is required!');
@@ -24,29 +38,37 @@ function animation (doback, duration, callback) {
24
38
  clock.start();
25
39
  return id;
26
40
  },
41
+
42
+ //开启唯一的定时器timerId
27
43
  "start": function () {
28
44
  if (!$timerId) {
29
45
  $timerId = setInterval(clock.tick, $interval);
30
46
  }
31
47
  },
48
+
49
+ //被定时器调用,遍历timers堆栈
32
50
  "tick": function () {
33
- var createTime, flag, tick, callback, timer, duration, passTime;
34
- var timers = $timers;
51
+ var createTime, flag, tick, callback, timer, duration, passTime, timers = $timers;
52
+
35
53
  $timers = [];
36
54
  $timers.length = 0;
55
+
37
56
  for (flag = 0; flag < timers.length; flag++) {
57
+ //初始化数据
38
58
  timer = timers[flag];
39
59
  createTime = timer.createTime;
40
60
  tick = timer.tick;
41
61
  duration = timer.duration;
42
62
  callback = timer.callback;
63
+
64
+ //执行
43
65
  passTime = (+new Date().valueOf() - createTime.valueOf()) / duration;
44
66
  passTime = passTime > 1 ? 1 : passTime;
45
67
  tick(passTime);
46
68
  if (passTime < 1 && timer.id) {
69
+ //动画没有结束再添加
47
70
  $timers.push(timer);
48
- }
49
- else {
71
+ } else {
50
72
  callback(passTime);
51
73
  }
52
74
  }
@@ -54,6 +76,8 @@ function animation (doback, duration, callback) {
54
76
  clock.stop();
55
77
  }
56
78
  },
79
+
80
+ //停止定时器,重置timerId=null
57
81
  "stop": function () {
58
82
  if ($timerId) {
59
83
  clearInterval($timerId);
@@ -61,9 +85,14 @@ function animation (doback, duration, callback) {
61
85
  }
62
86
  }
63
87
  };
88
+
64
89
  var id = clock.timer(function (deep) {
90
+ //其中deep为0-1,表示改变的程度
65
91
  doback(deep);
66
92
  }, duration, callback);
93
+
94
+ // 返回一个函数
95
+ // 用于在动画结束前结束动画
67
96
  return function () {
68
97
  var i;
69
98
  for (i in $timers) {
@@ -73,6 +102,7 @@ function animation (doback, duration, callback) {
73
102
  }
74
103
  }
75
104
  };
105
+
76
106
  }
77
107
 
78
108
  export { animation as default };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of VISLite JavaScript Library v1.2.0-alpha.2
2
+ * animation of VISLite JavaScript Library v1.2.0-alpha.4
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
- var t,e=[];function i(i,n,r){void 0===n&&(n=400),void 0===r&&(r=function(){});var a={timer:function(t,i,n){if(!t)throw new Error("Tick is required!");var r=(new Date).valueOf()+"_"+(1e3*Math.random()).toFixed(0);return e.push({id:r,createTime:new Date,tick:t,duration:i,callback:n}),a.start(),r},start:function(){t||(t=setInterval(a.tick,13))},tick:function(){var t,i,n,r,o,u,c,f=e;for((e=[]).length=0,i=0;i<f.length;i++)t=(o=f[i]).createTime,n=o.tick,u=o.duration,r=o.callback,n(c=(c=(+(new Date).valueOf()-t.valueOf())/u)>1?1:c),c<1&&o.id?e.push(o):r(c);e.length<=0&&a.stop()},stop:function(){t&&(clearInterval(t),t=null)}},o=a.timer((function(t){i(t)}),n,r);return function(){var t;for(t in e)if(e[t].id==o)return void(e[t].id=void 0)}}export{i as default};
5
+ var t,e=[];function n(n,r,i){arguments.length<2&&(r=400),arguments.length<3&&(i=function(){});var a={timer:function(t,n,r){if(!t)throw new Error("Tick is required!");var i=(new Date).valueOf()+"_"+(1e3*Math.random()).toFixed(0);return e.push({id:i,createTime:new Date,tick:t,duration:n,callback:r}),a.start(),i},start:function(){t||(t=setInterval(a.tick,13))},tick:function(){var t,n,r,i,o,u,c,l=e;for((e=[]).length=0,n=0;n<l.length;n++)t=(o=l[n]).createTime,r=o.tick,u=o.duration,i=o.callback,r(c=(c=(+(new Date).valueOf()-t.valueOf())/u)>1?1:c),c<1&&o.id?e.push(o):i(c);e.length<=0&&a.stop()},stop:function(){t&&(clearInterval(t),t=null)}},o=a.timer((function(t){n(t)}),r,i);return function(){var t;for(t in e)if(e[t].id==o)return void(e[t].id=void 0)}}export{n as default};
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * assemble of VISLite JavaScript Library v1.2.0-alpha.2
2
+ * assemble of VISLite JavaScript Library v1.2.0-alpha.4
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function assemble (begin, end, step, count) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * assemble of VISLite JavaScript Library v1.2.0-alpha.2
2
+ * assemble of VISLite JavaScript Library v1.2.0-alpha.4
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function r(r,t,e,f){for(var n=[],o=0;o<f;o++)n[o]=r;return function(){for(var o=0;o<f;o++){if(n[o]+e<t){n[o]=+(n[o]+e).toFixed(7);break}o<f-1&&(n[o]=r)}return n}}export{r as default};
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * getLoopColors of VISLite JavaScript Library v1.2.0-alpha.2
2
+ * getLoopColors of VISLite JavaScript Library v1.2.0-alpha.4
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function getLoopColors (num, alpha) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * getLoopColors of VISLite JavaScript Library v1.2.0-alpha.2
2
+ * getLoopColors of VISLite JavaScript Library v1.2.0-alpha.4
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function r(r,a){void 0===a&&(a=1);var g=["rgba(84,112,198,"+a+")","rgba(145,204,117,"+a+")","rgba(250,200,88,"+a+")","rgba(238,102,102,"+a+")","rgba(115,192,222,"+a+")","rgba(59,162,114,"+a+")","rgba(252,132,82,"+a+")","rgba(154,96,180,"+a+")","rgba(234,124,204,"+a+")"],t=[];if(r<=g.length)return g;if(r%g.length==0)for(var e=0;e<r/g.length;e++)t=t.concat(g);else{for(var n=1;n<r/g.length;n++)t=t.concat(g);if(r%g.length==1)t=t.concat(g[4]);else for(var o=0;o<r%g.length;o++)t=t.concat(g[o])}return t}export{r as default};
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * getWebGLContext of VISLite JavaScript Library v1.2.0-alpha.2
2
+ * getWebGLContext of VISLite JavaScript Library v1.2.0-alpha.4
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function getWebGLContext (canvas, scale, opts, mode) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * getWebGLContext of VISLite JavaScript Library v1.2.0-alpha.2
2
+ * getWebGLContext of VISLite JavaScript Library v1.2.0-alpha.4
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  var e=function(e,t,i){if(void 0===t&&(t=1),!e)throw new Error("VISLite getWebGLContext:The mount point requires an HTMLElement type but encountered null.");var n,r=e.clientWidth,a=e.clientHeight,o=e;return o._vislite_canvas_?n=o._vislite_canvas_:(n=document.createElement("canvas"),e.appendChild(n),o._vislite_canvas_=n,e.setAttribute("vislite","WebGL")),n.style.width=r+"px",n.setAttribute("width",r+""),n.style.height=a+"px",n.setAttribute("height",a+""),function(e,t,i,n){void 0===i&&(i={}),void 0===n&&(n="scaleToFill");for(var r=["experimental-webgl","webkit-3d","moz-webgl"],a=e.getContext("webgl",i),o=0;o<r.length;o++){try{a=e.getContext(r[o],i)}catch(e){}if(a)break}if(!a)throw new Error("Non canvas or browser does not support webgl.");var l=a.canvas.width,s=a.canvas.height,c=t,v=t;"aspectFit"==n?l>s?c*=s/l:s>l&&(v*=l/s):"aspectFill"==n&&(l>s?v*=l/s:s>l&&(c*=s/l));var h=l*c,u=s*v;return a.viewport(.5*(l-h),.5*(s-u),h,u),a.depthFunc(a.LEQUAL),a.enable(a.DEPTH_TEST),a}(n,t,{},i)};export{e as default};
package/lib/index.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * VISLite JavaScript Library v1.2.0-alpha.2
2
+ * VISLite JavaScript Library v1.2.0-alpha.4
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  (function (global, factory) {
@@ -293,13 +293,27 @@
293
293
  return colors;
294
294
  }
295
295
 
296
+ //当前正在运动的动画的tick函数堆栈
296
297
  var $timers = [];
298
+ //唯一定时器的定时间隔
297
299
  var $interval = 13;
300
+ //定时器ID
298
301
  var $timerId;
299
- function animation (doback, duration, callback) {
300
- if (duration === void 0) { duration = 400; }
301
- if (callback === void 0) { callback = function () { }; }
302
+
303
+ /**
304
+ * 动画轮播
305
+ * @param {function} doback 轮询函数,有一个形参deep,0-1,表示执行进度
306
+ * @param {number} duration 动画时长,可选
307
+ * @param {function} callback 动画结束回调,可选,有一个形参deep,0-1,表示执行进度
308
+ *
309
+ * @returns {function} 返回一个函数,调用该函数,可以提前结束动画
310
+ */
311
+ function animation(doback, duration, callback) {
312
+ if (arguments.length < 2) duration = 400;
313
+ if (arguments.length < 3) callback = function () { };
314
+
302
315
  var clock = {
316
+ //把tick函数推入堆栈
303
317
  "timer": function (tick, duration, callback) {
304
318
  if (!tick) {
305
319
  throw new Error('Tick is required!');
@@ -315,29 +329,37 @@
315
329
  clock.start();
316
330
  return id;
317
331
  },
332
+
333
+ //开启唯一的定时器timerId
318
334
  "start": function () {
319
335
  if (!$timerId) {
320
336
  $timerId = setInterval(clock.tick, $interval);
321
337
  }
322
338
  },
339
+
340
+ //被定时器调用,遍历timers堆栈
323
341
  "tick": function () {
324
- var createTime, flag, tick, callback, timer, duration, passTime;
325
- var timers = $timers;
342
+ var createTime, flag, tick, callback, timer, duration, passTime, timers = $timers;
343
+
326
344
  $timers = [];
327
345
  $timers.length = 0;
346
+
328
347
  for (flag = 0; flag < timers.length; flag++) {
348
+ //初始化数据
329
349
  timer = timers[flag];
330
350
  createTime = timer.createTime;
331
351
  tick = timer.tick;
332
352
  duration = timer.duration;
333
353
  callback = timer.callback;
354
+
355
+ //执行
334
356
  passTime = (+new Date().valueOf() - createTime.valueOf()) / duration;
335
357
  passTime = passTime > 1 ? 1 : passTime;
336
358
  tick(passTime);
337
359
  if (passTime < 1 && timer.id) {
360
+ //动画没有结束再添加
338
361
  $timers.push(timer);
339
- }
340
- else {
362
+ } else {
341
363
  callback(passTime);
342
364
  }
343
365
  }
@@ -345,6 +367,8 @@
345
367
  clock.stop();
346
368
  }
347
369
  },
370
+
371
+ //停止定时器,重置timerId=null
348
372
  "stop": function () {
349
373
  if ($timerId) {
350
374
  clearInterval($timerId);
@@ -352,9 +376,14 @@
352
376
  }
353
377
  }
354
378
  };
379
+
355
380
  var id = clock.timer(function (deep) {
381
+ //其中deep为0-1,表示改变的程度
356
382
  doback(deep);
357
383
  }, duration, callback);
384
+
385
+ // 返回一个函数
386
+ // 用于在动画结束前结束动画
358
387
  return function () {
359
388
  var i;
360
389
  for (i in $timers) {
@@ -364,6 +393,7 @@
364
393
  }
365
394
  }
366
395
  };
396
+
367
397
  }
368
398
 
369
399
  function ruler (maxValue, minValue, num, option) {
@@ -562,7 +592,6 @@
562
592
  function full(el, config) {
563
593
  _setAttribute(el, "stroke", config.strokeStyle);
564
594
  _setAttribute(el, "fill", config.fillStyle);
565
- _setAttribute(el, "stroke-dasharray", config.lineDash.join(','));
566
595
  }
567
596
  function fill(el, config) {
568
597
  _setAttribute(el, "fill", config.fillStyle);
@@ -570,7 +599,6 @@
570
599
  function stroke(el, config) {
571
600
  _setAttribute(el, "stroke", config.strokeStyle);
572
601
  _setAttribute(el, "fill", "none");
573
- _setAttribute(el, "stroke-dasharray", config.lineDash.join(','));
574
602
  }
575
603
 
576
604
  function setStyle (el, styles) {
@@ -651,10 +679,14 @@
651
679
  setAttribute(el, "cy", cy);
652
680
  setAttribute(el, "r", r);
653
681
  };
654
- var initPath = function (el, path) {
682
+ var initPath = function (el, path, config) {
655
683
  if (el.nodeName.toLowerCase() !== "path")
656
684
  throw new Error("Need a <path> !");
657
685
  setAttribute(el, "d", path);
686
+ setAttribute(el, "stroke-dasharray", config.lineDash.join(','));
687
+ setAttribute(el, "stroke-width", config.lineWidth + "");
688
+ setAttribute(el, "stroke-linecap", config.lineCap + "");
689
+ setAttribute(el, "stroke-linejoin", config.lineJoin + "");
658
690
  };
659
691
  var initRect$1 = function (el, x, y, width, height) {
660
692
  if (el.nodeName.toLowerCase() !== "rect")
@@ -761,7 +793,6 @@
761
793
  this.__config = {
762
794
  fillStyle: "#000",
763
795
  strokeStyle: "#000",
764
- lineWidth: 1,
765
796
  textAlign: "left",
766
797
  textBaseline: "middle",
767
798
  "fontSize": 16,
@@ -769,6 +800,9 @@
769
800
  "arcStartCap": "butt",
770
801
  "arcEndCap": "butt",
771
802
  lineDash: [],
803
+ lineWidth: 1,
804
+ lineCap: "butt",
805
+ lineJoin: "miter"
772
806
  };
773
807
  this.__path = "";
774
808
  this.__currentPosition = [];
@@ -923,17 +957,17 @@
923
957
  return this;
924
958
  };
925
959
  SVG.prototype.fill = function () {
926
- initPath(this.__useEl, this.__path);
960
+ initPath(this.__useEl, this.__path, this.__config);
927
961
  fill(this.__useEl, this.__config);
928
962
  return this;
929
963
  };
930
964
  SVG.prototype.stroke = function () {
931
- initPath(this.__useEl, this.__path);
965
+ initPath(this.__useEl, this.__path, this.__config);
932
966
  stroke(this.__useEl, this.__config);
933
967
  return this;
934
968
  };
935
969
  SVG.prototype.full = function () {
936
- initPath(this.__useEl, this.__path);
970
+ initPath(this.__useEl, this.__path, this.__config);
937
971
  full(this.__useEl, this.__config);
938
972
  return this;
939
973
  };
@@ -1104,9 +1138,11 @@
1104
1138
  "fillStyle": 'black',
1105
1139
  "strokeStyle": 'black',
1106
1140
  "lineWidth": 1,
1141
+ "lineCap": "butt",
1142
+ "lineJoin": "miter",
1143
+ "lineDash": [],
1107
1144
  "textAlign": 'left',
1108
1145
  "textBaseline": 'middle',
1109
- "lineDash": [],
1110
1146
  "shadowBlur": 0,
1111
1147
  "shadowColor": "black"
1112
1148
  };
@@ -1494,13 +1530,13 @@
1494
1530
  };
1495
1531
  }
1496
1532
 
1497
- var enhanceGradient = function (gradient) {
1533
+ var enhanceGradient = function (gradient, calcStop) {
1498
1534
  var enhanceGradient = {
1499
1535
  "value": function () {
1500
1536
  return gradient;
1501
1537
  },
1502
1538
  "setColor": function (stop, color) {
1503
- gradient.addColorStop(stop, color);
1539
+ gradient.addColorStop(calcStop ? calcStop(stop) : stop, color);
1504
1540
  return enhanceGradient;
1505
1541
  }
1506
1542
  };
@@ -1513,6 +1549,12 @@
1513
1549
  var radialGradient = function (painter, cx, cy, r) {
1514
1550
  var gradient = painter.createRadialGradient(cx, cy, 0, cx, cy, r);
1515
1551
  return enhanceGradient(gradient);
1552
+ };
1553
+ var conicGradient = function (painter, cx, cy, startDeg, deg) {
1554
+ var gradient = painter.createConicGradient(startDeg, cx, cy);
1555
+ return enhanceGradient(gradient, deg ? function (stop) {
1556
+ return deg / (Math.PI * 2) * stop;
1557
+ } : undefined);
1516
1558
  };
1517
1559
 
1518
1560
  var Canvas$1 = (function (_super) {
@@ -1621,6 +1663,9 @@
1621
1663
  Canvas.prototype.createRadialGradient = function (cx, cy, r) {
1622
1664
  return radialGradient(this.painter, cx, cy, r);
1623
1665
  };
1666
+ Canvas.prototype.createConicGradient = function (cx, cy, beginDeg, deg) {
1667
+ return conicGradient(this.painter, cx, cy, beginDeg, deg);
1668
+ };
1624
1669
  Canvas.prototype.getColor = function (x, y) {
1625
1670
  x *= this.__scaleSize;
1626
1671
  y *= this.__scaleSize;
@@ -1740,7 +1785,7 @@
1740
1785
  var _this = this;
1741
1786
  this.__el.addEventListener(eventName, function (event) {
1742
1787
  _this.getRegion(event.offsetX, event.offsetY).then(function (regionName) {
1743
- callback(regionName);
1788
+ callback(regionName, event.offsetX, event.offsetY);
1744
1789
  });
1745
1790
  });
1746
1791
  return this;
@@ -1993,47 +2038,54 @@
1993
2038
  return Mercator;
1994
2039
  }());
1995
2040
 
1996
- function throttle (callback, option) {
1997
- if (option === void 0) { option = {}; }
1998
- option = initOption(option, {
2041
+ function throttle(callback, _option) {
2042
+
2043
+ // 缺省值
2044
+ var option = {
1999
2045
  time: 200,
2000
2046
  keep: false,
2001
2047
  opportunity: "end"
2002
- });
2003
- var hadInterval = false;
2004
- var hadClick = false;
2005
- var oneClick = false;
2006
- var arg;
2048
+ };
2049
+
2050
+ // 校对
2051
+ if (_option) {
2052
+ for (var key in _option) {
2053
+ option[key] = _option[key];
2054
+ }
2055
+ }
2056
+
2057
+ var hadInterval = false, hadClick = false, oneClick = false, arg;
2007
2058
  return function () {
2008
- var _this = this;
2059
+ const _this = this;
2009
2060
  arg = arguments;
2061
+
2062
+ // 如果前置任务都完成了
2010
2063
  if (!hadInterval) {
2011
2064
  if (option.opportunity != 'end') {
2012
2065
  callback.apply(_this, arg);
2013
2066
  }
2014
2067
  hadInterval = true;
2015
- var interval_1 = setInterval(function () {
2068
+
2069
+ var interval = setInterval(() => {
2016
2070
  if (hadClick) {
2017
2071
  if (!option.keep) {
2018
2072
  callback.apply(_this, arg);
2019
2073
  }
2020
- }
2021
- else {
2074
+ } else {
2022
2075
  if (option.opportunity != 'begin') {
2023
- if (oneClick || option.opportunity == 'end')
2024
- callback.apply(_this, arg);
2076
+ if (oneClick || option.opportunity == 'end') callback.apply(_this, arg);
2025
2077
  }
2026
2078
  hadInterval = false;
2027
2079
  oneClick = false;
2028
- clearInterval(interval_1);
2080
+ clearInterval(interval);
2029
2081
  }
2030
2082
  hadClick = false;
2031
2083
  }, option.time);
2032
- }
2033
- else {
2084
+ } else {
2034
2085
  hadClick = true;
2035
2086
  oneClick = true;
2036
2087
  }
2088
+
2037
2089
  };
2038
2090
  }
2039
2091