@antv/g-svg 1.1.6 → 1.1.7
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.
- package/dist/index.esm.js +70 -179
- package/dist/index.js +70 -179
- package/dist/index.umd.js +1081 -1501
- package/dist/index.umd.min.js +4 -4
- package/package.json +5 -5
package/dist/index.umd.js
CHANGED
|
@@ -4,64 +4,11 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.SVG = {}), global.window.G, global.window.G.ManaSyringe));
|
|
5
5
|
}(this, (function (exports, g, manaSyringe) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
11
|
-
return typeof obj;
|
|
12
|
-
} : function (obj) {
|
|
13
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
14
|
-
}, _typeof(obj);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function _classCallCheck(instance, Constructor) {
|
|
18
|
-
if (!(instance instanceof Constructor)) {
|
|
19
|
-
throw new TypeError("Cannot call a class as a function");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
7
|
+
function _inheritsLoose(subClass, superClass) {
|
|
8
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
9
|
+
subClass.prototype.constructor = subClass;
|
|
22
10
|
|
|
23
|
-
|
|
24
|
-
for (var i = 0; i < props.length; i++) {
|
|
25
|
-
var descriptor = props[i];
|
|
26
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
27
|
-
descriptor.configurable = true;
|
|
28
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
29
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
34
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
35
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
36
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
37
|
-
writable: false
|
|
38
|
-
});
|
|
39
|
-
return Constructor;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function _inherits(subClass, superClass) {
|
|
43
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
44
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
48
|
-
constructor: {
|
|
49
|
-
value: subClass,
|
|
50
|
-
writable: true,
|
|
51
|
-
configurable: true
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
Object.defineProperty(subClass, "prototype", {
|
|
55
|
-
writable: false
|
|
56
|
-
});
|
|
57
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function _getPrototypeOf(o) {
|
|
61
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
62
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
63
|
-
};
|
|
64
|
-
return _getPrototypeOf(o);
|
|
11
|
+
_setPrototypeOf(subClass, superClass);
|
|
65
12
|
}
|
|
66
13
|
|
|
67
14
|
function _setPrototypeOf(o, p) {
|
|
@@ -73,56 +20,6 @@
|
|
|
73
20
|
return _setPrototypeOf(o, p);
|
|
74
21
|
}
|
|
75
22
|
|
|
76
|
-
function _isNativeReflectConstruct() {
|
|
77
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
78
|
-
if (Reflect.construct.sham) return false;
|
|
79
|
-
if (typeof Proxy === "function") return true;
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
83
|
-
return true;
|
|
84
|
-
} catch (e) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function _assertThisInitialized(self) {
|
|
90
|
-
if (self === void 0) {
|
|
91
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return self;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function _possibleConstructorReturn(self, call) {
|
|
98
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
99
|
-
return call;
|
|
100
|
-
} else if (call !== void 0) {
|
|
101
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return _assertThisInitialized(self);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function _createSuper(Derived) {
|
|
108
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
109
|
-
|
|
110
|
-
return function _createSuperInternal() {
|
|
111
|
-
var Super = _getPrototypeOf(Derived),
|
|
112
|
-
result;
|
|
113
|
-
|
|
114
|
-
if (hasNativeReflectConstruct) {
|
|
115
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
116
|
-
|
|
117
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
118
|
-
} else {
|
|
119
|
-
result = Super.apply(this, arguments);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return _possibleConstructorReturn(this, result);
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
23
|
/******************************************************************************
|
|
127
24
|
Copyright (c) Microsoft Corporation.
|
|
128
25
|
|
|
@@ -274,7 +171,7 @@
|
|
|
274
171
|
if ("throw" !== record.type) {
|
|
275
172
|
var result = record.arg,
|
|
276
173
|
value = result.value;
|
|
277
|
-
return value && "object" ==
|
|
174
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
278
175
|
invoke("next", value, resolve, reject);
|
|
279
176
|
}, function (err) {
|
|
280
177
|
invoke("throw", err, resolve, reject);
|
|
@@ -535,31 +432,6 @@
|
|
|
535
432
|
};
|
|
536
433
|
}
|
|
537
434
|
|
|
538
|
-
function _classCallCheck$1(instance, Constructor) {
|
|
539
|
-
if (!(instance instanceof Constructor)) {
|
|
540
|
-
throw new TypeError("Cannot call a class as a function");
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
function _defineProperties$1(target, props) {
|
|
545
|
-
for (var i = 0; i < props.length; i++) {
|
|
546
|
-
var descriptor = props[i];
|
|
547
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
548
|
-
descriptor.configurable = true;
|
|
549
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
550
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
function _createClass$1(Constructor, protoProps, staticProps) {
|
|
555
|
-
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
556
|
-
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
557
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
558
|
-
writable: false
|
|
559
|
-
});
|
|
560
|
-
return Constructor;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
435
|
var _class;
|
|
564
436
|
|
|
565
437
|
var DOMInteractionPlugin_1;
|
|
@@ -569,150 +441,147 @@
|
|
|
569
441
|
|
|
570
442
|
var DOMInteractionPlugin = DOMInteractionPlugin_1 = (_class = /*#__PURE__*/function () {
|
|
571
443
|
function DOMInteractionPlugin() {
|
|
572
|
-
_classCallCheck$1(this, DOMInteractionPlugin);
|
|
573
|
-
|
|
574
444
|
this.contextService = void 0;
|
|
575
445
|
this.renderingContext = void 0;
|
|
576
446
|
}
|
|
577
447
|
|
|
578
|
-
|
|
579
|
-
key: "apply",
|
|
580
|
-
value: function apply(renderingService) {
|
|
581
|
-
var _this = this;
|
|
448
|
+
var _proto = DOMInteractionPlugin.prototype;
|
|
582
449
|
|
|
583
|
-
|
|
450
|
+
_proto.apply = function apply(renderingService) {
|
|
451
|
+
var _this = this;
|
|
584
452
|
|
|
585
|
-
|
|
586
|
-
renderingService.hooks.pointerMove.call(ev);
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
var onPointerUp = function onPointerUp(ev) {
|
|
590
|
-
renderingService.hooks.pointerUp.call(ev);
|
|
591
|
-
};
|
|
453
|
+
var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
592
454
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
455
|
+
var onPointerMove = function onPointerMove(ev) {
|
|
456
|
+
renderingService.hooks.pointerMove.call(ev);
|
|
457
|
+
};
|
|
596
458
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
459
|
+
var onPointerUp = function onPointerUp(ev) {
|
|
460
|
+
renderingService.hooks.pointerUp.call(ev);
|
|
461
|
+
};
|
|
600
462
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
463
|
+
var onPointerDown = function onPointerDown(ev) {
|
|
464
|
+
renderingService.hooks.pointerDown.call(ev);
|
|
465
|
+
};
|
|
604
466
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
467
|
+
var onPointerOver = function onPointerOver(ev) {
|
|
468
|
+
renderingService.hooks.pointerOver.call(ev);
|
|
469
|
+
};
|
|
608
470
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
471
|
+
var onPointerOut = function onPointerOut(ev) {
|
|
472
|
+
renderingService.hooks.pointerOut.call(ev);
|
|
473
|
+
};
|
|
612
474
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
617
|
-
$el.addEventListener('pointerover', onPointerOver, true);
|
|
618
|
-
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
619
|
-
};
|
|
475
|
+
var onPointerCancel = function onPointerCancel(ev) {
|
|
476
|
+
renderingService.hooks.pointerCancel.call(ev);
|
|
477
|
+
};
|
|
620
478
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
$el.addEventListener('touchmove', onPointerMove, true);
|
|
625
|
-
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
626
|
-
};
|
|
479
|
+
var onPointerWheel = function onPointerWheel(ev) {
|
|
480
|
+
renderingService.hooks.pointerWheel.call(ev);
|
|
481
|
+
};
|
|
627
482
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
483
|
+
var addPointerEventListener = function addPointerEventListener($el) {
|
|
484
|
+
globalThis.document.addEventListener('pointermove', onPointerMove, true);
|
|
485
|
+
$el.addEventListener('pointerdown', onPointerDown, true);
|
|
486
|
+
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
487
|
+
$el.addEventListener('pointerover', onPointerOver, true);
|
|
488
|
+
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
489
|
+
};
|
|
635
490
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
};
|
|
491
|
+
var addTouchEventListener = function addTouchEventListener($el) {
|
|
492
|
+
$el.addEventListener('touchstart', onPointerDown, true);
|
|
493
|
+
$el.addEventListener('touchend', onPointerUp, true);
|
|
494
|
+
$el.addEventListener('touchmove', onPointerMove, true);
|
|
495
|
+
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
496
|
+
};
|
|
643
497
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
498
|
+
var addMouseEventListener = function addMouseEventListener($el) {
|
|
499
|
+
globalThis.document.addEventListener('mousemove', onPointerMove, true);
|
|
500
|
+
$el.addEventListener('mousedown', onPointerDown, true);
|
|
501
|
+
$el.addEventListener('mouseout', onPointerOut, true);
|
|
502
|
+
$el.addEventListener('mouseover', onPointerOver, true);
|
|
503
|
+
globalThis.addEventListener('mouseup', onPointerUp, true);
|
|
504
|
+
};
|
|
649
505
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
506
|
+
var removePointerEventListener = function removePointerEventListener($el) {
|
|
507
|
+
globalThis.document.removeEventListener('pointermove', onPointerMove, true);
|
|
508
|
+
$el.removeEventListener('pointerdown', onPointerDown, true);
|
|
509
|
+
$el.removeEventListener('pointerleave', onPointerOut, true);
|
|
510
|
+
$el.removeEventListener('pointerover', onPointerOver, true);
|
|
511
|
+
globalThis.removeEventListener('pointerup', onPointerUp, true);
|
|
512
|
+
};
|
|
657
513
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
case 0:
|
|
664
|
-
$el = _this.contextService.getDomElement(); // @ts-ignore
|
|
514
|
+
var removeTouchEventListener = function removeTouchEventListener($el) {
|
|
515
|
+
$el.removeEventListener('touchstart', onPointerDown, true);
|
|
516
|
+
$el.removeEventListener('touchend', onPointerUp, true);
|
|
517
|
+
$el.removeEventListener('touchmove', onPointerMove, true);
|
|
518
|
+
};
|
|
665
519
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
520
|
+
var removeMouseEventListener = function removeMouseEventListener($el) {
|
|
521
|
+
globalThis.document.removeEventListener('mousemove', onPointerMove, true);
|
|
522
|
+
$el.removeEventListener('mousedown', onPointerDown, true);
|
|
523
|
+
$el.removeEventListener('mouseout', onPointerOut, true);
|
|
524
|
+
$el.removeEventListener('mouseover', onPointerOver, true);
|
|
525
|
+
globalThis.removeEventListener('mouseup', onPointerUp, true);
|
|
526
|
+
};
|
|
669
527
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
528
|
+
renderingService.hooks.init.tapPromise(DOMInteractionPlugin_1.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
529
|
+
var $el;
|
|
530
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
531
|
+
while (1) {
|
|
532
|
+
switch (_context.prev = _context.next) {
|
|
533
|
+
case 0:
|
|
534
|
+
$el = _this.contextService.getDomElement(); // @ts-ignore
|
|
535
|
+
|
|
536
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
537
|
+
// @ts-ignore
|
|
538
|
+
$el.style.msContentZooming = 'none'; // @ts-ignore
|
|
539
|
+
|
|
540
|
+
$el.style.msTouchAction = 'none';
|
|
541
|
+
} else if (canvas.supportsPointerEvents) {
|
|
542
|
+
$el.style.touchAction = 'none';
|
|
543
|
+
}
|
|
674
544
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
545
|
+
if (canvas.supportsPointerEvents) {
|
|
546
|
+
addPointerEventListener($el);
|
|
547
|
+
} else {
|
|
548
|
+
addMouseEventListener($el);
|
|
549
|
+
}
|
|
680
550
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
551
|
+
if (canvas.supportsTouchEvents) {
|
|
552
|
+
addTouchEventListener($el);
|
|
553
|
+
} // use passive event listeners
|
|
554
|
+
// @see https://zhuanlan.zhihu.com/p/24555031
|
|
685
555
|
|
|
686
556
|
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
557
|
+
$el.addEventListener('wheel', onPointerWheel, {
|
|
558
|
+
passive: true,
|
|
559
|
+
capture: true
|
|
560
|
+
});
|
|
691
561
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
}
|
|
562
|
+
case 5:
|
|
563
|
+
case "end":
|
|
564
|
+
return _context.stop();
|
|
696
565
|
}
|
|
697
|
-
}, _callee);
|
|
698
|
-
})));
|
|
699
|
-
renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
|
|
700
|
-
var $el = _this.contextService.getDomElement();
|
|
701
|
-
|
|
702
|
-
if (canvas.supportsPointerEvents) {
|
|
703
|
-
removePointerEventListener($el);
|
|
704
|
-
} else {
|
|
705
|
-
removeMouseEventListener($el);
|
|
706
566
|
}
|
|
567
|
+
}, _callee);
|
|
568
|
+
})));
|
|
569
|
+
renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
|
|
570
|
+
var $el = _this.contextService.getDomElement();
|
|
707
571
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
572
|
+
if (canvas.supportsPointerEvents) {
|
|
573
|
+
removePointerEventListener($el);
|
|
574
|
+
} else {
|
|
575
|
+
removeMouseEventListener($el);
|
|
576
|
+
}
|
|
711
577
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
578
|
+
if (canvas.supportsTouchEvents) {
|
|
579
|
+
removeTouchEventListener($el);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
$el.removeEventListener('wheel', onPointerWheel, true);
|
|
583
|
+
});
|
|
584
|
+
};
|
|
716
585
|
|
|
717
586
|
return DOMInteractionPlugin;
|
|
718
587
|
}(), _class.tag = 'DOMInteraction', _class);
|
|
@@ -730,22 +599,18 @@
|
|
|
730
599
|
|
|
731
600
|
var Plugin = /*#__PURE__*/function () {
|
|
732
601
|
function Plugin() {
|
|
733
|
-
_classCallCheck$1(this, Plugin);
|
|
734
|
-
|
|
735
602
|
this.name = 'dom-interaction';
|
|
736
603
|
}
|
|
737
604
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
}
|
|
748
|
-
}]);
|
|
605
|
+
var _proto = Plugin.prototype;
|
|
606
|
+
|
|
607
|
+
_proto.init = function init(container) {
|
|
608
|
+
container.load(containerModule, true);
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
_proto.destroy = function destroy(container) {
|
|
612
|
+
container.unload(containerModule);
|
|
613
|
+
};
|
|
749
614
|
|
|
750
615
|
return Plugin;
|
|
751
616
|
}();
|
|
@@ -961,6 +826,342 @@
|
|
|
961
826
|
return output;
|
|
962
827
|
}
|
|
963
828
|
|
|
829
|
+
var ElementSVG = function ElementSVG() {
|
|
830
|
+
this.$el = void 0;
|
|
831
|
+
this.$groupEl = void 0;
|
|
832
|
+
this.$hitTestingEl = void 0;
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
ElementSVG.tag = 'c-svg-element';
|
|
836
|
+
|
|
837
|
+
function updateImageElementAttribute($el, parsedStyle) {
|
|
838
|
+
var _parsedStyle$img = parsedStyle.img,
|
|
839
|
+
img = _parsedStyle$img === void 0 ? '' : _parsedStyle$img,
|
|
840
|
+
width = parsedStyle.width,
|
|
841
|
+
height = parsedStyle.height;
|
|
842
|
+
$el.setAttribute('x', '0');
|
|
843
|
+
$el.setAttribute('y', '0');
|
|
844
|
+
|
|
845
|
+
if (g.isString(img)) {
|
|
846
|
+
$el.setAttribute('href', img);
|
|
847
|
+
} else if (img instanceof Image) {
|
|
848
|
+
if (!width) {
|
|
849
|
+
$el.setAttribute('width', "" + img.width); // TODO: set renderable.boundsDirty
|
|
850
|
+
// this.attr('width', img.width);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
if (!height) {
|
|
854
|
+
$el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
$el.setAttribute('href', img.src);
|
|
858
|
+
} else if ( // @ts-ignore
|
|
859
|
+
img instanceof HTMLElement && g.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
|
|
860
|
+
$el.setAttribute('href', img.toDataURL()); // @ts-ignore
|
|
861
|
+
} else if (img instanceof ImageData) {
|
|
862
|
+
var canvas = document.createElement('canvas'); // @ts-ignore
|
|
863
|
+
|
|
864
|
+
canvas.setAttribute('width', "" + img.width); // @ts-ignore
|
|
865
|
+
|
|
866
|
+
canvas.setAttribute('height', "" + img.height);
|
|
867
|
+
var context = canvas.getContext('2d');
|
|
868
|
+
|
|
869
|
+
if (context) {
|
|
870
|
+
context.putImageData(img, 0, 0);
|
|
871
|
+
|
|
872
|
+
if (!width) {
|
|
873
|
+
// @ts-ignore
|
|
874
|
+
$el.setAttribute('width', "" + img.width); // this.attr('width', img.width);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
if (!height) {
|
|
878
|
+
// @ts-ignore
|
|
879
|
+
$el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
$el.setAttribute('href', canvas.toDataURL());
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
function updateLineElementAttribute($el, parsedStyle) {
|
|
888
|
+
var x1 = parsedStyle.x1,
|
|
889
|
+
y1 = parsedStyle.y1,
|
|
890
|
+
x2 = parsedStyle.x2,
|
|
891
|
+
y2 = parsedStyle.y2,
|
|
892
|
+
_parsedStyle$defX = parsedStyle.defX,
|
|
893
|
+
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
894
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
895
|
+
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
|
|
896
|
+
stroke = parsedStyle.stroke;
|
|
897
|
+
$el.setAttribute('x1', "" + (x1.value - x));
|
|
898
|
+
$el.setAttribute('y1', "" + (y1.value - y));
|
|
899
|
+
$el.setAttribute('x2', "" + (x2.value - x)); // fix horizontal line stroke url bug in Chrome
|
|
900
|
+
// @see https://stackoverflow.com/questions/14680240/did-chrome-break-svg-stroke-url
|
|
901
|
+
|
|
902
|
+
if (y1.value === y2.value && stroke && !(stroke instanceof g.CSSRGB)) {
|
|
903
|
+
$el.setAttribute('y2', "" + (y2.value - y + 0.00001));
|
|
904
|
+
} else {
|
|
905
|
+
$el.setAttribute('y2', "" + (y2.value - y));
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
function updatePathElementAttribute($el, parsedStyle) {
|
|
910
|
+
var path = parsedStyle.path,
|
|
911
|
+
_parsedStyle$defX = parsedStyle.defX,
|
|
912
|
+
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
913
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
914
|
+
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
915
|
+
$el.setAttribute('d', formatPath(path.absolutePath, x, y));
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
function formatPath(value, x, y) {
|
|
919
|
+
var newValue = value.map(function (params) {
|
|
920
|
+
var command = params[0];
|
|
921
|
+
|
|
922
|
+
switch (command) {
|
|
923
|
+
case 'M':
|
|
924
|
+
return "M " + (params[1] - x) + "," + (params[2] - y);
|
|
925
|
+
|
|
926
|
+
case 'L':
|
|
927
|
+
return "L " + (params[1] - x) + "," + (params[2] - y);
|
|
928
|
+
|
|
929
|
+
case 'Q':
|
|
930
|
+
return "Q " + (params[1] - x) + " " + (params[2] - y) + "," + (params[3] - x) + " " + (params[4] - y);
|
|
931
|
+
|
|
932
|
+
case 'C':
|
|
933
|
+
return "C " + (params[1] - x) + " " + (params[2] - y) + "," + (params[3] - x) + " " + (params[4] - y) + "," + (params[5] - x) + " " + (params[6] - y);
|
|
934
|
+
|
|
935
|
+
case 'A':
|
|
936
|
+
return "A " + params[1] + " " + params[2] + " " + params[3] + " " + params[4] + " " + params[5] + " " + (params[6] - x) + " " + (params[7] - y);
|
|
937
|
+
|
|
938
|
+
case 'Z':
|
|
939
|
+
return 'Z';
|
|
940
|
+
}
|
|
941
|
+
}).join(' ');
|
|
942
|
+
|
|
943
|
+
if (~newValue.indexOf('NaN')) {
|
|
944
|
+
return '';
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
return newValue;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
function updatePolylineElementAttribute($el, parsedStyle) {
|
|
951
|
+
var points = parsedStyle.points,
|
|
952
|
+
_parsedStyle$defX = parsedStyle.defX,
|
|
953
|
+
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
954
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
955
|
+
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
956
|
+
|
|
957
|
+
if (points && points.points && points.points.length >= 2) {
|
|
958
|
+
$el.setAttribute('points', points.points.map(function (point) {
|
|
959
|
+
return point[0] - x + "," + (point[1] - y);
|
|
960
|
+
}).join(' '));
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
function updateRectElementAttribute($el, parsedStyle) {
|
|
965
|
+
var radius = parsedStyle.radius,
|
|
966
|
+
width = parsedStyle.width,
|
|
967
|
+
height = parsedStyle.height;
|
|
968
|
+
var hasRadius = radius && radius.some(function (r) {
|
|
969
|
+
return r.value !== 0;
|
|
970
|
+
});
|
|
971
|
+
var d = '';
|
|
972
|
+
|
|
973
|
+
if (!hasRadius) {
|
|
974
|
+
d = "M 0,0 l " + width.value + ",0 l 0," + height.value + " l" + -width.value + " 0 z";
|
|
975
|
+
} else {
|
|
976
|
+
var _radius$map = radius.map(function (r) {
|
|
977
|
+
return r.value;
|
|
978
|
+
}),
|
|
979
|
+
tlr = _radius$map[0],
|
|
980
|
+
trr = _radius$map[1],
|
|
981
|
+
brr = _radius$map[2],
|
|
982
|
+
blr = _radius$map[3];
|
|
983
|
+
|
|
984
|
+
d = [["M " + tlr + ",0"], ["l " + (width.value - tlr - trr) + ",0"], ["a " + trr + "," + trr + ",0,0,1," + trr + "," + trr], ["l 0," + (height.value - trr - brr)], ["a " + brr + "," + brr + ",0,0,1," + -brr + "," + brr], ["l " + (brr + blr - width.value) + ",0"], ["a " + blr + "," + blr + ",0,0,1," + -blr + "," + -blr], ["l 0," + (blr + tlr - height.value)], ["a " + tlr + "," + tlr + ",0,0,1," + tlr + "," + -tlr], ['z']].join(' ');
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
$el.setAttribute('d', d);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
function numberToLongString(x) {
|
|
991
|
+
return x.toFixed(6).replace('.000000', '');
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
function convertHTML(str) {
|
|
995
|
+
var regex = /[&|<|>|"|']/g;
|
|
996
|
+
return str.replace(regex, function (match) {
|
|
997
|
+
if (match === '&') {
|
|
998
|
+
return '&';
|
|
999
|
+
} else if (match === '<') {
|
|
1000
|
+
return '<';
|
|
1001
|
+
} else if (match === '>') {
|
|
1002
|
+
return '>';
|
|
1003
|
+
} else if (match === '"') {
|
|
1004
|
+
return '"';
|
|
1005
|
+
} else {
|
|
1006
|
+
return ''';
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
var BASELINE_MAP = {
|
|
1012
|
+
top: 'before-edge',
|
|
1013
|
+
middle: 'central',
|
|
1014
|
+
bottom: 'after-edge',
|
|
1015
|
+
alphabetic: 'alphabetic',
|
|
1016
|
+
ideographic: 'ideographic',
|
|
1017
|
+
hanging: 'hanging'
|
|
1018
|
+
}; // for FireFox
|
|
1019
|
+
// @see https://github.com/plouc/nivo/issues/164
|
|
1020
|
+
|
|
1021
|
+
var BASELINE_MAP_FOR_FIREFOX = {
|
|
1022
|
+
top: 'text-before-edge',
|
|
1023
|
+
middle: 'central',
|
|
1024
|
+
bottom: 'text-after-edge',
|
|
1025
|
+
alphabetic: 'alphabetic',
|
|
1026
|
+
ideographic: 'ideographic',
|
|
1027
|
+
hanging: 'hanging'
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
function updateTextElementAttribute($el, parsedStyle) {
|
|
1031
|
+
var textBaseline = parsedStyle.textBaseline,
|
|
1032
|
+
lineWidth = parsedStyle.lineWidth,
|
|
1033
|
+
metrics = parsedStyle.metrics,
|
|
1034
|
+
dx = parsedStyle.dx,
|
|
1035
|
+
dy = parsedStyle.dy;
|
|
1036
|
+
var browser = detect();
|
|
1037
|
+
|
|
1038
|
+
if (browser && browser.name === 'firefox') {
|
|
1039
|
+
// compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119
|
|
1040
|
+
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value] || 'alphabetic');
|
|
1041
|
+
} else {
|
|
1042
|
+
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value]);
|
|
1043
|
+
$el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline.value]);
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
$el.setAttribute('paint-order', 'stroke');
|
|
1047
|
+
var lines = metrics.lines,
|
|
1048
|
+
lineHeight = metrics.lineHeight,
|
|
1049
|
+
height = metrics.height;
|
|
1050
|
+
var lineNum = lines.length;
|
|
1051
|
+
$el.setAttribute('style', "transform:translate(" + dx.toString() + ", " + dy.toString() + ");");
|
|
1052
|
+
|
|
1053
|
+
if (lineNum === 1) {
|
|
1054
|
+
$el.innerHTML = convertHTML(lines[0]);
|
|
1055
|
+
$el.setAttribute('dx', "" + lineWidth.value / 2);
|
|
1056
|
+
} else {
|
|
1057
|
+
$el.innerHTML = lines.map(function (line, i) {
|
|
1058
|
+
var dx = lineWidth.value / 2;
|
|
1059
|
+
var dy = 0;
|
|
1060
|
+
|
|
1061
|
+
if (i === 0) {
|
|
1062
|
+
// TODO: handle other textBaseline values
|
|
1063
|
+
if (textBaseline.value === 'middle') {
|
|
1064
|
+
dy = lineHeight / 2 - height / 2;
|
|
1065
|
+
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
1066
|
+
dy = 0;
|
|
1067
|
+
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
1068
|
+
dy = -lineHeight * (lineNum - 1);
|
|
1069
|
+
}
|
|
1070
|
+
} else {
|
|
1071
|
+
dy = lineHeight;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
return "<tspan x=\"0\" dx=\"" + dx + "\" dy=\"" + dy + "\">" + convertHTML(line) + "</tspan>";
|
|
1075
|
+
}).join('');
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
var CreateElementContribution = manaSyringe.Syringe.defineToken('CreateElementContribution', {
|
|
1080
|
+
multiple: false
|
|
1081
|
+
});
|
|
1082
|
+
|
|
1083
|
+
function createSVGElement(type, doc) {
|
|
1084
|
+
return (doc || document).createElementNS('http://www.w3.org/2000/svg', type);
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
var _SHAPE2TAGS, _SHAPE_UPDATE_DEPS;
|
|
1088
|
+
|
|
1089
|
+
var SHAPE2TAGS = (_SHAPE2TAGS = {}, _SHAPE2TAGS[g.Shape.RECT] = 'path', _SHAPE2TAGS[g.Shape.CIRCLE] = 'circle', _SHAPE2TAGS[g.Shape.ELLIPSE] = 'ellipse', _SHAPE2TAGS[g.Shape.IMAGE] = 'image', _SHAPE2TAGS[g.Shape.GROUP] = 'g', _SHAPE2TAGS[g.Shape.LINE] = 'line', _SHAPE2TAGS[g.Shape.POLYLINE] = 'polyline', _SHAPE2TAGS[g.Shape.POLYGON] = 'polygon', _SHAPE2TAGS[g.Shape.TEXT] = 'text', _SHAPE2TAGS[g.Shape.PATH] = 'path', _SHAPE2TAGS[g.Shape.HTML] = 'foreignObject', _SHAPE2TAGS);
|
|
1090
|
+
var SHAPE_UPDATE_DEPS = (_SHAPE_UPDATE_DEPS = {}, _SHAPE_UPDATE_DEPS[g.Shape.CIRCLE] = ['r'], _SHAPE_UPDATE_DEPS[g.Shape.ELLIPSE] = ['rx', 'ry'], _SHAPE_UPDATE_DEPS[g.Shape.RECT] = ['width', 'height', 'radius'], _SHAPE_UPDATE_DEPS[g.Shape.IMAGE] = ['img', 'width', 'height'], _SHAPE_UPDATE_DEPS[g.Shape.LINE] = ['x1', 'y1', 'x2', 'y2'], _SHAPE_UPDATE_DEPS[g.Shape.POLYLINE] = ['points'], _SHAPE_UPDATE_DEPS[g.Shape.POLYGON] = ['points'], _SHAPE_UPDATE_DEPS[g.Shape.PATH] = ['path'], _SHAPE_UPDATE_DEPS[g.Shape.TEXT] = ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'whiteSpace', 'dx', 'dy'], _SHAPE_UPDATE_DEPS);
|
|
1091
|
+
|
|
1092
|
+
var DefaultCreateElementContribution = /*#__PURE__*/function () {
|
|
1093
|
+
function DefaultCreateElementContribution() {
|
|
1094
|
+
this.canvasConfig = void 0;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
var _proto = DefaultCreateElementContribution.prototype;
|
|
1098
|
+
|
|
1099
|
+
_proto.createElement = function createElement(object) {
|
|
1100
|
+
var doc = this.canvasConfig.document;
|
|
1101
|
+
var type = SHAPE2TAGS[object.nodeName] || 'g';
|
|
1102
|
+
return createSVGElement(type, doc || document);
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1105
|
+
_proto.shouldUpdateElementAttribute = function shouldUpdateElementAttribute(object, attributeName) {
|
|
1106
|
+
var nodeName = object.nodeName;
|
|
1107
|
+
return (SHAPE_UPDATE_DEPS[nodeName] || []).indexOf(attributeName) > -1;
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
_proto.updateElementAttribute = function updateElementAttribute(object) {
|
|
1111
|
+
// @ts-ignore
|
|
1112
|
+
var $el = object.elementSVG.$el;
|
|
1113
|
+
var nodeName = object.nodeName,
|
|
1114
|
+
parsedStyle = object.parsedStyle;
|
|
1115
|
+
|
|
1116
|
+
switch (nodeName) {
|
|
1117
|
+
case g.Shape.IMAGE:
|
|
1118
|
+
{
|
|
1119
|
+
updateImageElementAttribute($el, parsedStyle);
|
|
1120
|
+
break;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
case g.Shape.RECT:
|
|
1124
|
+
{
|
|
1125
|
+
updateRectElementAttribute($el, parsedStyle);
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
case g.Shape.LINE:
|
|
1130
|
+
{
|
|
1131
|
+
updateLineElementAttribute($el, parsedStyle);
|
|
1132
|
+
break;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
case g.Shape.POLYGON:
|
|
1136
|
+
case g.Shape.POLYLINE:
|
|
1137
|
+
{
|
|
1138
|
+
updatePolylineElementAttribute($el, parsedStyle);
|
|
1139
|
+
break;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
case g.Shape.PATH:
|
|
1143
|
+
{
|
|
1144
|
+
updatePathElementAttribute($el, parsedStyle);
|
|
1145
|
+
break;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
case g.Shape.TEXT:
|
|
1149
|
+
{
|
|
1150
|
+
updateTextElementAttribute($el, parsedStyle);
|
|
1151
|
+
break;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
};
|
|
1155
|
+
|
|
1156
|
+
return DefaultCreateElementContribution;
|
|
1157
|
+
}();
|
|
1158
|
+
|
|
1159
|
+
__decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], DefaultCreateElementContribution.prototype, "canvasConfig", void 0);
|
|
1160
|
+
|
|
1161
|
+
DefaultCreateElementContribution = __decorate([manaSyringe.singleton({
|
|
1162
|
+
token: CreateElementContribution
|
|
1163
|
+
})], DefaultCreateElementContribution);
|
|
1164
|
+
|
|
964
1165
|
function _regeneratorRuntime$1() {
|
|
965
1166
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
966
1167
|
_regeneratorRuntime$1 = function _regeneratorRuntime() {
|
|
@@ -1086,7 +1287,7 @@
|
|
|
1086
1287
|
if ("throw" !== record.type) {
|
|
1087
1288
|
var result = record.arg,
|
|
1088
1289
|
value = result.value;
|
|
1089
|
-
return value && "object" ==
|
|
1290
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1090
1291
|
invoke("next", value, resolve, reject);
|
|
1091
1292
|
}, function (err) {
|
|
1092
1293
|
invoke("throw", err, resolve, reject);
|
|
@@ -1338,467 +1539,21 @@
|
|
|
1338
1539
|
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
1339
1540
|
}
|
|
1340
1541
|
|
|
1341
|
-
function _throw(err) {
|
|
1342
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
_next(undefined);
|
|
1346
|
-
});
|
|
1347
|
-
};
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
function _classCallCheck$2(instance, Constructor) {
|
|
1351
|
-
if (!(instance instanceof Constructor)) {
|
|
1352
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
function _defineProperties$2(target, props) {
|
|
1357
|
-
for (var i = 0; i < props.length; i++) {
|
|
1358
|
-
var descriptor = props[i];
|
|
1359
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
1360
|
-
descriptor.configurable = true;
|
|
1361
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
1362
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
function _createClass$2(Constructor, protoProps, staticProps) {
|
|
1367
|
-
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
1368
|
-
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
1369
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
1370
|
-
writable: false
|
|
1371
|
-
});
|
|
1372
|
-
return Constructor;
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
function _defineProperty(obj, key, value) {
|
|
1376
|
-
if (key in obj) {
|
|
1377
|
-
Object.defineProperty(obj, key, {
|
|
1378
|
-
value: value,
|
|
1379
|
-
enumerable: true,
|
|
1380
|
-
configurable: true,
|
|
1381
|
-
writable: true
|
|
1382
|
-
});
|
|
1383
|
-
} else {
|
|
1384
|
-
obj[key] = value;
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
return obj;
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
function _slicedToArray(arr, i) {
|
|
1391
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
function _arrayWithHoles(arr) {
|
|
1395
|
-
if (Array.isArray(arr)) return arr;
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
function _iterableToArrayLimit(arr, i) {
|
|
1399
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1400
|
-
|
|
1401
|
-
if (_i == null) return;
|
|
1402
|
-
var _arr = [];
|
|
1403
|
-
var _n = true;
|
|
1404
|
-
var _d = false;
|
|
1405
|
-
|
|
1406
|
-
var _s, _e;
|
|
1407
|
-
|
|
1408
|
-
try {
|
|
1409
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
1410
|
-
_arr.push(_s.value);
|
|
1411
|
-
|
|
1412
|
-
if (i && _arr.length === i) break;
|
|
1413
|
-
}
|
|
1414
|
-
} catch (err) {
|
|
1415
|
-
_d = true;
|
|
1416
|
-
_e = err;
|
|
1417
|
-
} finally {
|
|
1418
|
-
try {
|
|
1419
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
1420
|
-
} finally {
|
|
1421
|
-
if (_d) throw _e;
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
return _arr;
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
1429
|
-
if (!o) return;
|
|
1430
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1431
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1432
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1433
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1434
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
function _arrayLikeToArray(arr, len) {
|
|
1438
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
1439
|
-
|
|
1440
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1441
|
-
arr2[i] = arr[i];
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
return arr2;
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
function _nonIterableRest() {
|
|
1448
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
var ElementSVG = /*#__PURE__*/_createClass$2(function ElementSVG() {
|
|
1452
|
-
_classCallCheck$2(this, ElementSVG);
|
|
1453
|
-
|
|
1454
|
-
this.$el = void 0;
|
|
1455
|
-
this.$groupEl = void 0;
|
|
1456
|
-
this.$hitTestingEl = void 0;
|
|
1457
|
-
});
|
|
1458
|
-
|
|
1459
|
-
ElementSVG.tag = 'c-svg-element';
|
|
1460
|
-
|
|
1461
|
-
var RectRenderer = /*#__PURE__*/function () {
|
|
1462
|
-
function RectRenderer() {
|
|
1463
|
-
_classCallCheck$2(this, RectRenderer);
|
|
1464
|
-
|
|
1465
|
-
this.dependencies = ['radius', 'width', 'height'];
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1468
|
-
_createClass$2(RectRenderer, [{
|
|
1469
|
-
key: "apply",
|
|
1470
|
-
value: function apply($el, parsedStyle) {
|
|
1471
|
-
var radius = parsedStyle.radius,
|
|
1472
|
-
width = parsedStyle.width,
|
|
1473
|
-
height = parsedStyle.height;
|
|
1474
|
-
var hasRadius = radius && radius.some(function (r) {
|
|
1475
|
-
return r.value !== 0;
|
|
1476
|
-
});
|
|
1477
|
-
var d = '';
|
|
1478
|
-
|
|
1479
|
-
if (!hasRadius) {
|
|
1480
|
-
d = "M 0,0 l ".concat(width.value, ",0 l 0,").concat(height.value, " l").concat(-width.value, " 0 z");
|
|
1481
|
-
} else {
|
|
1482
|
-
var _radius$map = radius.map(function (r) {
|
|
1483
|
-
return r.value;
|
|
1484
|
-
}),
|
|
1485
|
-
_radius$map2 = _slicedToArray(_radius$map, 4),
|
|
1486
|
-
tlr = _radius$map2[0],
|
|
1487
|
-
trr = _radius$map2[1],
|
|
1488
|
-
brr = _radius$map2[2],
|
|
1489
|
-
blr = _radius$map2[3];
|
|
1490
|
-
|
|
1491
|
-
d = [["M ".concat(tlr, ",0")], ["l ".concat(width.value - tlr - trr, ",0")], ["a ".concat(trr, ",").concat(trr, ",0,0,1,").concat(trr, ",").concat(trr)], ["l 0,".concat(height.value - trr - brr)], ["a ".concat(brr, ",").concat(brr, ",0,0,1,").concat(-brr, ",").concat(brr)], ["l ".concat(brr + blr - width.value, ",0")], ["a ".concat(blr, ",").concat(blr, ",0,0,1,").concat(-blr, ",").concat(-blr)], ["l 0,".concat(blr + tlr - height.value)], ["a ".concat(tlr, ",").concat(tlr, ",0,0,1,").concat(tlr, ",").concat(-tlr)], ['z']].join(' ');
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
$el.setAttribute('d', d);
|
|
1495
|
-
}
|
|
1496
|
-
}]);
|
|
1497
|
-
|
|
1498
|
-
return RectRenderer;
|
|
1499
|
-
}();
|
|
1500
|
-
|
|
1501
|
-
RectRenderer = __decorate([manaSyringe.singleton()], RectRenderer);
|
|
1502
|
-
|
|
1503
|
-
var ImageRenderer = /*#__PURE__*/function () {
|
|
1504
|
-
function ImageRenderer() {
|
|
1505
|
-
_classCallCheck$2(this, ImageRenderer);
|
|
1506
|
-
|
|
1507
|
-
this.dependencies = ['img', 'width', 'height'];
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
_createClass$2(ImageRenderer, [{
|
|
1511
|
-
key: "apply",
|
|
1512
|
-
value: function apply($el, parsedStyle) {
|
|
1513
|
-
var _parsedStyle$img = parsedStyle.img,
|
|
1514
|
-
img = _parsedStyle$img === void 0 ? '' : _parsedStyle$img,
|
|
1515
|
-
width = parsedStyle.width,
|
|
1516
|
-
height = parsedStyle.height;
|
|
1517
|
-
$el.setAttribute('x', '0');
|
|
1518
|
-
$el.setAttribute('y', '0');
|
|
1519
|
-
|
|
1520
|
-
if (g.isString(img)) {
|
|
1521
|
-
$el.setAttribute('href', img);
|
|
1522
|
-
} else if (img instanceof Image) {
|
|
1523
|
-
if (!width) {
|
|
1524
|
-
$el.setAttribute('width', "".concat(img.width)); // TODO: set renderable.boundsDirty
|
|
1525
|
-
// this.attr('width', img.width);
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
if (!height) {
|
|
1529
|
-
$el.setAttribute('height', "".concat(img.height)); // this.attr('height', img.height);
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
$el.setAttribute('href', img.src);
|
|
1533
|
-
} else if ( // @ts-ignore
|
|
1534
|
-
img instanceof HTMLElement && g.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
|
|
1535
|
-
$el.setAttribute('href', img.toDataURL()); // @ts-ignore
|
|
1536
|
-
} else if (img instanceof ImageData) {
|
|
1537
|
-
var canvas = document.createElement('canvas'); // @ts-ignore
|
|
1538
|
-
|
|
1539
|
-
canvas.setAttribute('width', "".concat(img.width)); // @ts-ignore
|
|
1540
|
-
|
|
1541
|
-
canvas.setAttribute('height', "".concat(img.height));
|
|
1542
|
-
var context = canvas.getContext('2d');
|
|
1543
|
-
|
|
1544
|
-
if (context) {
|
|
1545
|
-
context.putImageData(img, 0, 0);
|
|
1546
|
-
|
|
1547
|
-
if (!width) {
|
|
1548
|
-
// @ts-ignore
|
|
1549
|
-
$el.setAttribute('width', "".concat(img.width)); // this.attr('width', img.width);
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
if (!height) {
|
|
1553
|
-
// @ts-ignore
|
|
1554
|
-
$el.setAttribute('height', "".concat(img.height)); // this.attr('height', img.height);
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
$el.setAttribute('href', canvas.toDataURL());
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
}]);
|
|
1562
|
-
|
|
1563
|
-
return ImageRenderer;
|
|
1564
|
-
}();
|
|
1565
|
-
|
|
1566
|
-
ImageRenderer = __decorate([manaSyringe.singleton()], ImageRenderer);
|
|
1567
|
-
|
|
1568
|
-
var LineRenderer = /*#__PURE__*/function () {
|
|
1569
|
-
function LineRenderer() {
|
|
1570
|
-
_classCallCheck$2(this, LineRenderer);
|
|
1571
|
-
|
|
1572
|
-
this.dependencies = ['x1', 'y1', 'x2', 'y2'];
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
|
-
_createClass$2(LineRenderer, [{
|
|
1576
|
-
key: "apply",
|
|
1577
|
-
value: function apply($el, parsedStyle) {
|
|
1578
|
-
var x1 = parsedStyle.x1,
|
|
1579
|
-
y1 = parsedStyle.y1,
|
|
1580
|
-
x2 = parsedStyle.x2,
|
|
1581
|
-
y2 = parsedStyle.y2,
|
|
1582
|
-
_parsedStyle$defX = parsedStyle.defX,
|
|
1583
|
-
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1584
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
1585
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
|
|
1586
|
-
stroke = parsedStyle.stroke;
|
|
1587
|
-
$el.setAttribute('x1', "".concat(x1.value - x));
|
|
1588
|
-
$el.setAttribute('y1', "".concat(y1.value - y));
|
|
1589
|
-
$el.setAttribute('x2', "".concat(x2.value - x)); // fix horizontal line stroke url bug in Chrome
|
|
1590
|
-
// @see https://stackoverflow.com/questions/14680240/did-chrome-break-svg-stroke-url
|
|
1591
|
-
|
|
1592
|
-
if (y1.value === y2.value && stroke && !(stroke instanceof g.CSSRGB)) {
|
|
1593
|
-
$el.setAttribute('y2', "".concat(y2.value - y + 0.00001));
|
|
1594
|
-
} else {
|
|
1595
|
-
$el.setAttribute('y2', "".concat(y2.value - y));
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
}]);
|
|
1599
|
-
|
|
1600
|
-
return LineRenderer;
|
|
1601
|
-
}();
|
|
1602
|
-
|
|
1603
|
-
LineRenderer = __decorate([manaSyringe.singleton()], LineRenderer);
|
|
1604
|
-
|
|
1605
|
-
var PolylineRenderer = /*#__PURE__*/function () {
|
|
1606
|
-
function PolylineRenderer() {
|
|
1607
|
-
_classCallCheck$2(this, PolylineRenderer);
|
|
1608
|
-
|
|
1609
|
-
this.dependencies = ['points'];
|
|
1610
|
-
}
|
|
1611
|
-
|
|
1612
|
-
_createClass$2(PolylineRenderer, [{
|
|
1613
|
-
key: "apply",
|
|
1614
|
-
value: function apply($el, parsedStyle) {
|
|
1615
|
-
var points = parsedStyle.points,
|
|
1616
|
-
_parsedStyle$defX = parsedStyle.defX,
|
|
1617
|
-
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1618
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
1619
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
1620
|
-
|
|
1621
|
-
if (points && points.points && points.points.length >= 2) {
|
|
1622
|
-
$el.setAttribute('points', points.points.map(function (point) {
|
|
1623
|
-
return "".concat(point[0] - x, ",").concat(point[1] - y);
|
|
1624
|
-
}).join(' '));
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
}]);
|
|
1628
|
-
|
|
1629
|
-
return PolylineRenderer;
|
|
1630
|
-
}();
|
|
1631
|
-
|
|
1632
|
-
PolylineRenderer = __decorate([manaSyringe.singleton()], PolylineRenderer);
|
|
1633
|
-
|
|
1634
|
-
function numberToLongString(x) {
|
|
1635
|
-
return x.toFixed(6).replace('.000000', '');
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
function convertHTML(str) {
|
|
1639
|
-
var regex = /[&|<|>|"|']/g;
|
|
1640
|
-
return str.replace(regex, function (match) {
|
|
1641
|
-
if (match === '&') {
|
|
1642
|
-
return '&';
|
|
1643
|
-
} else if (match === '<') {
|
|
1644
|
-
return '<';
|
|
1645
|
-
} else if (match === '>') {
|
|
1646
|
-
return '>';
|
|
1647
|
-
} else if (match === '"') {
|
|
1648
|
-
return '"';
|
|
1649
|
-
} else {
|
|
1650
|
-
return ''';
|
|
1651
|
-
}
|
|
1652
|
-
});
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
var BASELINE_MAP = {
|
|
1656
|
-
top: 'before-edge',
|
|
1657
|
-
middle: 'central',
|
|
1658
|
-
bottom: 'after-edge',
|
|
1659
|
-
alphabetic: 'alphabetic',
|
|
1660
|
-
ideographic: 'ideographic',
|
|
1661
|
-
hanging: 'hanging'
|
|
1662
|
-
}; // for FireFox
|
|
1663
|
-
// @see https://github.com/plouc/nivo/issues/164
|
|
1664
|
-
|
|
1665
|
-
var BASELINE_MAP_FOR_FIREFOX = {
|
|
1666
|
-
top: 'text-before-edge',
|
|
1667
|
-
middle: 'central',
|
|
1668
|
-
bottom: 'text-after-edge',
|
|
1669
|
-
alphabetic: 'alphabetic',
|
|
1670
|
-
ideographic: 'ideographic',
|
|
1671
|
-
hanging: 'hanging'
|
|
1672
|
-
};
|
|
1673
|
-
|
|
1674
|
-
var TextRenderer = /*#__PURE__*/function () {
|
|
1675
|
-
function TextRenderer() {
|
|
1676
|
-
_classCallCheck$2(this, TextRenderer);
|
|
1677
|
-
|
|
1678
|
-
this.dependencies = ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'whiteSpace', 'dx', 'dy'];
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
_createClass$2(TextRenderer, [{
|
|
1682
|
-
key: "apply",
|
|
1683
|
-
value: function apply($el, parsedStyle) {
|
|
1684
|
-
var textBaseline = parsedStyle.textBaseline,
|
|
1685
|
-
lineWidth = parsedStyle.lineWidth,
|
|
1686
|
-
metrics = parsedStyle.metrics,
|
|
1687
|
-
dx = parsedStyle.dx,
|
|
1688
|
-
dy = parsedStyle.dy;
|
|
1689
|
-
var browser = detect();
|
|
1690
|
-
|
|
1691
|
-
if (browser && browser.name === 'firefox') {
|
|
1692
|
-
// compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119
|
|
1693
|
-
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value] || 'alphabetic');
|
|
1694
|
-
} else {
|
|
1695
|
-
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value]);
|
|
1696
|
-
$el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline.value]);
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
$el.setAttribute('paint-order', 'stroke');
|
|
1700
|
-
var lines = metrics.lines,
|
|
1701
|
-
lineHeight = metrics.lineHeight,
|
|
1702
|
-
height = metrics.height;
|
|
1703
|
-
var lineNum = lines.length;
|
|
1704
|
-
$el.setAttribute('style', "transform:translate(".concat(dx.toString(), ", ").concat(dy.toString(), ");"));
|
|
1705
|
-
|
|
1706
|
-
if (lineNum === 1) {
|
|
1707
|
-
$el.innerHTML = convertHTML(lines[0]);
|
|
1708
|
-
$el.setAttribute('dx', "".concat(lineWidth.value / 2));
|
|
1709
|
-
} else {
|
|
1710
|
-
$el.innerHTML = lines.map(function (line, i) {
|
|
1711
|
-
var dx = lineWidth.value / 2;
|
|
1712
|
-
var dy = 0;
|
|
1713
|
-
|
|
1714
|
-
if (i === 0) {
|
|
1715
|
-
// TODO: handle other textBaseline values
|
|
1716
|
-
if (textBaseline.value === 'middle') {
|
|
1717
|
-
dy = lineHeight / 2 - height / 2;
|
|
1718
|
-
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
1719
|
-
dy = 0;
|
|
1720
|
-
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
1721
|
-
dy = -lineHeight * (lineNum - 1);
|
|
1722
|
-
}
|
|
1723
|
-
} else {
|
|
1724
|
-
dy = lineHeight;
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
|
-
return "<tspan x=\"0\" dx=\"".concat(dx, "\" dy=\"").concat(dy, "\">").concat(convertHTML(line), "</tspan>");
|
|
1728
|
-
}).join('');
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
}]);
|
|
1732
|
-
|
|
1733
|
-
return TextRenderer;
|
|
1734
|
-
}();
|
|
1735
|
-
|
|
1736
|
-
TextRenderer = __decorate([manaSyringe.singleton()], TextRenderer);
|
|
1737
|
-
|
|
1738
|
-
var PathRenderer = /*#__PURE__*/function () {
|
|
1739
|
-
function PathRenderer() {
|
|
1740
|
-
_classCallCheck$2(this, PathRenderer);
|
|
1741
|
-
|
|
1742
|
-
this.dependencies = ['path'];
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
|
-
_createClass$2(PathRenderer, [{
|
|
1746
|
-
key: "apply",
|
|
1747
|
-
value: function apply($el, parsedStyle) {
|
|
1748
|
-
var path = parsedStyle.path,
|
|
1749
|
-
_parsedStyle$defX = parsedStyle.defX,
|
|
1750
|
-
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1751
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
1752
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
1753
|
-
$el.setAttribute('d', this.formatPath(path.absolutePath, x, y));
|
|
1754
|
-
}
|
|
1755
|
-
}, {
|
|
1756
|
-
key: "formatPath",
|
|
1757
|
-
value: function formatPath(value, x, y) {
|
|
1758
|
-
var newValue = value.map(function (params) {
|
|
1759
|
-
var command = params[0];
|
|
1760
|
-
|
|
1761
|
-
switch (command) {
|
|
1762
|
-
case 'M':
|
|
1763
|
-
return "M ".concat(params[1] - x, ",").concat(params[2] - y);
|
|
1764
|
-
|
|
1765
|
-
case 'L':
|
|
1766
|
-
return "L ".concat(params[1] - x, ",").concat(params[2] - y);
|
|
1767
|
-
|
|
1768
|
-
case 'Q':
|
|
1769
|
-
return "Q ".concat(params[1] - x, " ").concat(params[2] - y, ",").concat(params[3] - x, " ").concat(params[4] - y);
|
|
1770
|
-
|
|
1771
|
-
case 'C':
|
|
1772
|
-
return "C ".concat(params[1] - x, " ").concat(params[2] - y, ",").concat(params[3] - x, " ").concat(params[4] - y, ",").concat(params[5] - x, " ").concat(params[6] - y);
|
|
1773
|
-
|
|
1774
|
-
case 'A':
|
|
1775
|
-
return "A ".concat(params[1], " ").concat(params[2], " ").concat(params[3], " ").concat(params[4], " ").concat(params[5], " ").concat(params[6] - x, " ").concat(params[7] - y);
|
|
1776
|
-
|
|
1777
|
-
case 'Z':
|
|
1778
|
-
return 'Z';
|
|
1779
|
-
}
|
|
1780
|
-
}).join(' ');
|
|
1781
|
-
|
|
1782
|
-
if (~newValue.indexOf('NaN')) {
|
|
1783
|
-
return '';
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
return newValue;
|
|
1787
|
-
}
|
|
1788
|
-
}]);
|
|
1789
|
-
|
|
1790
|
-
return PathRenderer;
|
|
1791
|
-
}();
|
|
1542
|
+
function _throw(err) {
|
|
1543
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1544
|
+
}
|
|
1792
1545
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1546
|
+
_next(undefined);
|
|
1547
|
+
});
|
|
1548
|
+
};
|
|
1549
|
+
}
|
|
1796
1550
|
/**
|
|
1797
1551
|
* Common utilities
|
|
1798
1552
|
* @module glMatrix
|
|
1799
1553
|
*/
|
|
1800
1554
|
// Configuration Constants
|
|
1801
1555
|
|
|
1556
|
+
|
|
1802
1557
|
var EPSILON = 0.000001;
|
|
1803
1558
|
var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
|
|
1804
1559
|
if (!Math.hypot) Math.hypot = function () {
|
|
@@ -2451,20 +2206,16 @@
|
|
|
2451
2206
|
};
|
|
2452
2207
|
}();
|
|
2453
2208
|
|
|
2454
|
-
function createSVGElement(type) {
|
|
2455
|
-
return document.createElementNS('http://www.w3.org/2000/svg', type);
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
2209
|
var FILTER_PREFIX = 'g-filter-';
|
|
2459
2210
|
/**
|
|
2460
2211
|
* use SVG filters, eg. blur, brightness, contrast...
|
|
2461
2212
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
2462
2213
|
*/
|
|
2463
2214
|
|
|
2464
|
-
function createOrUpdateFilter($def, object, $el, filters) {
|
|
2215
|
+
function createOrUpdateFilter(document, $def, object, $el, filters) {
|
|
2465
2216
|
// eg. filter="url(#f1) url(#f2)"
|
|
2466
2217
|
var filterName = FILTER_PREFIX + object.entity;
|
|
2467
|
-
var $existedFilters = $def.querySelectorAll("[name="
|
|
2218
|
+
var $existedFilters = $def.querySelectorAll("[name=" + filterName + "]");
|
|
2468
2219
|
|
|
2469
2220
|
if ($existedFilters.length) {
|
|
2470
2221
|
$existedFilters.forEach(function ($filter) {
|
|
@@ -2479,35 +2230,35 @@
|
|
|
2479
2230
|
var filterIds = filters.map(function (_ref, i) {
|
|
2480
2231
|
var name = _ref.name,
|
|
2481
2232
|
params = _ref.params;
|
|
2482
|
-
var $filter = createSVGElement('filter');
|
|
2233
|
+
var $filter = createSVGElement('filter', document);
|
|
2483
2234
|
|
|
2484
2235
|
if (name === 'blur') {
|
|
2485
|
-
createBlur($filter, params);
|
|
2236
|
+
createBlur(document, $filter, params);
|
|
2486
2237
|
} else if (name === 'brightness') {
|
|
2487
|
-
createBrightness($filter, params);
|
|
2238
|
+
createBrightness(document, $filter, params);
|
|
2488
2239
|
} else if (name === 'drop-shadow') {
|
|
2489
|
-
createDropShadow($filter, params);
|
|
2240
|
+
createDropShadow(document, $filter, params);
|
|
2490
2241
|
} else if (name === 'contrast') {
|
|
2491
|
-
createContrast($filter, params);
|
|
2242
|
+
createContrast(document, $filter, params);
|
|
2492
2243
|
} else if (name === 'grayscale') {
|
|
2493
|
-
createGrayscale($filter, params);
|
|
2244
|
+
createGrayscale(document, $filter, params);
|
|
2494
2245
|
} else if (name === 'sepia') {
|
|
2495
|
-
createSepia($filter, params);
|
|
2246
|
+
createSepia(document, $filter, params);
|
|
2496
2247
|
} else if (name === 'saturate') {
|
|
2497
|
-
createSaturate($filter, params);
|
|
2248
|
+
createSaturate(document, $filter, params);
|
|
2498
2249
|
} else if (name === 'hue-rotate') {
|
|
2499
|
-
createHueRotate($filter, params);
|
|
2250
|
+
createHueRotate(document, $filter, params);
|
|
2500
2251
|
} else if (name === 'invert') {
|
|
2501
|
-
createInvert($filter, params);
|
|
2252
|
+
createInvert(document, $filter, params);
|
|
2502
2253
|
}
|
|
2503
2254
|
|
|
2504
|
-
$filter.id =
|
|
2255
|
+
$filter.id = filterName + "-" + i;
|
|
2505
2256
|
$filter.setAttribute('name', filterName);
|
|
2506
2257
|
$def.appendChild($filter);
|
|
2507
2258
|
return $filter.id;
|
|
2508
2259
|
});
|
|
2509
2260
|
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', filterIds.map(function (filterId) {
|
|
2510
|
-
return "url(#"
|
|
2261
|
+
return "url(#" + filterId + ")";
|
|
2511
2262
|
}).join(' '));
|
|
2512
2263
|
}
|
|
2513
2264
|
}
|
|
@@ -2520,27 +2271,27 @@
|
|
|
2520
2271
|
*/
|
|
2521
2272
|
|
|
2522
2273
|
|
|
2523
|
-
function createBlur($filter, params) {
|
|
2524
|
-
var $feGaussianBlur = createSVGElement('feGaussianBlur');
|
|
2274
|
+
function createBlur(document, $filter, params) {
|
|
2275
|
+
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
2525
2276
|
$feGaussianBlur.setAttribute('in', 'SourceGraphic');
|
|
2526
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
2277
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + params[0].value);
|
|
2527
2278
|
$filter.appendChild($feGaussianBlur);
|
|
2528
2279
|
}
|
|
2529
2280
|
|
|
2530
|
-
function createFeComponentTransfer($filter, _ref2) {
|
|
2281
|
+
function createFeComponentTransfer(document, $filter, _ref2) {
|
|
2531
2282
|
var type = _ref2.type,
|
|
2532
2283
|
slope = _ref2.slope,
|
|
2533
2284
|
intercept = _ref2.intercept,
|
|
2534
2285
|
tableValues = _ref2.tableValues;
|
|
2535
|
-
var $feComponentTransfer = createSVGElement('feComponentTransfer');
|
|
2536
|
-
[createSVGElement('feFuncR'), createSVGElement('feFuncG'), createSVGElement('feFuncB')].forEach(function ($feFunc) {
|
|
2286
|
+
var $feComponentTransfer = createSVGElement('feComponentTransfer', document);
|
|
2287
|
+
[createSVGElement('feFuncR', document), createSVGElement('feFuncG', document), createSVGElement('feFuncB', document)].forEach(function ($feFunc) {
|
|
2537
2288
|
$feFunc.setAttribute('type', type);
|
|
2538
2289
|
|
|
2539
2290
|
if (type === 'table') {
|
|
2540
|
-
$feFunc.setAttribute('tableValues', ""
|
|
2291
|
+
$feFunc.setAttribute('tableValues', "" + tableValues);
|
|
2541
2292
|
} else {
|
|
2542
|
-
$feFunc.setAttribute('slope', ""
|
|
2543
|
-
$feFunc.setAttribute('intercept', ""
|
|
2293
|
+
$feFunc.setAttribute('slope', "" + slope);
|
|
2294
|
+
$feFunc.setAttribute('intercept', "" + intercept);
|
|
2544
2295
|
}
|
|
2545
2296
|
|
|
2546
2297
|
$feComponentTransfer.appendChild($feFunc);
|
|
@@ -2548,80 +2299,80 @@
|
|
|
2548
2299
|
$filter.appendChild($feComponentTransfer);
|
|
2549
2300
|
}
|
|
2550
2301
|
|
|
2551
|
-
function createContrast($filter, params) {
|
|
2302
|
+
function createContrast(document, $filter, params) {
|
|
2552
2303
|
var slope = convertToAbsoluteValue(params[0]);
|
|
2553
|
-
createFeComponentTransfer($filter, {
|
|
2304
|
+
createFeComponentTransfer(document, $filter, {
|
|
2554
2305
|
type: 'linear',
|
|
2555
2306
|
slope: slope,
|
|
2556
2307
|
intercept: -(0.5 * slope) + 0.5
|
|
2557
2308
|
});
|
|
2558
2309
|
}
|
|
2559
2310
|
|
|
2560
|
-
function createInvert($filter, params) {
|
|
2311
|
+
function createInvert(document, $filter, params) {
|
|
2561
2312
|
var amount = convertToAbsoluteValue(params[0]);
|
|
2562
|
-
createFeComponentTransfer($filter, {
|
|
2313
|
+
createFeComponentTransfer(document, $filter, {
|
|
2563
2314
|
type: 'table',
|
|
2564
|
-
tableValues:
|
|
2315
|
+
tableValues: amount + " " + (1 - amount)
|
|
2565
2316
|
});
|
|
2566
2317
|
}
|
|
2567
2318
|
|
|
2568
|
-
function createBrightness($filter, params) {
|
|
2319
|
+
function createBrightness(document, $filter, params) {
|
|
2569
2320
|
var slope = convertToAbsoluteValue(params[0]);
|
|
2570
|
-
createFeComponentTransfer($filter, {
|
|
2321
|
+
createFeComponentTransfer(document, $filter, {
|
|
2571
2322
|
type: 'linear',
|
|
2572
2323
|
slope: slope,
|
|
2573
2324
|
intercept: 0
|
|
2574
2325
|
});
|
|
2575
2326
|
}
|
|
2576
2327
|
|
|
2577
|
-
function createSaturate($filter, params) {
|
|
2328
|
+
function createSaturate(document, $filter, params) {
|
|
2578
2329
|
var amount = convertToAbsoluteValue(params[0]);
|
|
2579
|
-
var $feColorMatrix = createSVGElement('feColorMatrix');
|
|
2330
|
+
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
2580
2331
|
$feColorMatrix.setAttribute('type', 'saturate');
|
|
2581
|
-
$feColorMatrix.setAttribute('values', ""
|
|
2332
|
+
$feColorMatrix.setAttribute('values', "" + amount);
|
|
2582
2333
|
$filter.appendChild($feColorMatrix);
|
|
2583
2334
|
}
|
|
2584
2335
|
|
|
2585
|
-
function createHueRotate($filter, params) {
|
|
2586
|
-
var $feColorMatrix = createSVGElement('feColorMatrix');
|
|
2336
|
+
function createHueRotate(document, $filter, params) {
|
|
2337
|
+
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
2587
2338
|
$feColorMatrix.setAttribute('type', 'hueRotate');
|
|
2588
|
-
$feColorMatrix.setAttribute('values', ""
|
|
2339
|
+
$feColorMatrix.setAttribute('values', "" + params[0].to(g.UnitType.kDegrees).value);
|
|
2589
2340
|
$filter.appendChild($feColorMatrix);
|
|
2590
2341
|
}
|
|
2591
2342
|
|
|
2592
|
-
function createDropShadow($filter, params) {
|
|
2343
|
+
function createDropShadow(document, $filter, params) {
|
|
2593
2344
|
var shadowOffsetX = params[0].value;
|
|
2594
2345
|
var shadowOffsetY = params[1].value;
|
|
2595
2346
|
var shadowBlur = params[2].value; // @ts-ignore
|
|
2596
2347
|
|
|
2597
2348
|
var shadowColor = params[3].formatted;
|
|
2598
|
-
var $feGaussianBlur = createSVGElement('feGaussianBlur');
|
|
2349
|
+
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
2599
2350
|
$feGaussianBlur.setAttribute('in', 'SourceAlpha');
|
|
2600
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
2351
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + shadowBlur);
|
|
2601
2352
|
$filter.appendChild($feGaussianBlur);
|
|
2602
|
-
var $feOffset = createSVGElement('feOffset');
|
|
2603
|
-
$feOffset.setAttribute('dx', ""
|
|
2604
|
-
$feOffset.setAttribute('dy', ""
|
|
2353
|
+
var $feOffset = createSVGElement('feOffset', document);
|
|
2354
|
+
$feOffset.setAttribute('dx', "" + shadowOffsetX);
|
|
2355
|
+
$feOffset.setAttribute('dy', "" + shadowOffsetY);
|
|
2605
2356
|
$feOffset.setAttribute('result', 'offsetblur');
|
|
2606
2357
|
$filter.appendChild($feOffset);
|
|
2607
|
-
var $feFlood = createSVGElement('feFlood');
|
|
2358
|
+
var $feFlood = createSVGElement('feFlood', document);
|
|
2608
2359
|
$feFlood.setAttribute('flood-color', shadowColor);
|
|
2609
2360
|
$filter.appendChild($feFlood);
|
|
2610
|
-
var $feComposite = createSVGElement('feComposite');
|
|
2361
|
+
var $feComposite = createSVGElement('feComposite', document);
|
|
2611
2362
|
$feComposite.setAttribute('in2', 'offsetblur');
|
|
2612
2363
|
$feComposite.setAttribute('operator', 'in');
|
|
2613
2364
|
$filter.appendChild($feComposite);
|
|
2614
|
-
var $feMerge = createSVGElement('feMerge');
|
|
2365
|
+
var $feMerge = createSVGElement('feMerge', document);
|
|
2615
2366
|
$filter.appendChild($feMerge);
|
|
2616
|
-
var $feMergeNode1 = createSVGElement('feMergeNode');
|
|
2617
|
-
var $feMergeNode2 = createSVGElement('feMergeNode');
|
|
2367
|
+
var $feMergeNode1 = createSVGElement('feMergeNode', document);
|
|
2368
|
+
var $feMergeNode2 = createSVGElement('feMergeNode', document);
|
|
2618
2369
|
$feMergeNode2.setAttribute('in', 'SourceGraphic');
|
|
2619
2370
|
$feMerge.appendChild($feMergeNode1);
|
|
2620
2371
|
$feMerge.appendChild($feMergeNode2);
|
|
2621
2372
|
}
|
|
2622
2373
|
|
|
2623
|
-
function createFeColorMatrix($filter, matrix) {
|
|
2624
|
-
var $feColorMatrix = createSVGElement('feColorMatrix');
|
|
2374
|
+
function createFeColorMatrix(document, $filter, matrix) {
|
|
2375
|
+
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
2625
2376
|
$feColorMatrix.setAttribute('type', 'matrix');
|
|
2626
2377
|
$feColorMatrix.setAttribute('values', matrix.join(' '));
|
|
2627
2378
|
$filter.appendChild($feColorMatrix);
|
|
@@ -2631,31 +2382,31 @@
|
|
|
2631
2382
|
*/
|
|
2632
2383
|
|
|
2633
2384
|
|
|
2634
|
-
function createGrayscale($filter, params) {
|
|
2385
|
+
function createGrayscale(document, $filter, params) {
|
|
2635
2386
|
var amount = convertToAbsoluteValue(params[0]);
|
|
2636
|
-
createFeColorMatrix($filter, [0.2126 + 0.7874 * (1 - amount), 0.7152 - 0.7152 * (1 - amount), 0.0722 - 0.0722 * (1 - amount), 0, 0, 0.2126 - 0.2126 * (1 - amount), 0.7152 + 0.2848 * (1 - amount), 0.0722 - 0.0722 * (1 - amount), 0, 0, 0.2126 - 0.2126 * (1 - amount), 0.7152 - 0.7152 * (1 - amount), 0.0722 + 0.9278 * (1 - amount), 0, 0, 0, 0, 0, 1, 0]);
|
|
2387
|
+
createFeColorMatrix(document, $filter, [0.2126 + 0.7874 * (1 - amount), 0.7152 - 0.7152 * (1 - amount), 0.0722 - 0.0722 * (1 - amount), 0, 0, 0.2126 - 0.2126 * (1 - amount), 0.7152 + 0.2848 * (1 - amount), 0.0722 - 0.0722 * (1 - amount), 0, 0, 0.2126 - 0.2126 * (1 - amount), 0.7152 - 0.7152 * (1 - amount), 0.0722 + 0.9278 * (1 - amount), 0, 0, 0, 0, 0, 1, 0]);
|
|
2637
2388
|
}
|
|
2638
2389
|
/**
|
|
2639
2390
|
* @see https://drafts.fxtf.org/filter-effects/#sepiaEquivalent
|
|
2640
2391
|
*/
|
|
2641
2392
|
|
|
2642
2393
|
|
|
2643
|
-
function createSepia($filter, params) {
|
|
2394
|
+
function createSepia(document, $filter, params) {
|
|
2644
2395
|
var amount = convertToAbsoluteValue(params[0]);
|
|
2645
|
-
createFeColorMatrix($filter, [0.393 + 0.607 * (1 - amount), 0.769 - 0.769 * (1 - amount), 0.189 - 0.189 * (1 - amount), 0, 0, 0.349 - 0.349 * (1 - amount), 0.686 + 0.314 * (1 - amount), 0.168 - 0.168 * (1 - amount), 0, 0, 0.272 - 0.272 * (1 - amount), 0.534 - 0.534 * (1 - amount), 0.131 + 0.869 * (1 - amount), 0, 0, 0, 0, 0, 1, 0]);
|
|
2396
|
+
createFeColorMatrix(document, $filter, [0.393 + 0.607 * (1 - amount), 0.769 - 0.769 * (1 - amount), 0.189 - 0.189 * (1 - amount), 0, 0, 0.349 - 0.349 * (1 - amount), 0.686 + 0.314 * (1 - amount), 0.168 - 0.168 * (1 - amount), 0, 0, 0.272 - 0.272 * (1 - amount), 0.534 - 0.534 * (1 - amount), 0.131 + 0.869 * (1 - amount), 0, 0, 0, 0, 0, 1, 0]);
|
|
2646
2397
|
}
|
|
2647
2398
|
|
|
2648
2399
|
var cacheKey2IDMap = {};
|
|
2649
2400
|
var counter = 0;
|
|
2650
2401
|
|
|
2651
|
-
function createOrUpdateGradientAndPattern($def, object, $el, parsedColor, name) {
|
|
2402
|
+
function createOrUpdateGradientAndPattern(document, $def, object, $el, parsedColor, name) {
|
|
2652
2403
|
// eg. clipPath don't have fill/stroke
|
|
2653
2404
|
if (!parsedColor) {
|
|
2654
2405
|
return;
|
|
2655
2406
|
}
|
|
2656
2407
|
|
|
2657
2408
|
var gradientId = generateCacheKey(parsedColor);
|
|
2658
|
-
var existed = $def.querySelector("#"
|
|
2409
|
+
var existed = $def.querySelector("#" + gradientId);
|
|
2659
2410
|
|
|
2660
2411
|
if (parsedColor instanceof g.CSSRGB) {
|
|
2661
2412
|
// keep using currentColor @see https://github.com/d3/d3-axis/issues/49
|
|
@@ -2668,16 +2419,16 @@
|
|
|
2668
2419
|
} else {
|
|
2669
2420
|
if (parsedColor.type === g.GradientPatternType.Pattern) {
|
|
2670
2421
|
if (!existed) {
|
|
2671
|
-
createPattern($def, parsedColor, gradientId);
|
|
2422
|
+
createPattern(document, $def, parsedColor, gradientId);
|
|
2672
2423
|
}
|
|
2673
2424
|
|
|
2674
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#"
|
|
2425
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
|
|
2675
2426
|
} else {
|
|
2676
2427
|
if (!existed) {
|
|
2677
|
-
createGradient($def, parsedColor, gradientId);
|
|
2428
|
+
createGradient(document, $def, parsedColor, gradientId);
|
|
2678
2429
|
}
|
|
2679
2430
|
|
|
2680
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#"
|
|
2431
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
|
|
2681
2432
|
}
|
|
2682
2433
|
}
|
|
2683
2434
|
}
|
|
@@ -2700,14 +2451,14 @@
|
|
|
2700
2451
|
y1 = _params$value.y1,
|
|
2701
2452
|
r1 = _params$value.r1,
|
|
2702
2453
|
steps = _params$value.steps;
|
|
2703
|
-
cacheKey = ""
|
|
2454
|
+
cacheKey = "" + type + x0 + y0 + x1 + y1 + (r1 || 0) + steps.map(function (step) {
|
|
2704
2455
|
return step.join('');
|
|
2705
|
-
}).join('')
|
|
2456
|
+
}).join('');
|
|
2706
2457
|
}
|
|
2707
2458
|
|
|
2708
2459
|
if (cacheKey) {
|
|
2709
2460
|
if (!cacheKey2IDMap[cacheKey]) {
|
|
2710
|
-
cacheKey2IDMap[cacheKey] = "_pattern_"
|
|
2461
|
+
cacheKey2IDMap[cacheKey] = "_pattern_" + type + "_" + counter++;
|
|
2711
2462
|
}
|
|
2712
2463
|
}
|
|
2713
2464
|
}
|
|
@@ -2715,12 +2466,12 @@
|
|
|
2715
2466
|
return cacheKey2IDMap[cacheKey];
|
|
2716
2467
|
}
|
|
2717
2468
|
|
|
2718
|
-
function createPattern($def, parsedColor, patternId) {
|
|
2469
|
+
function createPattern(document, $def, parsedColor, patternId) {
|
|
2719
2470
|
var src = parsedColor.value.src; // @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/pattern
|
|
2720
2471
|
|
|
2721
|
-
var $pattern = createSVGElement('pattern');
|
|
2472
|
+
var $pattern = createSVGElement('pattern', document);
|
|
2722
2473
|
$pattern.setAttribute('patternUnits', 'userSpaceOnUse');
|
|
2723
|
-
var $image = createSVGElement('image');
|
|
2474
|
+
var $image = createSVGElement('image', document);
|
|
2724
2475
|
$pattern.appendChild($image);
|
|
2725
2476
|
$pattern.id = patternId;
|
|
2726
2477
|
$def.appendChild($pattern);
|
|
@@ -2734,8 +2485,8 @@
|
|
|
2734
2485
|
img.src = src;
|
|
2735
2486
|
|
|
2736
2487
|
function onload() {
|
|
2737
|
-
$pattern.setAttribute('width', ""
|
|
2738
|
-
$pattern.setAttribute('height', ""
|
|
2488
|
+
$pattern.setAttribute('width', "" + img.width);
|
|
2489
|
+
$pattern.setAttribute('height', "" + img.height);
|
|
2739
2490
|
}
|
|
2740
2491
|
|
|
2741
2492
|
if (img.complete) {
|
|
@@ -2747,11 +2498,11 @@
|
|
|
2747
2498
|
}
|
|
2748
2499
|
}
|
|
2749
2500
|
|
|
2750
|
-
function createGradient($def, parsedColor, gradientId) {
|
|
2501
|
+
function createGradient(document, $def, parsedColor, gradientId) {
|
|
2751
2502
|
// <linearGradient> <radialGradient>
|
|
2752
2503
|
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/linearGradient
|
|
2753
2504
|
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/radialGradient
|
|
2754
|
-
var $gradient = createSVGElement(parsedColor.type === g.GradientPatternType.LinearGradient ? 'linearGradient' : 'radialGradient');
|
|
2505
|
+
var $gradient = createSVGElement(parsedColor.type === g.GradientPatternType.LinearGradient ? 'linearGradient' : 'radialGradient', document);
|
|
2755
2506
|
|
|
2756
2507
|
if (parsedColor.type === g.GradientPatternType.LinearGradient) {
|
|
2757
2508
|
var _parsedColor$value = parsedColor.value,
|
|
@@ -2759,28 +2510,26 @@
|
|
|
2759
2510
|
y0 = _parsedColor$value.y0,
|
|
2760
2511
|
x1 = _parsedColor$value.x1,
|
|
2761
2512
|
y1 = _parsedColor$value.y1;
|
|
2762
|
-
$gradient.setAttribute('x1', ""
|
|
2763
|
-
$gradient.setAttribute('y1', ""
|
|
2764
|
-
$gradient.setAttribute('x2', ""
|
|
2765
|
-
$gradient.setAttribute('y2', ""
|
|
2513
|
+
$gradient.setAttribute('x1', "" + x0);
|
|
2514
|
+
$gradient.setAttribute('y1', "" + y0);
|
|
2515
|
+
$gradient.setAttribute('x2', "" + x1);
|
|
2516
|
+
$gradient.setAttribute('y2', "" + y1);
|
|
2766
2517
|
} else {
|
|
2767
2518
|
var _parsedColor$value2 = parsedColor.value,
|
|
2768
2519
|
_x = _parsedColor$value2.x0,
|
|
2769
2520
|
_y = _parsedColor$value2.y0,
|
|
2770
2521
|
r1 = _parsedColor$value2.r1;
|
|
2771
|
-
$gradient.setAttribute('cx', ""
|
|
2772
|
-
$gradient.setAttribute('cy', ""
|
|
2773
|
-
$gradient.setAttribute('r', ""
|
|
2522
|
+
$gradient.setAttribute('cx', "" + _x);
|
|
2523
|
+
$gradient.setAttribute('cy', "" + _y);
|
|
2524
|
+
$gradient.setAttribute('r', "" + r1 / 2);
|
|
2774
2525
|
} // add stops
|
|
2775
2526
|
|
|
2776
2527
|
|
|
2777
2528
|
var innerHTML = '';
|
|
2778
2529
|
parsedColor.value.steps.forEach(function (_ref) {
|
|
2779
|
-
var
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
innerHTML += "<stop offset=\"".concat(offset, "\" stop-color=\"").concat(color, "\"></stop>");
|
|
2530
|
+
var offset = _ref[0],
|
|
2531
|
+
color = _ref[1];
|
|
2532
|
+
innerHTML += "<stop offset=\"" + offset + "\" stop-color=\"" + color + "\"></stop>";
|
|
2784
2533
|
});
|
|
2785
2534
|
$gradient.innerHTML = innerHTML;
|
|
2786
2535
|
$gradient.id = gradientId;
|
|
@@ -2793,14 +2542,14 @@
|
|
|
2793
2542
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
2794
2543
|
*/
|
|
2795
2544
|
|
|
2796
|
-
function createOrUpdateShadow($def, object, $el, name) {
|
|
2545
|
+
function createOrUpdateShadow(document, $def, object, $el, name) {
|
|
2797
2546
|
var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
|
|
2798
|
-
var $existedFilter = $def.querySelector("#"
|
|
2547
|
+
var $existedFilter = $def.querySelector("#" + shadowId);
|
|
2799
2548
|
|
|
2800
2549
|
if (!$existedFilter) {
|
|
2801
|
-
$existedFilter = createSVGElement('filter');
|
|
2550
|
+
$existedFilter = createSVGElement('filter', document);
|
|
2802
2551
|
|
|
2803
|
-
var _$feDropShadow = createSVGElement('feDropShadow');
|
|
2552
|
+
var _$feDropShadow = createSVGElement('feDropShadow', document);
|
|
2804
2553
|
|
|
2805
2554
|
_$feDropShadow.setAttribute('dx', '0');
|
|
2806
2555
|
|
|
@@ -2821,52 +2570,28 @@
|
|
|
2821
2570
|
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
2822
2571
|
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
2823
2572
|
|
|
2824
|
-
$feDropShadow.setAttribute('stdDeviation', ""
|
|
2573
|
+
$feDropShadow.setAttribute('stdDeviation', "" + (shadowBlur && shadowBlur.value || 0) / 2);
|
|
2825
2574
|
} else if (name === 'shadowOffsetX') {
|
|
2826
2575
|
var shadowOffsetX = object.parsedStyle[name];
|
|
2827
|
-
$feDropShadow.setAttribute('dx', ""
|
|
2576
|
+
$feDropShadow.setAttribute('dx', "" + (shadowOffsetX && shadowOffsetX.value || 0) / 2);
|
|
2828
2577
|
} else if (name === 'shadowOffsetY') {
|
|
2829
2578
|
var shadowOffsetY = object.parsedStyle[name];
|
|
2830
|
-
$feDropShadow.setAttribute('dy', ""
|
|
2579
|
+
$feDropShadow.setAttribute('dy', "" + (shadowOffsetY && shadowOffsetY.value || 0) / 2);
|
|
2831
2580
|
} // only apply shadow when blur > 0
|
|
2832
2581
|
|
|
2833
2582
|
|
|
2834
2583
|
if (object.parsedStyle.shadowBlur && object.parsedStyle.shadowBlur.value > 0) {
|
|
2835
2584
|
// use filter <feDropShadow>
|
|
2836
2585
|
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
|
|
2837
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#"
|
|
2586
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + shadowId + ")");
|
|
2838
2587
|
} else {
|
|
2839
2588
|
$el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
|
|
2840
2589
|
}
|
|
2841
2590
|
}
|
|
2842
2591
|
|
|
2843
|
-
var
|
|
2844
|
-
multiple: false
|
|
2845
|
-
});
|
|
2846
|
-
|
|
2847
|
-
var DefaultElementContribution = /*#__PURE__*/function () {
|
|
2848
|
-
function DefaultElementContribution() {
|
|
2849
|
-
_classCallCheck$2(this, DefaultElementContribution);
|
|
2850
|
-
}
|
|
2851
|
-
|
|
2852
|
-
_createClass$2(DefaultElementContribution, [{
|
|
2853
|
-
key: "createElement",
|
|
2854
|
-
value: function createElement(object) {
|
|
2855
|
-
return createSVGElement(object.nodeName);
|
|
2856
|
-
}
|
|
2857
|
-
}]);
|
|
2858
|
-
|
|
2859
|
-
return DefaultElementContribution;
|
|
2860
|
-
}();
|
|
2861
|
-
|
|
2862
|
-
DefaultElementContribution = __decorate([manaSyringe.singleton({
|
|
2863
|
-
token: CreateElementContribution
|
|
2864
|
-
})], DefaultElementContribution);
|
|
2865
|
-
|
|
2866
|
-
var _SHAPE2TAGS, _class$1;
|
|
2592
|
+
var _class$1;
|
|
2867
2593
|
|
|
2868
2594
|
var SVGRendererPlugin_1;
|
|
2869
|
-
var SHAPE2TAGS = (_SHAPE2TAGS = {}, _defineProperty(_SHAPE2TAGS, g.Shape.RECT, 'path'), _defineProperty(_SHAPE2TAGS, g.Shape.CIRCLE, 'circle'), _defineProperty(_SHAPE2TAGS, g.Shape.ELLIPSE, 'ellipse'), _defineProperty(_SHAPE2TAGS, g.Shape.IMAGE, 'image'), _defineProperty(_SHAPE2TAGS, g.Shape.GROUP, 'g'), _defineProperty(_SHAPE2TAGS, g.Shape.LINE, 'line'), _defineProperty(_SHAPE2TAGS, g.Shape.POLYLINE, 'polyline'), _defineProperty(_SHAPE2TAGS, g.Shape.POLYGON, 'polygon'), _defineProperty(_SHAPE2TAGS, g.Shape.TEXT, 'text'), _defineProperty(_SHAPE2TAGS, g.Shape.PATH, 'path'), _defineProperty(_SHAPE2TAGS, g.Shape.HTML, 'foreignObject'), _SHAPE2TAGS);
|
|
2870
2595
|
var SVG_ATTR_MAP = {
|
|
2871
2596
|
opacity: 'opacity',
|
|
2872
2597
|
fillStyle: 'fill',
|
|
@@ -2948,485 +2673,471 @@
|
|
|
2948
2673
|
var CLIP_PATH_PREFIX = 'clip-path-';
|
|
2949
2674
|
var SVGRendererPlugin = SVGRendererPlugin_1 = (_class$1 = /*#__PURE__*/function () {
|
|
2950
2675
|
function SVGRendererPlugin() {
|
|
2951
|
-
_classCallCheck$2(this, SVGRendererPlugin);
|
|
2952
|
-
|
|
2953
2676
|
this.canvasConfig = void 0;
|
|
2954
2677
|
this.camera = void 0;
|
|
2955
2678
|
this.contextService = void 0;
|
|
2956
2679
|
this.renderingContext = void 0;
|
|
2957
2680
|
this.createElementContribution = void 0;
|
|
2958
|
-
this.elementRendererFactory = void 0;
|
|
2959
2681
|
this.$def = void 0;
|
|
2960
2682
|
this.$camera = void 0;
|
|
2961
2683
|
this.renderQueue = [];
|
|
2962
2684
|
}
|
|
2963
2685
|
|
|
2964
|
-
|
|
2965
|
-
key: "apply",
|
|
2966
|
-
value: function apply(renderingService) {
|
|
2967
|
-
var _this = this;
|
|
2686
|
+
var _proto = SVGRendererPlugin.prototype;
|
|
2968
2687
|
|
|
2969
|
-
|
|
2970
|
-
|
|
2688
|
+
_proto.apply = function apply(renderingService) {
|
|
2689
|
+
var _this = this;
|
|
2971
2690
|
|
|
2972
|
-
|
|
2973
|
-
};
|
|
2691
|
+
var document = this.canvasConfig.document;
|
|
2974
2692
|
|
|
2975
|
-
|
|
2976
|
-
|
|
2693
|
+
var handleMounted = function handleMounted(e) {
|
|
2694
|
+
var object = e.target; // create SVG DOM Node
|
|
2977
2695
|
|
|
2978
|
-
|
|
2979
|
-
|
|
2696
|
+
_this.createSVGDom(document, object, _this.$camera);
|
|
2697
|
+
};
|
|
2980
2698
|
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
// @ts-ignore
|
|
2699
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
2700
|
+
var object = e.target;
|
|
2984
2701
|
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
}
|
|
2702
|
+
_this.removeSVGDom(object);
|
|
2703
|
+
};
|
|
2988
2704
|
|
|
2989
|
-
|
|
2705
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
2706
|
+
var object = e.target; // @see https://github.com/antvis/g/issues/994
|
|
2707
|
+
// @ts-ignore
|
|
2990
2708
|
|
|
2991
|
-
|
|
2992
|
-
|
|
2709
|
+
if (!object.elementSVG) {
|
|
2710
|
+
return;
|
|
2711
|
+
}
|
|
2993
2712
|
|
|
2994
|
-
|
|
2713
|
+
var attrName = e.attrName;
|
|
2995
2714
|
|
|
2996
|
-
|
|
2997
|
-
|
|
2715
|
+
if (attrName === 'zIndex') {
|
|
2716
|
+
var _object$parentNode, _object$parentNode$el;
|
|
2998
2717
|
|
|
2999
|
-
|
|
3000
|
-
_this.reorderChildren($groupEl, children);
|
|
3001
|
-
}
|
|
3002
|
-
} else if (attrName === 'increasedLineWidthForHitTesting') {
|
|
3003
|
-
// @ts-ignore
|
|
3004
|
-
var svgElement = object.elementSVG;
|
|
2718
|
+
var parent = object.parentNode; // @ts-ignore
|
|
3005
2719
|
|
|
3006
|
-
|
|
3007
|
-
|
|
2720
|
+
var $groupEl = (_object$parentNode = object.parentNode) === null || _object$parentNode === void 0 ? void 0 : (_object$parentNode$el = _object$parentNode.elementSVG) === null || _object$parentNode$el === void 0 ? void 0 : _object$parentNode$el.$groupEl;
|
|
2721
|
+
var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
|
|
3008
2722
|
|
|
3009
|
-
|
|
3010
|
-
|
|
2723
|
+
if ($groupEl) {
|
|
2724
|
+
_this.reorderChildren(document, $groupEl, children);
|
|
2725
|
+
}
|
|
2726
|
+
} else if (attrName === 'increasedLineWidthForHitTesting') {
|
|
2727
|
+
// @ts-ignore
|
|
2728
|
+
var svgElement = object.elementSVG;
|
|
3011
2729
|
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
3015
|
-
while (1) {
|
|
3016
|
-
switch (_context.prev = _context.next) {
|
|
3017
|
-
case 0:
|
|
3018
|
-
_this.$def = createSVGElement('defs');
|
|
3019
|
-
$svg = _this.contextService.getContext();
|
|
3020
|
-
background = _this.canvasConfig.background;
|
|
2730
|
+
_this.createOrUpdateHitArea(object, svgElement.$el, svgElement.$groupEl);
|
|
2731
|
+
}
|
|
3021
2732
|
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
}
|
|
2733
|
+
_this.updateAttribute(object, [attrName]);
|
|
2734
|
+
};
|
|
3025
2735
|
|
|
3026
|
-
|
|
2736
|
+
renderingService.hooks.init.tapPromise(SVGRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
2737
|
+
var _this$canvasConfig, background, document, $svg;
|
|
3027
2738
|
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
2739
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
2740
|
+
while (1) {
|
|
2741
|
+
switch (_context.prev = _context.next) {
|
|
2742
|
+
case 0:
|
|
2743
|
+
_this$canvasConfig = _this.canvasConfig, background = _this$canvasConfig.background, document = _this$canvasConfig.document;
|
|
2744
|
+
_this.$def = createSVGElement('defs', document);
|
|
2745
|
+
$svg = _this.contextService.getContext();
|
|
3031
2746
|
|
|
3032
|
-
|
|
2747
|
+
if (background) {
|
|
2748
|
+
$svg.style.background = background;
|
|
2749
|
+
}
|
|
3033
2750
|
|
|
3034
|
-
|
|
2751
|
+
$svg.appendChild(_this.$def); // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
|
|
3035
2752
|
|
|
3036
|
-
|
|
2753
|
+
$svg.setAttribute('color-interpolation-filters', 'sRGB');
|
|
2754
|
+
_this.$camera = createSVGElement('g', document);
|
|
2755
|
+
_this.$camera.id = G_SVG_PREFIX + "_camera";
|
|
3037
2756
|
|
|
3038
|
-
|
|
2757
|
+
_this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
|
|
3039
2758
|
|
|
3040
|
-
|
|
2759
|
+
$svg.appendChild(_this.$camera);
|
|
3041
2760
|
|
|
3042
|
-
|
|
3043
|
-
case "end":
|
|
3044
|
-
return _context.stop();
|
|
3045
|
-
}
|
|
3046
|
-
}
|
|
3047
|
-
}, _callee);
|
|
3048
|
-
})));
|
|
3049
|
-
renderingService.hooks.destroy.tap(SVGRendererPlugin_1.tag, function () {
|
|
3050
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
2761
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
3051
2762
|
|
|
3052
|
-
|
|
2763
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
3053
2764
|
|
|
3054
|
-
|
|
3055
|
-
});
|
|
3056
|
-
renderingService.hooks.render.tap(SVGRendererPlugin_1.tag, function (object) {
|
|
3057
|
-
// if (!object.isCulled()) {
|
|
3058
|
-
_this.renderQueue.push(object); // }
|
|
2765
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
3059
2766
|
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
2767
|
+
case 13:
|
|
2768
|
+
case "end":
|
|
2769
|
+
return _context.stop();
|
|
2770
|
+
}
|
|
3064
2771
|
}
|
|
2772
|
+
}, _callee);
|
|
2773
|
+
})));
|
|
2774
|
+
renderingService.hooks.destroy.tap(SVGRendererPlugin_1.tag, function () {
|
|
2775
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
2776
|
+
|
|
2777
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
3065
2778
|
|
|
3066
|
-
|
|
3067
|
-
|
|
2779
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
2780
|
+
});
|
|
2781
|
+
renderingService.hooks.render.tap(SVGRendererPlugin_1.tag, function (object) {
|
|
2782
|
+
// if (!object.isCulled()) {
|
|
2783
|
+
_this.renderQueue.push(object); // }
|
|
3068
2784
|
|
|
2785
|
+
});
|
|
2786
|
+
renderingService.hooks.endFrame.tap(SVGRendererPlugin_1.tag, function () {
|
|
2787
|
+
if (_this.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED)) {
|
|
2788
|
+
_this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
|
|
2789
|
+
}
|
|
3069
2790
|
|
|
3070
|
-
|
|
2791
|
+
_this.renderQueue.forEach(function (object) {
|
|
2792
|
+
var _object$elementSVG, _object$elementSVG2; // @ts-ignore
|
|
3071
2793
|
|
|
3072
|
-
var $groupEl = (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
|
|
3073
2794
|
|
|
3074
|
-
|
|
3075
|
-
// apply local RTS transformation to <group> wrapper
|
|
3076
|
-
// account for anchor
|
|
3077
|
-
_this.applyTransform($groupEl, object.getLocalTransform()); // finish rendering, clear dirty flag
|
|
2795
|
+
var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el; // @ts-ignore
|
|
3078
2796
|
|
|
2797
|
+
var $groupEl = (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
|
|
3079
2798
|
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
2799
|
+
if ($el && $groupEl) {
|
|
2800
|
+
// apply local RTS transformation to <group> wrapper
|
|
2801
|
+
// account for anchor
|
|
2802
|
+
_this.applyTransform($groupEl, object.getLocalTransform()); // finish rendering, clear dirty flag
|
|
3083
2803
|
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
}, {
|
|
3088
|
-
key: "reorderChildren",
|
|
3089
|
-
value: function reorderChildren($groupEl, children) {
|
|
3090
|
-
// need to reorder parent's children
|
|
3091
|
-
children.sort(function (a, b) {
|
|
3092
|
-
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
2804
|
+
|
|
2805
|
+
object.renderable.dirty = false;
|
|
2806
|
+
}
|
|
3093
2807
|
});
|
|
3094
2808
|
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
2809
|
+
_this.renderQueue = [];
|
|
2810
|
+
});
|
|
2811
|
+
};
|
|
2812
|
+
|
|
2813
|
+
_proto.reorderChildren = function reorderChildren(doc, $groupEl, children) {
|
|
2814
|
+
// need to reorder parent's children
|
|
2815
|
+
children.sort(function (a, b) {
|
|
2816
|
+
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
2817
|
+
});
|
|
3102
2818
|
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
2819
|
+
if (children.length) {
|
|
2820
|
+
// create empty fragment
|
|
2821
|
+
var fragment = (doc || document).createDocumentFragment();
|
|
2822
|
+
children.forEach(function (child) {
|
|
2823
|
+
if (child.isConnected) {
|
|
2824
|
+
// @ts-ignore
|
|
2825
|
+
var $el = child.elementSVG.$groupEl;
|
|
2826
|
+
|
|
2827
|
+
if ($el) {
|
|
2828
|
+
fragment.appendChild($el);
|
|
3106
2829
|
}
|
|
3107
|
-
}
|
|
3108
|
-
|
|
3109
|
-
|
|
2830
|
+
}
|
|
2831
|
+
});
|
|
2832
|
+
$groupEl.appendChild(fragment);
|
|
3110
2833
|
}
|
|
3111
|
-
}
|
|
3112
|
-
key: "applyTransform",
|
|
3113
|
-
value: function applyTransform($el, transform) {
|
|
3114
|
-
var translation = getTranslation(create$1(), transform);
|
|
3115
|
-
var scaling = getScaling(create$1(), transform);
|
|
3116
|
-
var rotation = getRotation(create$3(), transform);
|
|
3117
|
-
|
|
3118
|
-
var _translation = _slicedToArray(translation, 2),
|
|
3119
|
-
x = _translation[0],
|
|
3120
|
-
y = _translation[1];
|
|
2834
|
+
};
|
|
3121
2835
|
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
2836
|
+
_proto.applyTransform = function applyTransform($el, transform) {
|
|
2837
|
+
var translation = getTranslation(create$1(), transform);
|
|
2838
|
+
var scaling = getScaling(create$1(), transform);
|
|
2839
|
+
var rotation = getRotation(create$3(), transform);
|
|
2840
|
+
var x = translation[0],
|
|
2841
|
+
y = translation[1];
|
|
2842
|
+
var scaleX = scaling[0],
|
|
2843
|
+
scaleY = scaling[1]; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3125
2844
|
|
|
2845
|
+
var _getEuler = g.getEuler(create$1(), rotation),
|
|
2846
|
+
ex = _getEuler[0],
|
|
2847
|
+
ey = _getEuler[1],
|
|
2848
|
+
ez = _getEuler[2]; // gimbal lock at 90 degrees
|
|
3126
2849
|
|
|
3127
|
-
var _getEuler = g.getEuler(create$1(), rotation),
|
|
3128
|
-
_getEuler2 = _slicedToArray(_getEuler, 3),
|
|
3129
|
-
ex = _getEuler2[0],
|
|
3130
|
-
ey = _getEuler2[1],
|
|
3131
|
-
ez = _getEuler2[2]; // gimbal lock at 90 degrees
|
|
3132
2850
|
|
|
2851
|
+
var rts = g.fromRotationTranslationScale(ex || ez, x, y, scaleX, scaleY); // use proper precision avoiding too long string in `transform`
|
|
2852
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
3133
2853
|
|
|
3134
|
-
|
|
3135
|
-
|
|
2854
|
+
$el.setAttribute('transform', "matrix(" + numberToLongString(rts[0]) + "," + numberToLongString(rts[1]) + "," + numberToLongString(rts[3]) + "," + numberToLongString(rts[4]) + "," + numberToLongString(rts[6]) + "," + numberToLongString(rts[7]) + ")");
|
|
2855
|
+
};
|
|
3136
2856
|
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
// @ts-ignore
|
|
3143
|
-
var elementSVG = object.elementSVG;
|
|
3144
|
-
var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
|
|
3145
|
-
var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
|
|
2857
|
+
_proto.applyAttributes = function applyAttributes(object) {
|
|
2858
|
+
// @ts-ignore
|
|
2859
|
+
var elementSVG = object.elementSVG;
|
|
2860
|
+
var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
|
|
2861
|
+
var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
|
|
3146
2862
|
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
2863
|
+
if ($el && $groupEl) {
|
|
2864
|
+
var nodeName = object.nodeName,
|
|
2865
|
+
attributes = object.attributes;
|
|
2866
|
+
$el.setAttribute('fill', 'none');
|
|
3151
2867
|
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
2868
|
+
if (nodeName === g.Shape.IMAGE) {
|
|
2869
|
+
$el.setAttribute('preserveAspectRatio', 'none');
|
|
2870
|
+
} // apply attributes
|
|
3155
2871
|
|
|
3156
2872
|
|
|
3157
|
-
|
|
3158
|
-
}
|
|
2873
|
+
this.updateAttribute(object, Object.keys(attributes));
|
|
3159
2874
|
}
|
|
3160
|
-
}
|
|
3161
|
-
key: "updateAttribute",
|
|
3162
|
-
value: function updateAttribute(object, attributes) {
|
|
3163
|
-
var _this2 = this;
|
|
3164
|
-
|
|
3165
|
-
var needGeneratePath = false; // @ts-ignore
|
|
3166
|
-
|
|
3167
|
-
var _object$elementSVG3 = object.elementSVG,
|
|
3168
|
-
$el = _object$elementSVG3.$el,
|
|
3169
|
-
$groupEl = _object$elementSVG3.$groupEl,
|
|
3170
|
-
$hitTestingEl = _object$elementSVG3.$hitTestingEl;
|
|
3171
|
-
var parsedStyle = object.parsedStyle,
|
|
3172
|
-
computedStyle = object.computedStyle;
|
|
3173
|
-
var elementRenderer = this.elementRendererFactory(object.nodeName);
|
|
3174
|
-
attributes.forEach(function (name) {
|
|
3175
|
-
var usedName = SVG_ATTR_MAP[name];
|
|
3176
|
-
var computedValue = computedStyle[name];
|
|
3177
|
-
var usedValue = parsedStyle[name]; // generate path only once
|
|
3178
|
-
|
|
3179
|
-
if (!needGeneratePath && elementRenderer && elementRenderer.dependencies.indexOf(name) > -1) {
|
|
3180
|
-
needGeneratePath = true;
|
|
3181
|
-
} // <foreignObject>
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
if (object.nodeName === g.Shape.HTML) {
|
|
3185
|
-
if (name === 'fill') {
|
|
3186
|
-
$el.style.background = usedValue.toString();
|
|
3187
|
-
} else if (name === 'stroke') {
|
|
3188
|
-
$el.style['border-color'] = usedValue.toString();
|
|
3189
|
-
$el.style['border-style'] = 'solid';
|
|
3190
|
-
} else if (name === 'lineWidth') {
|
|
3191
|
-
$el.style['border-width'] = "".concat(usedValue.value || 0, "px");
|
|
3192
|
-
} else if (name === 'lineDash') {
|
|
3193
|
-
$el.style['border-style'] = 'dashed';
|
|
3194
|
-
}
|
|
3195
|
-
}
|
|
2875
|
+
};
|
|
3196
2876
|
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
} else if (name === 'visibility' && computedValue.value !== 'unset') {
|
|
3200
|
-
// use computed value
|
|
3201
|
-
// update `visibility` on <group>
|
|
3202
|
-
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, "".concat(computedValue.value));
|
|
3203
|
-
} else if (name === 'clipPath') {
|
|
3204
|
-
_this2.createOrUpdateClipPath(usedValue, $groupEl);
|
|
3205
|
-
} else if (name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
|
|
3206
|
-
createOrUpdateShadow(_this2.$def, object, $el, name);
|
|
3207
|
-
} else if (name === 'filter') {
|
|
3208
|
-
createOrUpdateFilter(_this2.$def, object, $el, usedValue);
|
|
3209
|
-
} else if (name === 'innerHTML') {
|
|
3210
|
-
_this2.createOrUpdateInnerHTML($el, usedValue);
|
|
3211
|
-
} else {
|
|
3212
|
-
if ( // (!object.style.clipPathTargets) &&
|
|
3213
|
-
object.nodeName !== g.Shape.TEXT && // text' anchor is controlled by `textAnchor` property
|
|
3214
|
-
['width', 'height', 'r', 'rx', 'ry', 'anchor'].indexOf(name) > -1) {
|
|
3215
|
-
_this2.updateAnchorWithTransform(object);
|
|
3216
|
-
}
|
|
2877
|
+
_proto.updateAttribute = function updateAttribute(object, attributes) {
|
|
2878
|
+
var _this2 = this;
|
|
3217
2879
|
|
|
3218
|
-
|
|
3219
|
-
// use computed value so that we can use cascaded effect in SVG
|
|
3220
|
-
var valueStr = computedValue.toString(); // ignore 'unset' and default value
|
|
2880
|
+
var document = this.canvasConfig.document; // @ts-ignore
|
|
3221
2881
|
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
2882
|
+
var _object$elementSVG3 = object.elementSVG,
|
|
2883
|
+
$el = _object$elementSVG3.$el,
|
|
2884
|
+
$groupEl = _object$elementSVG3.$groupEl,
|
|
2885
|
+
$hitTestingEl = _object$elementSVG3.$hitTestingEl;
|
|
2886
|
+
var parsedStyle = object.parsedStyle,
|
|
2887
|
+
computedStyle = object.computedStyle;
|
|
2888
|
+
var shouldUpdateElementAttribute = attributes.some(function (name) {
|
|
2889
|
+
return _this2.createElementContribution.shouldUpdateElementAttribute(object, name);
|
|
2890
|
+
}); // need re-generate path
|
|
3226
2891
|
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
2892
|
+
if (shouldUpdateElementAttribute && $el) {
|
|
2893
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
2894
|
+
if ($el) {
|
|
2895
|
+
_this2.createElementContribution.updateElementAttribute(object, $el);
|
|
2896
|
+
|
|
2897
|
+
if (object.nodeName !== g.Shape.TEXT) {
|
|
2898
|
+
_this2.updateAnchorWithTransform(object);
|
|
3234
2899
|
}
|
|
3235
2900
|
}
|
|
3236
|
-
});
|
|
2901
|
+
});
|
|
2902
|
+
} // update common attributes
|
|
2903
|
+
|
|
2904
|
+
|
|
2905
|
+
attributes.forEach(function (name) {
|
|
2906
|
+
var usedName = SVG_ATTR_MAP[name];
|
|
2907
|
+
var computedValue = computedStyle[name];
|
|
2908
|
+
var usedValue = parsedStyle[name]; // <foreignObject>
|
|
2909
|
+
|
|
2910
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
2911
|
+
if (name === 'fill') {
|
|
2912
|
+
$el.style.background = usedValue.toString();
|
|
2913
|
+
} else if (name === 'stroke') {
|
|
2914
|
+
$el.style['border-color'] = usedValue.toString();
|
|
2915
|
+
$el.style['border-style'] = 'solid';
|
|
2916
|
+
} else if (name === 'lineWidth') {
|
|
2917
|
+
$el.style['border-width'] = (usedValue.value || 0) + "px";
|
|
2918
|
+
} else if (name === 'lineDash') {
|
|
2919
|
+
$el.style['border-style'] = 'dashed';
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
3237
2922
|
|
|
3238
|
-
if (
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
2923
|
+
if (name === 'fill' || name === 'stroke') {
|
|
2924
|
+
createOrUpdateGradientAndPattern(document, _this2.$def, object, $el, usedValue, usedName);
|
|
2925
|
+
} else if (name === 'visibility' && computedValue.value !== 'unset') {
|
|
2926
|
+
// use computed value
|
|
2927
|
+
// update `visibility` on <group>
|
|
2928
|
+
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, "" + computedValue.value);
|
|
2929
|
+
} else if (name === 'clipPath') {
|
|
2930
|
+
_this2.createOrUpdateClipPath(document, usedValue, $groupEl);
|
|
2931
|
+
} else if (name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
|
|
2932
|
+
createOrUpdateShadow(document, _this2.$def, object, $el, name);
|
|
2933
|
+
} else if (name === 'filter') {
|
|
2934
|
+
createOrUpdateFilter(document, _this2.$def, object, $el, usedValue);
|
|
2935
|
+
} else if (name === 'innerHTML') {
|
|
2936
|
+
_this2.createOrUpdateInnerHTML(document, $el, usedValue);
|
|
2937
|
+
} else if (name === 'anchor') {
|
|
2938
|
+
// text' anchor is controlled by `textAnchor` property
|
|
2939
|
+
if (object.nodeName !== g.Shape.TEXT) {
|
|
2940
|
+
_this2.updateAnchorWithTransform(object);
|
|
2941
|
+
}
|
|
2942
|
+
} else {
|
|
2943
|
+
if (computedValue) {
|
|
2944
|
+
// use computed value so that we can use cascaded effect in SVG
|
|
2945
|
+
var valueStr = computedValue.toString(); // ignore 'unset' and default value
|
|
2946
|
+
|
|
2947
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
2948
|
+
if ($el && usedName) {
|
|
2949
|
+
if (valueStr !== 'unset' && valueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
2950
|
+
var _FORMAT_VALUE_MAP$nam;
|
|
2951
|
+
|
|
2952
|
+
var formattedValueStr = ((_FORMAT_VALUE_MAP$nam = FORMAT_VALUE_MAP[name]) === null || _FORMAT_VALUE_MAP$nam === void 0 ? void 0 : _FORMAT_VALUE_MAP$nam[valueStr]) || valueStr;
|
|
2953
|
+
$el.setAttribute(usedName, formattedValueStr);
|
|
2954
|
+
} else {
|
|
2955
|
+
$el.removeAttribute(usedName);
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
});
|
|
2959
|
+
}
|
|
3244
2960
|
}
|
|
3245
|
-
}
|
|
3246
|
-
}
|
|
3247
|
-
key: "createSVGDom",
|
|
3248
|
-
value: function createSVGDom(object, root) {
|
|
3249
|
-
var noWrapWithGroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; // create svg element
|
|
3250
|
-
// @ts-ignore
|
|
2961
|
+
});
|
|
2962
|
+
};
|
|
3251
2963
|
|
|
3252
|
-
|
|
2964
|
+
_proto.createSVGDom = function createSVGDom(document, object, root, noWrapWithGroup) {
|
|
2965
|
+
if (noWrapWithGroup === void 0) {
|
|
2966
|
+
noWrapWithGroup = false;
|
|
2967
|
+
} // create svg element
|
|
2968
|
+
// @ts-ignore
|
|
3253
2969
|
|
|
3254
|
-
var svgElement = object.elementSVG; // use <group> as default, eg. CustomElement
|
|
3255
2970
|
|
|
3256
|
-
|
|
2971
|
+
object.elementSVG = new ElementSVG(); // @ts-ignore
|
|
3257
2972
|
|
|
3258
|
-
|
|
3259
|
-
var _object$parentNode$el2;
|
|
2973
|
+
var svgElement = object.elementSVG; // use <group> as default, eg. CustomElement
|
|
3260
2974
|
|
|
3261
|
-
|
|
3262
|
-
var $el = createSVGElement(type); // save $el on parsedStyle, which will be returned in getDomElement()
|
|
2975
|
+
var $el = this.createElementContribution.createElement(object);
|
|
3263
2976
|
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
}
|
|
2977
|
+
if ($el) {
|
|
2978
|
+
var _object$parentNode$el2;
|
|
3267
2979
|
|
|
3268
|
-
|
|
2980
|
+
var $groupEl; // save $el on parsedStyle, which will be returned in getDomElement()
|
|
3269
2981
|
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
} else {
|
|
3274
|
-
$groupEl = $el;
|
|
3275
|
-
}
|
|
2982
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
2983
|
+
object.parsedStyle.$el = $el;
|
|
2984
|
+
}
|
|
3276
2985
|
|
|
3277
|
-
|
|
3278
|
-
svgElement.$groupEl = $groupEl;
|
|
3279
|
-
var $parentGroupEl = // @ts-ignore
|
|
3280
|
-
object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl) || root;
|
|
2986
|
+
$el.id = G_SVG_PREFIX + "_" + object.nodeName + "_" + object.entity;
|
|
3281
2987
|
|
|
3282
|
-
|
|
3283
|
-
|
|
2988
|
+
if (($el.hasAttribute('data-wrapgroup') || $el.nodeName !== 'g') && !noWrapWithGroup) {
|
|
2989
|
+
$groupEl = createSVGElement('g', document);
|
|
2990
|
+
$groupEl.appendChild($el);
|
|
2991
|
+
} else {
|
|
2992
|
+
$groupEl = $el;
|
|
2993
|
+
}
|
|
3284
2994
|
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
this.reorderChildren($parentGroupEl, children || []);
|
|
3288
|
-
} // apply attributes at first time
|
|
2995
|
+
svgElement.$el = $el;
|
|
2996
|
+
svgElement.$groupEl = $groupEl; // apply attributes at first time
|
|
3289
2997
|
|
|
2998
|
+
this.applyAttributes(object); // create hitArea if necessary
|
|
3290
2999
|
|
|
3291
|
-
|
|
3000
|
+
this.createOrUpdateHitArea(object, $el, $groupEl);
|
|
3001
|
+
var $parentGroupEl = // @ts-ignore
|
|
3002
|
+
object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl) || root;
|
|
3292
3003
|
|
|
3293
|
-
|
|
3004
|
+
if ($parentGroupEl) {
|
|
3005
|
+
var _object$parentNode2;
|
|
3006
|
+
|
|
3007
|
+
$parentGroupEl.appendChild($groupEl);
|
|
3008
|
+
var children = (((_object$parentNode2 = object.parentNode) === null || _object$parentNode2 === void 0 ? void 0 : _object$parentNode2.children) || []).slice();
|
|
3009
|
+
this.reorderChildren(document, $parentGroupEl, children || []);
|
|
3294
3010
|
}
|
|
3295
3011
|
}
|
|
3296
|
-
}
|
|
3297
|
-
key: "removeSVGDom",
|
|
3298
|
-
value: function removeSVGDom(object) {
|
|
3299
|
-
var _object$elementSVG4; // @ts-ignore
|
|
3012
|
+
};
|
|
3300
3013
|
|
|
3014
|
+
_proto.removeSVGDom = function removeSVGDom(object) {
|
|
3015
|
+
var _object$elementSVG4; // @ts-ignore
|
|
3301
3016
|
|
|
3302
|
-
var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
|
|
3303
3017
|
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3018
|
+
var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
|
|
3019
|
+
|
|
3020
|
+
if ($groupEl && $groupEl.parentNode) {
|
|
3021
|
+
$groupEl.parentNode.removeChild($groupEl); // object.entity.removeComponent(ElementSVG, true);
|
|
3307
3022
|
}
|
|
3308
|
-
}
|
|
3309
|
-
key: "createOrUpdateHitArea",
|
|
3310
|
-
value: function createOrUpdateHitArea(object, $el, $groupEl) {
|
|
3311
|
-
var _object$parsedStyle$i; // @ts-ignore
|
|
3023
|
+
};
|
|
3312
3024
|
|
|
3025
|
+
_proto.createOrUpdateHitArea = function createOrUpdateHitArea(object, $el, $groupEl) {
|
|
3026
|
+
var _object$parsedStyle$i; // @ts-ignore
|
|
3313
3027
|
|
|
3314
|
-
var svgElement = object.elementSVG;
|
|
3315
|
-
var $hitTestingEl = svgElement.$hitTestingEl;
|
|
3316
|
-
var increasedLineWidthForHitTesting = (_object$parsedStyle$i = object.parsedStyle.increasedLineWidthForHitTesting) === null || _object$parsedStyle$i === void 0 ? void 0 : _object$parsedStyle$i.value; // account for hitArea
|
|
3317
3028
|
|
|
3318
|
-
|
|
3319
|
-
|
|
3029
|
+
var svgElement = object.elementSVG;
|
|
3030
|
+
var $hitTestingEl = svgElement.$hitTestingEl;
|
|
3031
|
+
var increasedLineWidthForHitTesting = (_object$parsedStyle$i = object.parsedStyle.increasedLineWidthForHitTesting) === null || _object$parsedStyle$i === void 0 ? void 0 : _object$parsedStyle$i.value; // account for hitArea
|
|
3320
3032
|
|
|
3321
|
-
|
|
3322
|
-
|
|
3033
|
+
if (increasedLineWidthForHitTesting) {
|
|
3034
|
+
var _object$parsedStyle$l;
|
|
3323
3035
|
|
|
3324
|
-
|
|
3036
|
+
if (!$hitTestingEl) {
|
|
3037
|
+
$hitTestingEl = $el.cloneNode(); // use the entity suffix, so that `g-plugin-svg-picker` can extract
|
|
3325
3038
|
|
|
3326
|
-
|
|
3327
|
-
$hitTestingEl.removeAttribute(attribute);
|
|
3328
|
-
}); // hitArea should be 'transparent' but not 'none'
|
|
3039
|
+
$hitTestingEl.id = G_SVG_PREFIX + "_" + object.nodeName + "_hittesting_" + object.entity; // clear attributes like `filter` `font-size`
|
|
3329
3040
|
|
|
3330
|
-
|
|
3331
|
-
$hitTestingEl.
|
|
3332
|
-
|
|
3333
|
-
$groupEl.appendChild($hitTestingEl);
|
|
3334
|
-
svgElement.$hitTestingEl = $hitTestingEl;
|
|
3335
|
-
} // increase interactive line width
|
|
3041
|
+
['filter'].forEach(function (attribute) {
|
|
3042
|
+
$hitTestingEl.removeAttribute(attribute);
|
|
3043
|
+
}); // hitArea should be 'transparent' but not 'none'
|
|
3336
3044
|
|
|
3045
|
+
var hasFill = $el.getAttribute('fill') !== 'none';
|
|
3046
|
+
$hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
|
|
3047
|
+
$hitTestingEl.setAttribute('stroke', 'transparent');
|
|
3048
|
+
$groupEl.appendChild($hitTestingEl);
|
|
3049
|
+
svgElement.$hitTestingEl = $hitTestingEl;
|
|
3050
|
+
} // increase interactive line width
|
|
3337
3051
|
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3052
|
+
|
|
3053
|
+
$hitTestingEl.setAttribute('stroke-width', "" + (increasedLineWidthForHitTesting + ((_object$parsedStyle$l = object.parsedStyle.lineWidth) === null || _object$parsedStyle$l === void 0 ? void 0 : _object$parsedStyle$l.value)));
|
|
3054
|
+
} else {
|
|
3055
|
+
if ($hitTestingEl) {
|
|
3056
|
+
$groupEl.removeChild($hitTestingEl);
|
|
3057
|
+
svgElement.$hitTestingEl = null;
|
|
3344
3058
|
}
|
|
3345
3059
|
}
|
|
3346
|
-
}
|
|
3347
|
-
key: "createOrUpdateInnerHTML",
|
|
3348
|
-
value: function createOrUpdateInnerHTML($el, usedValue) {
|
|
3349
|
-
var $div = document.createElement('div');
|
|
3060
|
+
};
|
|
3350
3061
|
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
} else {
|
|
3354
|
-
$div.appendChild(usedValue);
|
|
3355
|
-
}
|
|
3062
|
+
_proto.createOrUpdateInnerHTML = function createOrUpdateInnerHTML(doc, $el, usedValue) {
|
|
3063
|
+
var $div = (doc || document).createElement('div');
|
|
3356
3064
|
|
|
3357
|
-
|
|
3358
|
-
$
|
|
3065
|
+
if (typeof usedValue === 'string') {
|
|
3066
|
+
$div.innerHTML = usedValue;
|
|
3067
|
+
} else {
|
|
3068
|
+
$div.appendChild(usedValue);
|
|
3359
3069
|
}
|
|
3360
|
-
}, {
|
|
3361
|
-
key: "createOrUpdateClipPath",
|
|
3362
|
-
value: function createOrUpdateClipPath(clipPath, $groupEl) {
|
|
3363
|
-
if (clipPath) {
|
|
3364
|
-
var _clipPath$elementSVG;
|
|
3365
3070
|
|
|
3366
|
-
|
|
3367
|
-
|
|
3071
|
+
$el.innerHTML = '';
|
|
3072
|
+
$el.appendChild($div);
|
|
3073
|
+
};
|
|
3074
|
+
|
|
3075
|
+
_proto.createOrUpdateClipPath = function createOrUpdateClipPath(document, clipPath, $groupEl) {
|
|
3076
|
+
if (clipPath) {
|
|
3077
|
+
var _clipPath$elementSVG;
|
|
3368
3078
|
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
var $clipPath = createSVGElement('clipPath');
|
|
3372
|
-
$clipPath.id = clipPathId;
|
|
3373
|
-
this.$def.appendChild($clipPath); // <clipPath><circle /></clipPath>
|
|
3079
|
+
var clipPathId = CLIP_PATH_PREFIX + clipPath.entity;
|
|
3080
|
+
var existed = this.$def.querySelector("#" + clipPathId);
|
|
3374
3081
|
|
|
3375
|
-
|
|
3082
|
+
if (!existed) {
|
|
3083
|
+
// create <clipPath> dom node, append it to <defs>
|
|
3084
|
+
var $clipPath = createSVGElement('clipPath', document);
|
|
3085
|
+
$clipPath.id = clipPathId;
|
|
3086
|
+
this.$def.appendChild($clipPath); // <clipPath><circle /></clipPath>
|
|
3376
3087
|
|
|
3377
|
-
|
|
3378
|
-
} // @ts-ignore
|
|
3088
|
+
this.createSVGDom(document, clipPath, $clipPath, true); // @ts-ignore
|
|
3379
3089
|
|
|
3090
|
+
clipPath.elementSVG.$groupEl = $clipPath;
|
|
3091
|
+
} // @ts-ignore
|
|
3380
3092
|
|
|
3381
|
-
var $clipPathGroupEl = (_clipPath$elementSVG = clipPath.elementSVG) === null || _clipPath$elementSVG === void 0 ? void 0 : _clipPath$elementSVG.$groupEl;
|
|
3382
3093
|
|
|
3383
|
-
|
|
3384
|
-
// apply local RTS transformation to <group> wrapper
|
|
3385
|
-
this.applyTransform($clipPathGroupEl, clipPath.getLocalTransform());
|
|
3386
|
-
} // apply attributes
|
|
3094
|
+
var $clipPathGroupEl = (_clipPath$elementSVG = clipPath.elementSVG) === null || _clipPath$elementSVG === void 0 ? void 0 : _clipPath$elementSVG.$groupEl;
|
|
3387
3095
|
|
|
3096
|
+
if ($clipPathGroupEl) {
|
|
3097
|
+
// apply local RTS transformation to <group> wrapper
|
|
3098
|
+
this.applyTransform($clipPathGroupEl, clipPath.getLocalTransform());
|
|
3099
|
+
} // apply attributes
|
|
3388
3100
|
|
|
3389
|
-
this.applyAttributes(clipPath); // apply clipPath to $group
|
|
3390
|
-
// @see https://github.com/antvis/g/issues/961
|
|
3391
3101
|
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3102
|
+
this.applyAttributes(clipPath); // apply clipPath to $group
|
|
3103
|
+
// @see https://github.com/antvis/g/issues/961
|
|
3104
|
+
|
|
3105
|
+
$groupEl.setAttribute('clip-path', "url(#" + clipPathId + ")");
|
|
3106
|
+
} else {
|
|
3107
|
+
// remove clip path
|
|
3108
|
+
$groupEl.removeAttribute('clip-path');
|
|
3397
3109
|
}
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3110
|
+
}
|
|
3111
|
+
/**
|
|
3112
|
+
* the origin is bounding box's top left corner
|
|
3113
|
+
*/
|
|
3114
|
+
;
|
|
3401
3115
|
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
value: function updateAnchorWithTransform(object) {
|
|
3405
|
-
var _object$elementSVG5, _object$elementSVG6;
|
|
3116
|
+
_proto.updateAnchorWithTransform = function updateAnchorWithTransform(object) {
|
|
3117
|
+
var _object$elementSVG5, _object$elementSVG6;
|
|
3406
3118
|
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3119
|
+
var bounds = object.getGeometryBounds();
|
|
3120
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
3121
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
3410
3122
|
|
|
3411
|
-
|
|
3412
|
-
|
|
3123
|
+
var _ref2 = object.parsedStyle || {},
|
|
3124
|
+
anchor = _ref2.anchor; // @ts-ignore
|
|
3413
3125
|
|
|
3414
3126
|
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
}
|
|
3127
|
+
[(_object$elementSVG5 = object.elementSVG) === null || _object$elementSVG5 === void 0 ? void 0 : _object$elementSVG5.$el, (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$hitTestingEl].forEach(function ($el) {
|
|
3128
|
+
if ($el) {
|
|
3129
|
+
// apply anchor to element's `transform` property
|
|
3130
|
+
$el.setAttribute('transform', // can't use percent unit like translate(-50%, -50%)
|
|
3131
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
|
|
3132
|
+
"translate(-" + anchor[0].value * width + ",-" + anchor[1].value * height + ")");
|
|
3133
|
+
|
|
3134
|
+
if (object.nodeName === g.Shape.CIRCLE || object.nodeName === g.Shape.ELLIPSE) {
|
|
3135
|
+
$el.setAttribute('cx', "" + width / 2);
|
|
3136
|
+
$el.setAttribute('cy', "" + height / 2);
|
|
3426
3137
|
}
|
|
3427
|
-
}
|
|
3428
|
-
}
|
|
3429
|
-
}
|
|
3138
|
+
}
|
|
3139
|
+
});
|
|
3140
|
+
};
|
|
3430
3141
|
|
|
3431
3142
|
return SVGRendererPlugin;
|
|
3432
3143
|
}(), _class$1.tag = 'SVGRenderer', _class$1);
|
|
@@ -3441,80 +3152,52 @@
|
|
|
3441
3152
|
|
|
3442
3153
|
__decorate([manaSyringe.inject(CreateElementContribution), __metadata("design:type", Object)], SVGRendererPlugin.prototype, "createElementContribution", void 0);
|
|
3443
3154
|
|
|
3444
|
-
__decorate([manaSyringe.inject(ElementRendererFactory), __metadata("design:type", Function)], SVGRendererPlugin.prototype, "elementRendererFactory", void 0);
|
|
3445
|
-
|
|
3446
3155
|
SVGRendererPlugin = SVGRendererPlugin_1 = __decorate([manaSyringe.singleton({
|
|
3447
3156
|
contrib: g.RenderingPluginContribution
|
|
3448
3157
|
})], SVGRendererPlugin);
|
|
3449
3158
|
var containerModule$1 = manaSyringe.Module(function (register) {
|
|
3450
|
-
|
|
3451
|
-
* register shape renderers
|
|
3452
|
-
*/
|
|
3453
|
-
register(RectRenderer);
|
|
3454
|
-
register(ImageRenderer);
|
|
3455
|
-
register(LineRenderer);
|
|
3456
|
-
register(PolylineRenderer);
|
|
3457
|
-
register(TextRenderer);
|
|
3458
|
-
register(PathRenderer);
|
|
3459
|
-
register({
|
|
3460
|
-
token: ElementRendererFactory,
|
|
3461
|
-
useFactory: function useFactory(ctx) {
|
|
3462
|
-
return function (tagName) {
|
|
3463
|
-
if (tagName === g.Shape.RECT) {
|
|
3464
|
-
return ctx.container.get(RectRenderer);
|
|
3465
|
-
} else if (tagName === g.Shape.IMAGE) {
|
|
3466
|
-
return ctx.container.get(ImageRenderer);
|
|
3467
|
-
} else if (tagName === g.Shape.LINE) {
|
|
3468
|
-
return ctx.container.get(LineRenderer);
|
|
3469
|
-
} else if (tagName === g.Shape.POLYLINE || tagName === g.Shape.POLYGON) {
|
|
3470
|
-
return ctx.container.get(PolylineRenderer);
|
|
3471
|
-
} else if (tagName === g.Shape.TEXT) {
|
|
3472
|
-
return ctx.container.get(TextRenderer);
|
|
3473
|
-
} else if (tagName === g.Shape.PATH) {
|
|
3474
|
-
return ctx.container.get(PathRenderer);
|
|
3475
|
-
}
|
|
3476
|
-
|
|
3477
|
-
return null;
|
|
3478
|
-
};
|
|
3479
|
-
}
|
|
3480
|
-
});
|
|
3481
|
-
register(DefaultElementContribution);
|
|
3159
|
+
register(DefaultCreateElementContribution);
|
|
3482
3160
|
register(SVGRendererPlugin);
|
|
3483
3161
|
});
|
|
3484
3162
|
|
|
3485
3163
|
var Plugin$1 = /*#__PURE__*/function () {
|
|
3486
3164
|
function Plugin() {
|
|
3487
|
-
_classCallCheck$2(this, Plugin);
|
|
3488
|
-
|
|
3489
3165
|
this.name = 'svg-renderer';
|
|
3490
3166
|
}
|
|
3491
3167
|
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
}
|
|
3502
|
-
}]);
|
|
3168
|
+
var _proto = Plugin.prototype;
|
|
3169
|
+
|
|
3170
|
+
_proto.init = function init(container) {
|
|
3171
|
+
container.load(containerModule$1, true);
|
|
3172
|
+
};
|
|
3173
|
+
|
|
3174
|
+
_proto.destroy = function destroy(container) {
|
|
3175
|
+
container.unload(containerModule$1);
|
|
3176
|
+
};
|
|
3503
3177
|
|
|
3504
3178
|
return Plugin;
|
|
3505
3179
|
}();
|
|
3506
3180
|
|
|
3507
3181
|
var index_esm$1 = /*#__PURE__*/Object.freeze({
|
|
3508
3182
|
__proto__: null,
|
|
3183
|
+
CreateElementContribution: CreateElementContribution,
|
|
3509
3184
|
DEFAULT_VALUE_MAP: DEFAULT_VALUE_MAP,
|
|
3185
|
+
get DefaultCreateElementContribution () { return DefaultCreateElementContribution; },
|
|
3510
3186
|
ElementSVG: ElementSVG,
|
|
3511
3187
|
G_SVG_PREFIX: G_SVG_PREFIX,
|
|
3512
3188
|
Plugin: Plugin$1,
|
|
3513
3189
|
SHAPE2TAGS: SHAPE2TAGS,
|
|
3190
|
+
SHAPE_UPDATE_DEPS: SHAPE_UPDATE_DEPS,
|
|
3514
3191
|
get SVGRendererPlugin () { return SVGRendererPlugin; },
|
|
3515
3192
|
SVG_ATTR_MAP: SVG_ATTR_MAP,
|
|
3516
3193
|
containerModule: containerModule$1,
|
|
3517
|
-
createSVGElement: createSVGElement
|
|
3194
|
+
createSVGElement: createSVGElement,
|
|
3195
|
+
updateImageElementAttribute: updateImageElementAttribute,
|
|
3196
|
+
updateLineElementAttribute: updateLineElementAttribute,
|
|
3197
|
+
updatePathElementAttribute: updatePathElementAttribute,
|
|
3198
|
+
updatePolylineElementAttribute: updatePolylineElementAttribute,
|
|
3199
|
+
updateRectElementAttribute: updateRectElementAttribute,
|
|
3200
|
+
updateTextElementAttribute: updateTextElementAttribute
|
|
3518
3201
|
});
|
|
3519
3202
|
|
|
3520
3203
|
function _regeneratorRuntime$2() {
|
|
@@ -3642,7 +3325,7 @@
|
|
|
3642
3325
|
if ("throw" !== record.type) {
|
|
3643
3326
|
var result = record.arg,
|
|
3644
3327
|
value = result.value;
|
|
3645
|
-
return value && "object" ==
|
|
3328
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
3646
3329
|
invoke("next", value, resolve, reject);
|
|
3647
3330
|
}, function (err) {
|
|
3648
3331
|
invoke("throw", err, resolve, reject);
|
|
@@ -3903,41 +3586,16 @@
|
|
|
3903
3586
|
};
|
|
3904
3587
|
}
|
|
3905
3588
|
|
|
3906
|
-
function
|
|
3907
|
-
if (!(instance instanceof Constructor)) {
|
|
3908
|
-
throw new TypeError("Cannot call a class as a function");
|
|
3909
|
-
}
|
|
3910
|
-
}
|
|
3911
|
-
|
|
3912
|
-
function _defineProperties$3(target, props) {
|
|
3913
|
-
for (var i = 0; i < props.length; i++) {
|
|
3914
|
-
var descriptor = props[i];
|
|
3915
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
3916
|
-
descriptor.configurable = true;
|
|
3917
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
3918
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
3919
|
-
}
|
|
3920
|
-
}
|
|
3921
|
-
|
|
3922
|
-
function _createClass$3(Constructor, protoProps, staticProps) {
|
|
3923
|
-
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
3924
|
-
if (staticProps) _defineProperties$3(Constructor, staticProps);
|
|
3925
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
3926
|
-
writable: false
|
|
3927
|
-
});
|
|
3928
|
-
return Constructor;
|
|
3929
|
-
}
|
|
3930
|
-
|
|
3931
|
-
function _unsupportedIterableToArray$1(o, minLen) {
|
|
3589
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
3932
3590
|
if (!o) return;
|
|
3933
|
-
if (typeof o === "string") return _arrayLikeToArray
|
|
3591
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
3934
3592
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3935
3593
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
3936
3594
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
3937
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray
|
|
3595
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
3938
3596
|
}
|
|
3939
3597
|
|
|
3940
|
-
function _arrayLikeToArray
|
|
3598
|
+
function _arrayLikeToArray(arr, len) {
|
|
3941
3599
|
if (len == null || len > arr.length) len = arr.length;
|
|
3942
3600
|
|
|
3943
3601
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
@@ -3947,61 +3605,25 @@
|
|
|
3947
3605
|
return arr2;
|
|
3948
3606
|
}
|
|
3949
3607
|
|
|
3950
|
-
function
|
|
3608
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
3951
3609
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
3610
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
3952
3611
|
|
|
3953
|
-
if (
|
|
3954
|
-
if (
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3612
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
3613
|
+
if (it) o = it;
|
|
3614
|
+
var i = 0;
|
|
3615
|
+
return function () {
|
|
3616
|
+
if (i >= o.length) return {
|
|
3617
|
+
done: true
|
|
3618
|
+
};
|
|
3960
3619
|
return {
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
if (i >= o.length) return {
|
|
3964
|
-
done: true
|
|
3965
|
-
};
|
|
3966
|
-
return {
|
|
3967
|
-
done: false,
|
|
3968
|
-
value: o[i++]
|
|
3969
|
-
};
|
|
3970
|
-
},
|
|
3971
|
-
e: function e(_e) {
|
|
3972
|
-
throw _e;
|
|
3973
|
-
},
|
|
3974
|
-
f: F
|
|
3620
|
+
done: false,
|
|
3621
|
+
value: o[i++]
|
|
3975
3622
|
};
|
|
3976
|
-
}
|
|
3977
|
-
|
|
3978
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3623
|
+
};
|
|
3979
3624
|
}
|
|
3980
3625
|
|
|
3981
|
-
|
|
3982
|
-
didErr = false,
|
|
3983
|
-
err;
|
|
3984
|
-
return {
|
|
3985
|
-
s: function s() {
|
|
3986
|
-
it = it.call(o);
|
|
3987
|
-
},
|
|
3988
|
-
n: function n() {
|
|
3989
|
-
var step = it.next();
|
|
3990
|
-
normalCompletion = step.done;
|
|
3991
|
-
return step;
|
|
3992
|
-
},
|
|
3993
|
-
e: function e(_e2) {
|
|
3994
|
-
didErr = true;
|
|
3995
|
-
err = _e2;
|
|
3996
|
-
},
|
|
3997
|
-
f: function f() {
|
|
3998
|
-
try {
|
|
3999
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
4000
|
-
} finally {
|
|
4001
|
-
if (didErr) throw err;
|
|
4002
|
-
}
|
|
4003
|
-
}
|
|
4004
|
-
};
|
|
3626
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4005
3627
|
}
|
|
4006
3628
|
|
|
4007
3629
|
var _class$2;
|
|
@@ -4016,120 +3638,98 @@
|
|
|
4016
3638
|
|
|
4017
3639
|
var SVGPickerPlugin = SVGPickerPlugin_1 = (_class$2 = /*#__PURE__*/function () {
|
|
4018
3640
|
function SVGPickerPlugin() {
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
this.sceneGraphService = void 0;
|
|
3641
|
+
this.canvasConfig = void 0;
|
|
4022
3642
|
this.displayObjectPool = void 0;
|
|
4023
3643
|
}
|
|
4024
3644
|
|
|
4025
|
-
|
|
4026
|
-
key: "apply",
|
|
4027
|
-
value: function apply(renderingService) {
|
|
4028
|
-
var _this = this;
|
|
4029
|
-
|
|
4030
|
-
renderingService.hooks.pick.tapPromise(SVGPickerPlugin_1.tag, /*#__PURE__*/function () {
|
|
4031
|
-
var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
|
|
4032
|
-
var topmost, _result$position, clientX, clientY, targets, _iterator, _step, element, id, index, target;
|
|
4033
|
-
|
|
4034
|
-
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
4035
|
-
while (1) {
|
|
4036
|
-
switch (_context.prev = _context.next) {
|
|
4037
|
-
case 0:
|
|
4038
|
-
topmost = result.topmost, _result$position = result.position, clientX = _result$position.clientX, clientY = _result$position.clientY;
|
|
4039
|
-
_context.prev = 1;
|
|
4040
|
-
targets = []; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
|
|
3645
|
+
var _proto = SVGPickerPlugin.prototype;
|
|
4041
3646
|
|
|
4042
|
-
|
|
4043
|
-
|
|
3647
|
+
_proto.apply = function apply(renderingService) {
|
|
3648
|
+
var _this = this;
|
|
4044
3649
|
|
|
4045
|
-
|
|
3650
|
+
var doc = this.canvasConfig.document;
|
|
3651
|
+
renderingService.hooks.pick.tapPromise(SVGPickerPlugin_1.tag, /*#__PURE__*/function () {
|
|
3652
|
+
var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
|
|
3653
|
+
var topmost, _result$position, clientX, clientY, targets, _iterator, _step, element, id, index, target;
|
|
4046
3654
|
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
id = element && element.getAttribute('id');
|
|
4056
|
-
|
|
4057
|
-
if (!(id && id.startsWith(G_SVG_PREFIX))) {
|
|
4058
|
-
_context.next = 17;
|
|
4059
|
-
break;
|
|
4060
|
-
}
|
|
4061
|
-
|
|
4062
|
-
index = id.lastIndexOf('_');
|
|
4063
|
-
target = _this.displayObjectPool.getByEntity(Number(id.substring(index + 1))); // don't need to account for `visibility` since DOM API already does
|
|
3655
|
+
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
3656
|
+
while (1) {
|
|
3657
|
+
switch (_context.prev = _context.next) {
|
|
3658
|
+
case 0:
|
|
3659
|
+
topmost = result.topmost, _result$position = result.position, clientX = _result$position.clientX, clientY = _result$position.clientY;
|
|
3660
|
+
_context.prev = 1;
|
|
3661
|
+
targets = []; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
|
|
4064
3662
|
|
|
4065
|
-
|
|
4066
|
-
_context.next = 17;
|
|
4067
|
-
break;
|
|
4068
|
-
}
|
|
3663
|
+
_iterator = _createForOfIteratorHelperLoose((doc || document).elementsFromPoint(clientX, clientY));
|
|
4069
3664
|
|
|
4070
|
-
|
|
3665
|
+
case 4:
|
|
3666
|
+
if ((_step = _iterator()).done) {
|
|
3667
|
+
_context.next = 17;
|
|
3668
|
+
break;
|
|
3669
|
+
}
|
|
4071
3670
|
|
|
4072
|
-
|
|
4073
|
-
_context.next = 17;
|
|
4074
|
-
break;
|
|
4075
|
-
}
|
|
3671
|
+
element = _step.value; // eg. g_svg_circle_345
|
|
4076
3672
|
|
|
4077
|
-
|
|
4078
|
-
return _context.abrupt("return", result);
|
|
3673
|
+
id = element && element.getAttribute('id');
|
|
4079
3674
|
|
|
4080
|
-
|
|
4081
|
-
_context.next =
|
|
3675
|
+
if (!(id && id.startsWith(G_SVG_PREFIX))) {
|
|
3676
|
+
_context.next = 15;
|
|
4082
3677
|
break;
|
|
3678
|
+
}
|
|
4083
3679
|
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
break;
|
|
3680
|
+
index = id.lastIndexOf('_');
|
|
3681
|
+
target = _this.displayObjectPool.getByEntity(Number(id.substring(index + 1))); // don't need to account for `visibility` since DOM API already does
|
|
4087
3682
|
|
|
4088
|
-
|
|
4089
|
-
_context.
|
|
4090
|
-
|
|
3683
|
+
if (!(target && target.isInteractive())) {
|
|
3684
|
+
_context.next = 15;
|
|
3685
|
+
break;
|
|
3686
|
+
}
|
|
4091
3687
|
|
|
4092
|
-
|
|
3688
|
+
targets.push(target);
|
|
4093
3689
|
|
|
4094
|
-
|
|
4095
|
-
_context.
|
|
3690
|
+
if (!topmost) {
|
|
3691
|
+
_context.next = 15;
|
|
3692
|
+
break;
|
|
3693
|
+
}
|
|
4096
3694
|
|
|
4097
|
-
|
|
3695
|
+
result.picked = targets;
|
|
3696
|
+
return _context.abrupt("return", result);
|
|
4098
3697
|
|
|
4099
|
-
|
|
3698
|
+
case 15:
|
|
3699
|
+
_context.next = 4;
|
|
3700
|
+
break;
|
|
4100
3701
|
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
3702
|
+
case 17:
|
|
3703
|
+
result.picked = targets;
|
|
3704
|
+
_context.next = 23;
|
|
3705
|
+
break;
|
|
4105
3706
|
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
3707
|
+
case 20:
|
|
3708
|
+
_context.prev = 20;
|
|
3709
|
+
_context.t0 = _context["catch"](1);
|
|
3710
|
+
result.picked = [];
|
|
4110
3711
|
|
|
4111
|
-
|
|
4112
|
-
|
|
3712
|
+
case 23:
|
|
3713
|
+
return _context.abrupt("return", result);
|
|
4113
3714
|
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
}
|
|
3715
|
+
case 24:
|
|
3716
|
+
case "end":
|
|
3717
|
+
return _context.stop();
|
|
4118
3718
|
}
|
|
4119
|
-
}
|
|
4120
|
-
})
|
|
3719
|
+
}
|
|
3720
|
+
}, _callee, null, [[1, 20]]);
|
|
3721
|
+
}));
|
|
4121
3722
|
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
}]);
|
|
3723
|
+
return function (_x) {
|
|
3724
|
+
return _ref.apply(this, arguments);
|
|
3725
|
+
};
|
|
3726
|
+
}());
|
|
3727
|
+
};
|
|
4128
3728
|
|
|
4129
3729
|
return SVGPickerPlugin;
|
|
4130
3730
|
}(), _class$2.tag = 'SVGPicker', _class$2);
|
|
4131
3731
|
|
|
4132
|
-
__decorate([manaSyringe.inject(g.
|
|
3732
|
+
__decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], SVGPickerPlugin.prototype, "canvasConfig", void 0);
|
|
4133
3733
|
|
|
4134
3734
|
__decorate([manaSyringe.inject(g.DisplayObjectPool), __metadata("design:type", g.DisplayObjectPool)], SVGPickerPlugin.prototype, "displayObjectPool", void 0);
|
|
4135
3735
|
|
|
@@ -4142,22 +3742,18 @@
|
|
|
4142
3742
|
|
|
4143
3743
|
var Plugin$2 = /*#__PURE__*/function () {
|
|
4144
3744
|
function Plugin() {
|
|
4145
|
-
_classCallCheck$3(this, Plugin);
|
|
4146
|
-
|
|
4147
3745
|
this.name = 'svg-picker';
|
|
4148
3746
|
}
|
|
4149
3747
|
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
}
|
|
4160
|
-
}]);
|
|
3748
|
+
var _proto = Plugin.prototype;
|
|
3749
|
+
|
|
3750
|
+
_proto.init = function init(container) {
|
|
3751
|
+
container.load(containerModule$2, true);
|
|
3752
|
+
};
|
|
3753
|
+
|
|
3754
|
+
_proto.destroy = function destroy(container) {
|
|
3755
|
+
container.unload(containerModule$2);
|
|
3756
|
+
};
|
|
4161
3757
|
|
|
4162
3758
|
return Plugin;
|
|
4163
3759
|
}();
|
|
@@ -4169,84 +3765,76 @@
|
|
|
4169
3765
|
|
|
4170
3766
|
var SVGContextService = /*#__PURE__*/function () {
|
|
4171
3767
|
function SVGContextService() {
|
|
4172
|
-
_classCallCheck(this, SVGContextService);
|
|
4173
|
-
|
|
4174
3768
|
this.$container = void 0;
|
|
4175
3769
|
this.$namespace = void 0;
|
|
4176
3770
|
this.dpr = void 0;
|
|
4177
3771
|
this.canvasConfig = void 0;
|
|
4178
3772
|
}
|
|
4179
3773
|
|
|
4180
|
-
|
|
4181
|
-
key: "init",
|
|
4182
|
-
value: function init() {
|
|
4183
|
-
var container = this.canvasConfig.container; // create container
|
|
3774
|
+
var _proto = SVGContextService.prototype;
|
|
4184
3775
|
|
|
4185
|
-
|
|
3776
|
+
_proto.init = function init() {
|
|
3777
|
+
var _this$canvasConfig = this.canvasConfig,
|
|
3778
|
+
container = _this$canvasConfig.container,
|
|
3779
|
+
doc = _this$canvasConfig.document; // create container
|
|
4186
3780
|
|
|
4187
|
-
|
|
4188
|
-
if (!this.$container.style.position) {
|
|
4189
|
-
this.$container.style.position = 'relative';
|
|
4190
|
-
}
|
|
3781
|
+
this.$container = g.isString(container) ? (doc || document).getElementById(container) : container;
|
|
4191
3782
|
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
this.$container.appendChild($namespace);
|
|
4196
|
-
this.$namespace = $namespace;
|
|
3783
|
+
if (this.$container) {
|
|
3784
|
+
if (!this.$container.style.position) {
|
|
3785
|
+
this.$container.style.position = 'relative';
|
|
4197
3786
|
}
|
|
4198
3787
|
|
|
4199
|
-
var
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
}, {
|
|
4205
|
-
key: "getDomElement",
|
|
4206
|
-
value: function getDomElement() {
|
|
4207
|
-
return this.$namespace;
|
|
4208
|
-
}
|
|
4209
|
-
}, {
|
|
4210
|
-
key: "getContext",
|
|
4211
|
-
value: function getContext() {
|
|
4212
|
-
return this.$namespace;
|
|
4213
|
-
}
|
|
4214
|
-
}, {
|
|
4215
|
-
key: "getDPR",
|
|
4216
|
-
value: function getDPR() {
|
|
4217
|
-
return this.dpr;
|
|
3788
|
+
var $namespace = createSVGElement('svg', doc);
|
|
3789
|
+
$namespace.setAttribute('width', "" + this.canvasConfig.width);
|
|
3790
|
+
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
3791
|
+
this.$container.appendChild($namespace);
|
|
3792
|
+
this.$namespace = $namespace;
|
|
4218
3793
|
}
|
|
4219
|
-
}, {
|
|
4220
|
-
key: "getBoundingClientRect",
|
|
4221
|
-
value: function getBoundingClientRect() {
|
|
4222
|
-
var _this$$namespace;
|
|
4223
3794
|
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
3795
|
+
var dpr = window.devicePixelRatio || 1;
|
|
3796
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
3797
|
+
this.dpr = dpr;
|
|
3798
|
+
} // @ts-ignore
|
|
3799
|
+
;
|
|
3800
|
+
|
|
3801
|
+
_proto.getDomElement = function getDomElement() {
|
|
3802
|
+
return this.$namespace;
|
|
3803
|
+
};
|
|
3804
|
+
|
|
3805
|
+
_proto.getContext = function getContext() {
|
|
3806
|
+
return this.$namespace;
|
|
3807
|
+
};
|
|
3808
|
+
|
|
3809
|
+
_proto.getDPR = function getDPR() {
|
|
3810
|
+
return this.dpr;
|
|
3811
|
+
};
|
|
3812
|
+
|
|
3813
|
+
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
3814
|
+
var _this$$namespace;
|
|
3815
|
+
|
|
3816
|
+
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
3817
|
+
};
|
|
3818
|
+
|
|
3819
|
+
_proto.destroy = function destroy() {
|
|
3820
|
+
// destroy context
|
|
3821
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
3822
|
+
this.$container.removeChild(this.$namespace);
|
|
4233
3823
|
}
|
|
4234
|
-
}
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
}
|
|
3824
|
+
};
|
|
3825
|
+
|
|
3826
|
+
_proto.resize = function resize(width, height) {
|
|
3827
|
+
if (this.$namespace) {
|
|
3828
|
+
this.$namespace.setAttribute('width', "" + width);
|
|
3829
|
+
this.$namespace.setAttribute('height', "" + height);
|
|
4241
3830
|
}
|
|
4242
|
-
}
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
}
|
|
3831
|
+
};
|
|
3832
|
+
|
|
3833
|
+
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
3834
|
+
if (this.$container) {
|
|
3835
|
+
this.$container.style.cursor = cursor;
|
|
4248
3836
|
}
|
|
4249
|
-
}
|
|
3837
|
+
};
|
|
4250
3838
|
|
|
4251
3839
|
return SVGContextService;
|
|
4252
3840
|
}();
|
|
@@ -4265,37 +3853,29 @@
|
|
|
4265
3853
|
});
|
|
4266
3854
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
4267
3855
|
function ContextRegisterPlugin() {
|
|
4268
|
-
_classCallCheck(this, ContextRegisterPlugin);
|
|
4269
|
-
|
|
4270
3856
|
this.name = 'svg-context-register';
|
|
4271
3857
|
}
|
|
4272
3858
|
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
}
|
|
4283
|
-
}]);
|
|
3859
|
+
var _proto = ContextRegisterPlugin.prototype;
|
|
3860
|
+
|
|
3861
|
+
_proto.init = function init(container) {
|
|
3862
|
+
container.load(containerModule$3, true);
|
|
3863
|
+
};
|
|
3864
|
+
|
|
3865
|
+
_proto.destroy = function destroy(container) {
|
|
3866
|
+
container.unload(containerModule$3);
|
|
3867
|
+
};
|
|
4284
3868
|
|
|
4285
3869
|
return ContextRegisterPlugin;
|
|
4286
3870
|
}();
|
|
4287
3871
|
|
|
4288
3872
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
var _super = _createSuper(Renderer);
|
|
3873
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
4292
3874
|
|
|
4293
3875
|
function Renderer(config) {
|
|
4294
3876
|
var _this;
|
|
4295
3877
|
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
_this = _super.call(this, config);
|
|
3878
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
4299
3879
|
|
|
4300
3880
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
4301
3881
|
|
|
@@ -4308,7 +3888,7 @@
|
|
|
4308
3888
|
return _this;
|
|
4309
3889
|
}
|
|
4310
3890
|
|
|
4311
|
-
return
|
|
3891
|
+
return Renderer;
|
|
4312
3892
|
}(g.AbstractRenderer);
|
|
4313
3893
|
|
|
4314
3894
|
exports.DomInteraction = index_esm;
|