@antv/g-svg 1.8.27 → 1.8.29
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 +227 -114
- package/dist/index.js +227 -114
- package/dist/index.umd.js +1657 -1087
- package/dist/index.umd.min.js +1 -1
- package/package.json +5 -5
package/dist/index.umd.js
CHANGED
|
@@ -139,14 +139,9 @@
|
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
function maybeInvokeDelegate(delegate, context) {
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
146
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
147
|
-
}
|
|
148
|
-
return ContinueSentinel;
|
|
149
|
-
}
|
|
142
|
+
var methodName = context.method,
|
|
143
|
+
method = delegate.iterator[methodName];
|
|
144
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
150
145
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
151
146
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
152
147
|
var info = record.arg;
|
|
@@ -310,6 +305,15 @@
|
|
|
310
305
|
}
|
|
311
306
|
}, exports;
|
|
312
307
|
}
|
|
308
|
+
function _typeof(obj) {
|
|
309
|
+
"@babel/helpers - typeof";
|
|
310
|
+
|
|
311
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
312
|
+
return typeof obj;
|
|
313
|
+
} : function (obj) {
|
|
314
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
315
|
+
}, _typeof(obj);
|
|
316
|
+
}
|
|
313
317
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
314
318
|
try {
|
|
315
319
|
var info = gen[key](arg);
|
|
@@ -340,10 +344,49 @@
|
|
|
340
344
|
});
|
|
341
345
|
};
|
|
342
346
|
}
|
|
343
|
-
function
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
+
function _classCallCheck(instance, Constructor) {
|
|
348
|
+
if (!(instance instanceof Constructor)) {
|
|
349
|
+
throw new TypeError("Cannot call a class as a function");
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function _defineProperties(target, props) {
|
|
353
|
+
for (var i = 0; i < props.length; i++) {
|
|
354
|
+
var descriptor = props[i];
|
|
355
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
356
|
+
descriptor.configurable = true;
|
|
357
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
358
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
362
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
363
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
364
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
365
|
+
writable: false
|
|
366
|
+
});
|
|
367
|
+
return Constructor;
|
|
368
|
+
}
|
|
369
|
+
function _inherits(subClass, superClass) {
|
|
370
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
371
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
372
|
+
}
|
|
373
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
374
|
+
constructor: {
|
|
375
|
+
value: subClass,
|
|
376
|
+
writable: true,
|
|
377
|
+
configurable: true
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
Object.defineProperty(subClass, "prototype", {
|
|
381
|
+
writable: false
|
|
382
|
+
});
|
|
383
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
384
|
+
}
|
|
385
|
+
function _getPrototypeOf(o) {
|
|
386
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
387
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
388
|
+
};
|
|
389
|
+
return _getPrototypeOf(o);
|
|
347
390
|
}
|
|
348
391
|
function _setPrototypeOf(o, p) {
|
|
349
392
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -352,6 +395,59 @@
|
|
|
352
395
|
};
|
|
353
396
|
return _setPrototypeOf(o, p);
|
|
354
397
|
}
|
|
398
|
+
function _isNativeReflectConstruct() {
|
|
399
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
400
|
+
if (Reflect.construct.sham) return false;
|
|
401
|
+
if (typeof Proxy === "function") return true;
|
|
402
|
+
try {
|
|
403
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
404
|
+
return true;
|
|
405
|
+
} catch (e) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
function _assertThisInitialized(self) {
|
|
410
|
+
if (self === void 0) {
|
|
411
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
412
|
+
}
|
|
413
|
+
return self;
|
|
414
|
+
}
|
|
415
|
+
function _possibleConstructorReturn(self, call) {
|
|
416
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
417
|
+
return call;
|
|
418
|
+
} else if (call !== void 0) {
|
|
419
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
420
|
+
}
|
|
421
|
+
return _assertThisInitialized(self);
|
|
422
|
+
}
|
|
423
|
+
function _createSuper(Derived) {
|
|
424
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
425
|
+
return function _createSuperInternal() {
|
|
426
|
+
var Super = _getPrototypeOf(Derived),
|
|
427
|
+
result;
|
|
428
|
+
if (hasNativeReflectConstruct) {
|
|
429
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
430
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
431
|
+
} else {
|
|
432
|
+
result = Super.apply(this, arguments);
|
|
433
|
+
}
|
|
434
|
+
return _possibleConstructorReturn(this, result);
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
function _toPrimitive(input, hint) {
|
|
438
|
+
if (typeof input !== "object" || input === null) return input;
|
|
439
|
+
var prim = input[Symbol.toPrimitive];
|
|
440
|
+
if (prim !== undefined) {
|
|
441
|
+
var res = prim.call(input, hint || "default");
|
|
442
|
+
if (typeof res !== "object") return res;
|
|
443
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
444
|
+
}
|
|
445
|
+
return (hint === "string" ? String : Number)(input);
|
|
446
|
+
}
|
|
447
|
+
function _toPropertyKey(arg) {
|
|
448
|
+
var key = _toPrimitive(arg, "string");
|
|
449
|
+
return typeof key === "symbol" ? key : String(key);
|
|
450
|
+
}
|
|
355
451
|
|
|
356
452
|
function _regeneratorRuntime$1() {
|
|
357
453
|
_regeneratorRuntime$1 = function _regeneratorRuntime() {
|
|
@@ -429,7 +525,7 @@
|
|
|
429
525
|
if ("throw" !== record.type) {
|
|
430
526
|
var result = record.arg,
|
|
431
527
|
value = result.value;
|
|
432
|
-
return value && "object" ==
|
|
528
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
433
529
|
invoke("next", value, resolve, reject);
|
|
434
530
|
}, function (err) {
|
|
435
531
|
invoke("throw", err, resolve, reject);
|
|
@@ -488,14 +584,9 @@
|
|
|
488
584
|
};
|
|
489
585
|
}
|
|
490
586
|
function maybeInvokeDelegate(delegate, context) {
|
|
491
|
-
var
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
495
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
496
|
-
}
|
|
497
|
-
return ContinueSentinel;
|
|
498
|
-
}
|
|
587
|
+
var methodName = context.method,
|
|
588
|
+
method = delegate.iterator[methodName];
|
|
589
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
499
590
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
500
591
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
501
592
|
var info = record.arg;
|
|
@@ -695,10 +786,49 @@
|
|
|
695
786
|
});
|
|
696
787
|
};
|
|
697
788
|
}
|
|
698
|
-
function
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
789
|
+
function _classCallCheck$1(instance, Constructor) {
|
|
790
|
+
if (!(instance instanceof Constructor)) {
|
|
791
|
+
throw new TypeError("Cannot call a class as a function");
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
function _defineProperties$1(target, props) {
|
|
795
|
+
for (var i = 0; i < props.length; i++) {
|
|
796
|
+
var descriptor = props[i];
|
|
797
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
798
|
+
descriptor.configurable = true;
|
|
799
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
800
|
+
Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
function _createClass$1(Constructor, protoProps, staticProps) {
|
|
804
|
+
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
805
|
+
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
806
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
807
|
+
writable: false
|
|
808
|
+
});
|
|
809
|
+
return Constructor;
|
|
810
|
+
}
|
|
811
|
+
function _inherits$1(subClass, superClass) {
|
|
812
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
813
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
814
|
+
}
|
|
815
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
816
|
+
constructor: {
|
|
817
|
+
value: subClass,
|
|
818
|
+
writable: true,
|
|
819
|
+
configurable: true
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
Object.defineProperty(subClass, "prototype", {
|
|
823
|
+
writable: false
|
|
824
|
+
});
|
|
825
|
+
if (superClass) _setPrototypeOf$1(subClass, superClass);
|
|
826
|
+
}
|
|
827
|
+
function _getPrototypeOf$1(o) {
|
|
828
|
+
_getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
829
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
830
|
+
};
|
|
831
|
+
return _getPrototypeOf$1(o);
|
|
702
832
|
}
|
|
703
833
|
function _setPrototypeOf$1(o, p) {
|
|
704
834
|
_setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -707,6 +837,59 @@
|
|
|
707
837
|
};
|
|
708
838
|
return _setPrototypeOf$1(o, p);
|
|
709
839
|
}
|
|
840
|
+
function _isNativeReflectConstruct$1() {
|
|
841
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
842
|
+
if (Reflect.construct.sham) return false;
|
|
843
|
+
if (typeof Proxy === "function") return true;
|
|
844
|
+
try {
|
|
845
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
846
|
+
return true;
|
|
847
|
+
} catch (e) {
|
|
848
|
+
return false;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
function _assertThisInitialized$1(self) {
|
|
852
|
+
if (self === void 0) {
|
|
853
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
854
|
+
}
|
|
855
|
+
return self;
|
|
856
|
+
}
|
|
857
|
+
function _possibleConstructorReturn$1(self, call) {
|
|
858
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
859
|
+
return call;
|
|
860
|
+
} else if (call !== void 0) {
|
|
861
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
862
|
+
}
|
|
863
|
+
return _assertThisInitialized$1(self);
|
|
864
|
+
}
|
|
865
|
+
function _createSuper$1(Derived) {
|
|
866
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
|
|
867
|
+
return function _createSuperInternal() {
|
|
868
|
+
var Super = _getPrototypeOf$1(Derived),
|
|
869
|
+
result;
|
|
870
|
+
if (hasNativeReflectConstruct) {
|
|
871
|
+
var NewTarget = _getPrototypeOf$1(this).constructor;
|
|
872
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
873
|
+
} else {
|
|
874
|
+
result = Super.apply(this, arguments);
|
|
875
|
+
}
|
|
876
|
+
return _possibleConstructorReturn$1(this, result);
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
function _toPrimitive$1(input, hint) {
|
|
880
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
881
|
+
var prim = input[Symbol.toPrimitive];
|
|
882
|
+
if (prim !== undefined) {
|
|
883
|
+
var res = prim.call(input, hint || "default");
|
|
884
|
+
if (_typeof(res) !== "object") return res;
|
|
885
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
886
|
+
}
|
|
887
|
+
return (hint === "string" ? String : Number)(input);
|
|
888
|
+
}
|
|
889
|
+
function _toPropertyKey$1(arg) {
|
|
890
|
+
var key = _toPrimitive$1(arg, "string");
|
|
891
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
892
|
+
}
|
|
710
893
|
|
|
711
894
|
// const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
712
895
|
/**
|
|
@@ -714,156 +897,165 @@
|
|
|
714
897
|
*/
|
|
715
898
|
var DOMInteractionPlugin = /*#__PURE__*/function () {
|
|
716
899
|
function DOMInteractionPlugin() {
|
|
900
|
+
_classCallCheck$1(this, DOMInteractionPlugin);
|
|
717
901
|
this.context = void 0;
|
|
718
902
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
$el
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
$el
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
903
|
+
_createClass$1(DOMInteractionPlugin, [{
|
|
904
|
+
key: "apply",
|
|
905
|
+
value: function apply(context) {
|
|
906
|
+
var _this = this;
|
|
907
|
+
var renderingService = context.renderingService,
|
|
908
|
+
renderingContext = context.renderingContext;
|
|
909
|
+
this.context = context;
|
|
910
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
911
|
+
// const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
912
|
+
var onPointerMove = function onPointerMove(ev) {
|
|
913
|
+
renderingService.hooks.pointerMove.call(ev);
|
|
914
|
+
};
|
|
915
|
+
var onPointerUp = function onPointerUp(ev) {
|
|
916
|
+
renderingService.hooks.pointerUp.call(ev);
|
|
917
|
+
};
|
|
918
|
+
var onPointerDown = function onPointerDown(ev) {
|
|
919
|
+
renderingService.hooks.pointerDown.call(ev);
|
|
920
|
+
};
|
|
921
|
+
var onPointerOver = function onPointerOver(ev) {
|
|
922
|
+
renderingService.hooks.pointerOver.call(ev);
|
|
923
|
+
};
|
|
924
|
+
var onPointerOut = function onPointerOut(ev) {
|
|
925
|
+
renderingService.hooks.pointerOut.call(ev);
|
|
926
|
+
};
|
|
927
|
+
var onPointerCancel = function onPointerCancel(ev) {
|
|
928
|
+
renderingService.hooks.pointerCancel.call(ev);
|
|
929
|
+
};
|
|
930
|
+
var onPointerWheel = function onPointerWheel(ev) {
|
|
931
|
+
renderingService.hooks.pointerWheel.call(ev);
|
|
932
|
+
};
|
|
933
|
+
var addPointerEventListener = function addPointerEventListener($el) {
|
|
934
|
+
globalThis.document.addEventListener('pointermove', onPointerMove, true);
|
|
935
|
+
$el.addEventListener('pointerdown', onPointerDown, true);
|
|
936
|
+
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
937
|
+
$el.addEventListener('pointerover', onPointerOver, true);
|
|
938
|
+
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
939
|
+
};
|
|
940
|
+
var addTouchEventListener = function addTouchEventListener($el) {
|
|
941
|
+
$el.addEventListener('touchstart', onPointerDown, true);
|
|
942
|
+
$el.addEventListener('touchend', onPointerUp, true);
|
|
943
|
+
$el.addEventListener('touchmove', onPointerMove, true);
|
|
944
|
+
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
945
|
+
};
|
|
946
|
+
var addMouseEventListener = function addMouseEventListener($el) {
|
|
947
|
+
globalThis.document.addEventListener('mousemove', onPointerMove, true);
|
|
948
|
+
$el.addEventListener('mousedown', onPointerDown, true);
|
|
949
|
+
$el.addEventListener('mouseout', onPointerOut, true);
|
|
950
|
+
$el.addEventListener('mouseover', onPointerOver, true);
|
|
951
|
+
globalThis.addEventListener('mouseup', onPointerUp, true);
|
|
952
|
+
};
|
|
953
|
+
var removePointerEventListener = function removePointerEventListener($el) {
|
|
954
|
+
globalThis.document.removeEventListener('pointermove', onPointerMove, true);
|
|
955
|
+
$el.removeEventListener('pointerdown', onPointerDown, true);
|
|
956
|
+
$el.removeEventListener('pointerleave', onPointerOut, true);
|
|
957
|
+
$el.removeEventListener('pointerover', onPointerOver, true);
|
|
958
|
+
globalThis.removeEventListener('pointerup', onPointerUp, true);
|
|
959
|
+
};
|
|
960
|
+
var removeTouchEventListener = function removeTouchEventListener($el) {
|
|
961
|
+
$el.removeEventListener('touchstart', onPointerDown, true);
|
|
962
|
+
$el.removeEventListener('touchend', onPointerUp, true);
|
|
963
|
+
$el.removeEventListener('touchmove', onPointerMove, true);
|
|
964
|
+
$el.removeEventListener('touchcancel', onPointerCancel, true);
|
|
965
|
+
};
|
|
966
|
+
var removeMouseEventListener = function removeMouseEventListener($el) {
|
|
967
|
+
globalThis.document.removeEventListener('mousemove', onPointerMove, true);
|
|
968
|
+
$el.removeEventListener('mousedown', onPointerDown, true);
|
|
969
|
+
$el.removeEventListener('mouseout', onPointerOut, true);
|
|
970
|
+
$el.removeEventListener('mouseover', onPointerOver, true);
|
|
971
|
+
globalThis.removeEventListener('mouseup', onPointerUp, true);
|
|
972
|
+
};
|
|
973
|
+
renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
974
|
+
var $el;
|
|
975
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
976
|
+
while (1) {
|
|
977
|
+
switch (_context.prev = _context.next) {
|
|
978
|
+
case 0:
|
|
979
|
+
$el = _this.context.contextService.getDomElement(); // @ts-ignore
|
|
980
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
981
|
+
// @ts-ignore
|
|
982
|
+
$el.style.msContentZooming = 'none';
|
|
983
|
+
// @ts-ignore
|
|
984
|
+
$el.style.msTouchAction = 'none';
|
|
985
|
+
} else if (canvas.supportsPointerEvents) {
|
|
986
|
+
$el.style.touchAction = 'none';
|
|
987
|
+
}
|
|
988
|
+
if (canvas.supportsPointerEvents) {
|
|
989
|
+
addPointerEventListener($el);
|
|
990
|
+
} else {
|
|
991
|
+
addMouseEventListener($el);
|
|
992
|
+
}
|
|
993
|
+
if (canvas.supportsTouchEvents) {
|
|
994
|
+
addTouchEventListener($el);
|
|
995
|
+
}
|
|
996
|
+
// use passive event listeners
|
|
997
|
+
// @see https://zhuanlan.zhihu.com/p/24555031
|
|
998
|
+
$el.addEventListener('wheel', onPointerWheel, {
|
|
999
|
+
passive: true,
|
|
1000
|
+
capture: true
|
|
1001
|
+
});
|
|
1002
|
+
case 5:
|
|
1003
|
+
case "end":
|
|
1004
|
+
return _context.stop();
|
|
1005
|
+
}
|
|
820
1006
|
}
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
var $el = _this.context.contextService.getDomElement();
|
|
826
|
-
// @ts-ignore
|
|
827
|
-
if (globalThis.navigator.msPointerEnabled) {
|
|
828
|
-
// @ts-ignore
|
|
829
|
-
$el.style.msContentZooming = '';
|
|
1007
|
+
}, _callee);
|
|
1008
|
+
})));
|
|
1009
|
+
renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
|
|
1010
|
+
var $el = _this.context.contextService.getDomElement();
|
|
830
1011
|
// @ts-ignore
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
1012
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
1013
|
+
// @ts-ignore
|
|
1014
|
+
$el.style.msContentZooming = '';
|
|
1015
|
+
// @ts-ignore
|
|
1016
|
+
$el.style.msTouchAction = '';
|
|
1017
|
+
} else if (canvas.supportsPointerEvents) {
|
|
1018
|
+
$el.style.touchAction = '';
|
|
1019
|
+
}
|
|
1020
|
+
if (canvas.supportsPointerEvents) {
|
|
1021
|
+
removePointerEventListener($el);
|
|
1022
|
+
} else {
|
|
1023
|
+
removeMouseEventListener($el);
|
|
1024
|
+
}
|
|
1025
|
+
if (canvas.supportsTouchEvents) {
|
|
1026
|
+
removeTouchEventListener($el);
|
|
1027
|
+
}
|
|
1028
|
+
$el.removeEventListener('wheel', onPointerWheel, true);
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
}]);
|
|
846
1032
|
return DOMInteractionPlugin;
|
|
847
1033
|
}();
|
|
848
1034
|
DOMInteractionPlugin.tag = 'DOMInteraction';
|
|
849
1035
|
var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
850
|
-
|
|
1036
|
+
_inherits$1(Plugin, _AbstractRendererPlug);
|
|
1037
|
+
var _super = _createSuper$1(Plugin);
|
|
851
1038
|
function Plugin() {
|
|
852
1039
|
var _this;
|
|
1040
|
+
_classCallCheck$1(this, Plugin);
|
|
853
1041
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
854
1042
|
args[_key] = arguments[_key];
|
|
855
1043
|
}
|
|
856
|
-
_this =
|
|
1044
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
857
1045
|
_this.name = 'dom-interaction';
|
|
858
1046
|
return _this;
|
|
859
1047
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
1048
|
+
_createClass$1(Plugin, [{
|
|
1049
|
+
key: "init",
|
|
1050
|
+
value: function init() {
|
|
1051
|
+
this.addRenderingPlugin(new DOMInteractionPlugin());
|
|
1052
|
+
}
|
|
1053
|
+
}, {
|
|
1054
|
+
key: "destroy",
|
|
1055
|
+
value: function destroy() {
|
|
1056
|
+
this.removeAllRenderingPlugins();
|
|
1057
|
+
}
|
|
1058
|
+
}]);
|
|
867
1059
|
return Plugin;
|
|
868
1060
|
}(gLite.AbstractRendererPlugin);
|
|
869
1061
|
|
|
@@ -1219,6 +1411,56 @@
|
|
|
1219
1411
|
return output;
|
|
1220
1412
|
}
|
|
1221
1413
|
|
|
1414
|
+
function _iterableToArrayLimit(arr, i) {
|
|
1415
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1416
|
+
if (null != _i) {
|
|
1417
|
+
var _s,
|
|
1418
|
+
_e,
|
|
1419
|
+
_x,
|
|
1420
|
+
_r,
|
|
1421
|
+
_arr = [],
|
|
1422
|
+
_n = !0,
|
|
1423
|
+
_d = !1;
|
|
1424
|
+
try {
|
|
1425
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
1426
|
+
if (Object(_i) !== _i) return;
|
|
1427
|
+
_n = !1;
|
|
1428
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) {
|
|
1429
|
+
;
|
|
1430
|
+
}
|
|
1431
|
+
} catch (err) {
|
|
1432
|
+
_d = !0, _e = err;
|
|
1433
|
+
} finally {
|
|
1434
|
+
try {
|
|
1435
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
1436
|
+
} finally {
|
|
1437
|
+
if (_d) throw _e;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
return _arr;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
function ownKeys(object, enumerableOnly) {
|
|
1444
|
+
var keys = Object.keys(object);
|
|
1445
|
+
if (Object.getOwnPropertySymbols) {
|
|
1446
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
1447
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
1448
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1449
|
+
})), keys.push.apply(keys, symbols);
|
|
1450
|
+
}
|
|
1451
|
+
return keys;
|
|
1452
|
+
}
|
|
1453
|
+
function _objectSpread2(target) {
|
|
1454
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1455
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
1456
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
1457
|
+
_defineProperty(target, key, source[key]);
|
|
1458
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
1459
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
return target;
|
|
1463
|
+
}
|
|
1222
1464
|
function _regeneratorRuntime$2() {
|
|
1223
1465
|
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
1224
1466
|
return exports;
|
|
@@ -1295,7 +1537,7 @@
|
|
|
1295
1537
|
if ("throw" !== record.type) {
|
|
1296
1538
|
var result = record.arg,
|
|
1297
1539
|
value = result.value;
|
|
1298
|
-
return value && "object" ==
|
|
1540
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1299
1541
|
invoke("next", value, resolve, reject);
|
|
1300
1542
|
}, function (err) {
|
|
1301
1543
|
invoke("throw", err, resolve, reject);
|
|
@@ -1354,14 +1596,9 @@
|
|
|
1354
1596
|
};
|
|
1355
1597
|
}
|
|
1356
1598
|
function maybeInvokeDelegate(delegate, context) {
|
|
1357
|
-
var
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
1361
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
1362
|
-
}
|
|
1363
|
-
return ContinueSentinel;
|
|
1364
|
-
}
|
|
1599
|
+
var methodName = context.method,
|
|
1600
|
+
method = delegate.iterator[methodName];
|
|
1601
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
1365
1602
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
1366
1603
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
1367
1604
|
var info = record.arg;
|
|
@@ -1561,24 +1798,63 @@
|
|
|
1561
1798
|
});
|
|
1562
1799
|
};
|
|
1563
1800
|
}
|
|
1564
|
-
function
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1801
|
+
function _classCallCheck$2(instance, Constructor) {
|
|
1802
|
+
if (!(instance instanceof Constructor)) {
|
|
1803
|
+
throw new TypeError("Cannot call a class as a function");
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
function _defineProperties$2(target, props) {
|
|
1807
|
+
for (var i = 0; i < props.length; i++) {
|
|
1808
|
+
var descriptor = props[i];
|
|
1809
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
1810
|
+
descriptor.configurable = true;
|
|
1811
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
1812
|
+
Object.defineProperty(target, _toPropertyKey$2(descriptor.key), descriptor);
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
function _createClass$2(Constructor, protoProps, staticProps) {
|
|
1816
|
+
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
1817
|
+
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
1818
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
1819
|
+
writable: false
|
|
1820
|
+
});
|
|
1821
|
+
return Constructor;
|
|
1822
|
+
}
|
|
1823
|
+
function _defineProperty(obj, key, value) {
|
|
1824
|
+
key = _toPropertyKey$2(key);
|
|
1825
|
+
if (key in obj) {
|
|
1826
|
+
Object.defineProperty(obj, key, {
|
|
1827
|
+
value: value,
|
|
1828
|
+
enumerable: true,
|
|
1829
|
+
configurable: true,
|
|
1830
|
+
writable: true
|
|
1831
|
+
});
|
|
1832
|
+
} else {
|
|
1833
|
+
obj[key] = value;
|
|
1834
|
+
}
|
|
1835
|
+
return obj;
|
|
1836
|
+
}
|
|
1837
|
+
function _inherits$2(subClass, superClass) {
|
|
1838
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
1839
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
1840
|
+
}
|
|
1841
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
1842
|
+
constructor: {
|
|
1843
|
+
value: subClass,
|
|
1844
|
+
writable: true,
|
|
1845
|
+
configurable: true
|
|
1573
1846
|
}
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1847
|
+
});
|
|
1848
|
+
Object.defineProperty(subClass, "prototype", {
|
|
1849
|
+
writable: false
|
|
1850
|
+
});
|
|
1851
|
+
if (superClass) _setPrototypeOf$2(subClass, superClass);
|
|
1577
1852
|
}
|
|
1578
|
-
function
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1853
|
+
function _getPrototypeOf$2(o) {
|
|
1854
|
+
_getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
1855
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
1856
|
+
};
|
|
1857
|
+
return _getPrototypeOf$2(o);
|
|
1582
1858
|
}
|
|
1583
1859
|
function _setPrototypeOf$2(o, p) {
|
|
1584
1860
|
_setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -1587,11 +1863,89 @@
|
|
|
1587
1863
|
};
|
|
1588
1864
|
return _setPrototypeOf$2(o, p);
|
|
1589
1865
|
}
|
|
1590
|
-
|
|
1866
|
+
function _isNativeReflectConstruct$2() {
|
|
1867
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
1868
|
+
if (Reflect.construct.sham) return false;
|
|
1869
|
+
if (typeof Proxy === "function") return true;
|
|
1870
|
+
try {
|
|
1871
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
1872
|
+
return true;
|
|
1873
|
+
} catch (e) {
|
|
1874
|
+
return false;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
function _assertThisInitialized$2(self) {
|
|
1878
|
+
if (self === void 0) {
|
|
1879
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1880
|
+
}
|
|
1881
|
+
return self;
|
|
1882
|
+
}
|
|
1883
|
+
function _possibleConstructorReturn$2(self, call) {
|
|
1884
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
1885
|
+
return call;
|
|
1886
|
+
} else if (call !== void 0) {
|
|
1887
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
1888
|
+
}
|
|
1889
|
+
return _assertThisInitialized$2(self);
|
|
1890
|
+
}
|
|
1891
|
+
function _createSuper$2(Derived) {
|
|
1892
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$2();
|
|
1893
|
+
return function _createSuperInternal() {
|
|
1894
|
+
var Super = _getPrototypeOf$2(Derived),
|
|
1895
|
+
result;
|
|
1896
|
+
if (hasNativeReflectConstruct) {
|
|
1897
|
+
var NewTarget = _getPrototypeOf$2(this).constructor;
|
|
1898
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
1899
|
+
} else {
|
|
1900
|
+
result = Super.apply(this, arguments);
|
|
1901
|
+
}
|
|
1902
|
+
return _possibleConstructorReturn$2(this, result);
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
function _slicedToArray(arr, i) {
|
|
1906
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
1907
|
+
}
|
|
1908
|
+
function _arrayWithHoles(arr) {
|
|
1909
|
+
if (Array.isArray(arr)) return arr;
|
|
1910
|
+
}
|
|
1911
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
1912
|
+
if (!o) return;
|
|
1913
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1914
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1915
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1916
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1917
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1918
|
+
}
|
|
1919
|
+
function _arrayLikeToArray(arr, len) {
|
|
1920
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1921
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1922
|
+
arr2[i] = arr[i];
|
|
1923
|
+
}
|
|
1924
|
+
return arr2;
|
|
1925
|
+
}
|
|
1926
|
+
function _nonIterableRest() {
|
|
1927
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1928
|
+
}
|
|
1929
|
+
function _toPrimitive$2(input, hint) {
|
|
1930
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
1931
|
+
var prim = input[Symbol.toPrimitive];
|
|
1932
|
+
if (prim !== undefined) {
|
|
1933
|
+
var res = prim.call(input, hint || "default");
|
|
1934
|
+
if (_typeof(res) !== "object") return res;
|
|
1935
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1936
|
+
}
|
|
1937
|
+
return (hint === "string" ? String : Number)(input);
|
|
1938
|
+
}
|
|
1939
|
+
function _toPropertyKey$2(arg) {
|
|
1940
|
+
var key = _toPrimitive$2(arg, "string");
|
|
1941
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
1942
|
+
}
|
|
1943
|
+
var ElementSVG = /*#__PURE__*/_createClass$2(function ElementSVG() {
|
|
1944
|
+
_classCallCheck$2(this, ElementSVG);
|
|
1591
1945
|
this.$el = void 0;
|
|
1592
1946
|
this.$groupEl = void 0;
|
|
1593
1947
|
this.$hitTestingEl = void 0;
|
|
1594
|
-
};
|
|
1948
|
+
});
|
|
1595
1949
|
ElementSVG.tag = 'c-svg-element';
|
|
1596
1950
|
function updateImageElementAttribute($el, parsedStyle) {
|
|
1597
1951
|
var _parsedStyle$img = parsedStyle.img,
|
|
@@ -1604,13 +1958,13 @@
|
|
|
1604
1958
|
$el.setAttribute('href', img);
|
|
1605
1959
|
} else if (img instanceof Image) {
|
|
1606
1960
|
if (!width) {
|
|
1607
|
-
$el.setAttribute('width', ""
|
|
1961
|
+
$el.setAttribute('width', "".concat(img.width));
|
|
1608
1962
|
// TODO: set renderable.boundsDirty
|
|
1609
1963
|
// this.attr('width', img.width);
|
|
1610
1964
|
}
|
|
1611
1965
|
|
|
1612
1966
|
if (!height) {
|
|
1613
|
-
$el.setAttribute('height', ""
|
|
1967
|
+
$el.setAttribute('height', "".concat(img.height));
|
|
1614
1968
|
// this.attr('height', img.height);
|
|
1615
1969
|
}
|
|
1616
1970
|
|
|
@@ -1623,21 +1977,21 @@
|
|
|
1623
1977
|
} else if (img instanceof ImageData) {
|
|
1624
1978
|
var canvas = document.createElement('canvas');
|
|
1625
1979
|
// @ts-ignore
|
|
1626
|
-
canvas.setAttribute('width', ""
|
|
1980
|
+
canvas.setAttribute('width', "".concat(img.width));
|
|
1627
1981
|
// @ts-ignore
|
|
1628
|
-
canvas.setAttribute('height', ""
|
|
1982
|
+
canvas.setAttribute('height', "".concat(img.height));
|
|
1629
1983
|
var context = canvas.getContext('2d');
|
|
1630
1984
|
if (context) {
|
|
1631
1985
|
context.putImageData(img, 0, 0);
|
|
1632
1986
|
if (!width) {
|
|
1633
1987
|
// @ts-ignore
|
|
1634
|
-
$el.setAttribute('width', ""
|
|
1988
|
+
$el.setAttribute('width', "".concat(img.width));
|
|
1635
1989
|
// this.attr('width', img.width);
|
|
1636
1990
|
}
|
|
1637
1991
|
|
|
1638
1992
|
if (!height) {
|
|
1639
1993
|
// @ts-ignore
|
|
1640
|
-
$el.setAttribute('height', ""
|
|
1994
|
+
$el.setAttribute('height', "".concat(img.height));
|
|
1641
1995
|
// this.attr('height', img.height);
|
|
1642
1996
|
}
|
|
1643
1997
|
|
|
@@ -1680,10 +2034,10 @@
|
|
|
1680
2034
|
endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
|
|
1681
2035
|
}
|
|
1682
2036
|
// @see https://github.com/antvis/g/issues/1038
|
|
1683
|
-
$el.setAttribute('x1', ""
|
|
1684
|
-
$el.setAttribute('y1', ""
|
|
1685
|
-
$el.setAttribute('x2', ""
|
|
1686
|
-
$el.setAttribute('y2', ""
|
|
2037
|
+
$el.setAttribute('x1', "".concat(x1 - defX + startOffsetX));
|
|
2038
|
+
$el.setAttribute('y1', "".concat(y1 - defY + startOffsetY));
|
|
2039
|
+
$el.setAttribute('x2', "".concat(x2 - defX + endOffsetX));
|
|
2040
|
+
$el.setAttribute('y2', "".concat(y2 - defY + endOffsetY));
|
|
1687
2041
|
}
|
|
1688
2042
|
function updatePathElementAttribute($el, parsedStyle) {
|
|
1689
2043
|
var path = parsedStyle.path,
|
|
@@ -1704,8 +2058,9 @@
|
|
|
1704
2058
|
var y;
|
|
1705
2059
|
if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
|
|
1706
2060
|
var _markerStart$parentNo = markerStart.parentNode.getStartTangent(),
|
|
1707
|
-
|
|
1708
|
-
|
|
2061
|
+
_markerStart$parentNo2 = _slicedToArray(_markerStart$parentNo, 2),
|
|
2062
|
+
p1 = _markerStart$parentNo2[0],
|
|
2063
|
+
p2 = _markerStart$parentNo2[1];
|
|
1709
2064
|
x = p1[0] - p2[0];
|
|
1710
2065
|
y = p1[1] - p2[1];
|
|
1711
2066
|
rad = Math.atan2(y, x);
|
|
@@ -1714,8 +2069,9 @@
|
|
|
1714
2069
|
}
|
|
1715
2070
|
if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
|
|
1716
2071
|
var _markerEnd$parentNode = markerEnd.parentNode.getEndTangent(),
|
|
1717
|
-
|
|
1718
|
-
|
|
2072
|
+
_markerEnd$parentNode2 = _slicedToArray(_markerEnd$parentNode, 2),
|
|
2073
|
+
_p = _markerEnd$parentNode2[0],
|
|
2074
|
+
_p2 = _markerEnd$parentNode2[1];
|
|
1719
2075
|
x = _p[0] - _p2[0];
|
|
1720
2076
|
y = _p[1] - _p2[1];
|
|
1721
2077
|
rad = Math.atan2(y, x);
|
|
@@ -1767,7 +2123,7 @@
|
|
|
1767
2123
|
offsetX = endOffsetX;
|
|
1768
2124
|
offsetY = endOffsetY;
|
|
1769
2125
|
}
|
|
1770
|
-
return point[0] - defX + offsetX
|
|
2126
|
+
return "".concat(point[0] - defX + offsetX, ",").concat(point[1] - defY + offsetY);
|
|
1771
2127
|
}).join(' '));
|
|
1772
2128
|
}
|
|
1773
2129
|
}
|
|
@@ -1784,20 +2140,21 @@
|
|
|
1784
2140
|
});
|
|
1785
2141
|
var d = '';
|
|
1786
2142
|
if (!hasRadius) {
|
|
1787
|
-
d = "M 0,0 l "
|
|
2143
|
+
d = "M 0,0 l ".concat(width, ",0 l 0,").concat(height, " l").concat(-width, " 0 z");
|
|
1788
2144
|
} else {
|
|
1789
2145
|
var _radius$map = radius.map(function (r) {
|
|
1790
2146
|
return clamp(r, 0, Math.min(Math.abs(width) / 2, Math.abs(height) / 2));
|
|
1791
2147
|
}),
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
2148
|
+
_radius$map2 = _slicedToArray(_radius$map, 4),
|
|
2149
|
+
tlr = _radius$map2[0],
|
|
2150
|
+
trr = _radius$map2[1],
|
|
2151
|
+
brr = _radius$map2[2],
|
|
2152
|
+
blr = _radius$map2[3];
|
|
1796
2153
|
var signX = width > 0 ? 1 : -1;
|
|
1797
2154
|
var signY = height > 0 ? 1 : -1;
|
|
1798
2155
|
// sweep-flag @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths#arcs
|
|
1799
2156
|
var sweepFlag = signX + signY !== 0 ? 1 : 0;
|
|
1800
|
-
d = [["M "
|
|
2157
|
+
d = [["M ".concat(signX * tlr, ",0")], ["l ".concat(width - signX * (tlr + trr), ",0")], ["a ".concat(trr, ",").concat(trr, ",0,0,").concat(sweepFlag, ",").concat(signX * trr, ",").concat(signY * trr)], ["l 0,".concat(height - signY * (trr + brr))], ["a ".concat(brr, ",").concat(brr, ",0,0,").concat(sweepFlag, ",").concat(-signX * brr, ",").concat(signY * brr)], ["l ".concat(signX * (brr + blr) - width, ",0")], ["a ".concat(blr, ",").concat(blr, ",0,0,").concat(sweepFlag, ",").concat(-signX * blr, ",").concat(-signY * blr)], ["l 0,".concat(signY * (blr + tlr) - height)], ["a ".concat(tlr, ",").concat(tlr, ",0,0,").concat(sweepFlag, ",").concat(signX * tlr, ",").concat(-signY * tlr)], ['z']].join(' ');
|
|
1801
2158
|
}
|
|
1802
2159
|
$el.setAttribute('d', d);
|
|
1803
2160
|
}
|
|
@@ -1909,6 +2266,7 @@
|
|
|
1909
2266
|
var TEXT_PATH_PREFIX = 'text-path-';
|
|
1910
2267
|
var SVGRendererPlugin = /*#__PURE__*/function () {
|
|
1911
2268
|
function SVGRendererPlugin(pluginOptions, defElementManager, context) {
|
|
2269
|
+
_classCallCheck$2(this, SVGRendererPlugin);
|
|
1912
2270
|
this.pluginOptions = void 0;
|
|
1913
2271
|
this.defElementManager = void 0;
|
|
1914
2272
|
this.context = void 0;
|
|
@@ -1924,507 +2282,526 @@
|
|
|
1924
2282
|
/**
|
|
1925
2283
|
* <camera>
|
|
1926
2284
|
*/
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
var
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
var
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
var
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
if (!object.elementSVG) {
|
|
1951
|
-
return;
|
|
1952
|
-
}
|
|
1953
|
-
var attrName = e.attrName;
|
|
1954
|
-
var attribtues = _this.dirtyAttributes.get(object);
|
|
1955
|
-
if (!attribtues) {
|
|
1956
|
-
_this.dirtyAttributes.set(object, []);
|
|
1957
|
-
attribtues = _this.dirtyAttributes.get(object);
|
|
1958
|
-
}
|
|
1959
|
-
attribtues.push(attrName);
|
|
1960
|
-
};
|
|
1961
|
-
var handleGeometryBoundsChanged = function handleGeometryBoundsChanged(e) {
|
|
1962
|
-
var _object$elementSVG;
|
|
1963
|
-
var object = e.target;
|
|
1964
|
-
// @ts-ignore
|
|
1965
|
-
var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el;
|
|
1966
|
-
var _object$parsedStyle = object.parsedStyle,
|
|
1967
|
-
fill = _object$parsedStyle.fill,
|
|
1968
|
-
stroke = _object$parsedStyle.stroke;
|
|
1969
|
-
if (fill && !(fill instanceof gLite.CSSRGB)) {
|
|
1970
|
-
_this.defElementManager.createOrUpdateGradientAndPattern(object, $el, fill, 'fill', _this);
|
|
1971
|
-
}
|
|
1972
|
-
if (stroke && !(stroke instanceof gLite.CSSRGB)) {
|
|
1973
|
-
_this.defElementManager.createOrUpdateGradientAndPattern(object, $el, stroke, 'stroke', _this);
|
|
1974
|
-
}
|
|
1975
|
-
};
|
|
1976
|
-
renderingService.hooks.init.tapPromise(SVGRendererPlugin.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
|
|
1977
|
-
var _this$context$config, background, document, $svg;
|
|
1978
|
-
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
1979
|
-
while (1) {
|
|
1980
|
-
switch (_context.prev = _context.next) {
|
|
1981
|
-
case 0:
|
|
1982
|
-
_this$context$config = _this.context.config, background = _this$context$config.background, document = _this$context$config.document; // <defs>
|
|
1983
|
-
_this.defElementManager.init();
|
|
1984
|
-
$svg = _this.context.contextService.getContext();
|
|
1985
|
-
if (background) {
|
|
1986
|
-
$svg.style.background = background;
|
|
1987
|
-
}
|
|
1988
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
|
|
1989
|
-
$svg.setAttribute('color-interpolation-filters', 'sRGB');
|
|
1990
|
-
_this.$camera = createSVGElement('g', document);
|
|
1991
|
-
_this.$camera.id = G_SVG_PREFIX + "-camera";
|
|
1992
|
-
_this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
|
|
1993
|
-
$svg.appendChild(_this.$camera);
|
|
1994
|
-
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
1995
|
-
canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
1996
|
-
canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
1997
|
-
canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
1998
|
-
case 13:
|
|
1999
|
-
case "end":
|
|
2000
|
-
return _context.stop();
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
}, _callee);
|
|
2004
|
-
})));
|
|
2005
|
-
renderingService.hooks.destroy.tap(SVGRendererPlugin.tag, function () {
|
|
2006
|
-
canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
2007
|
-
canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
2008
|
-
canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
2009
|
-
canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
2010
|
-
});
|
|
2011
|
-
renderingService.hooks.render.tap(SVGRendererPlugin.tag, function (object) {
|
|
2012
|
-
// if (!object.isCulled()) {
|
|
2013
|
-
_this.renderQueue.push(object);
|
|
2014
|
-
// }
|
|
2015
|
-
});
|
|
2016
|
-
|
|
2017
|
-
renderingService.hooks.beginFrame.tap(SVGRendererPlugin.tag, function () {
|
|
2018
|
-
var doc = _this.context.config.document;
|
|
2019
|
-
if (_this.pendingReorderQueue.size) {
|
|
2020
|
-
_this.pendingReorderQueue.forEach(function (object) {
|
|
2021
|
-
var _object$elementSVG2;
|
|
2022
|
-
var children = ((object === null || object === void 0 ? void 0 : object.children) || []).slice();
|
|
2023
|
-
var $parentGroupEl =
|
|
2024
|
-
// @ts-ignore
|
|
2025
|
-
object === null || object === void 0 ? void 0 : (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
|
|
2026
|
-
if ($parentGroupEl) {
|
|
2027
|
-
_this.reorderChildren(doc || document, $parentGroupEl, children || []);
|
|
2028
|
-
}
|
|
2029
|
-
});
|
|
2030
|
-
_this.pendingReorderQueue.clear();
|
|
2031
|
-
}
|
|
2032
|
-
});
|
|
2033
|
-
renderingService.hooks.endFrame.tap(SVGRendererPlugin.tag, function () {
|
|
2034
|
-
if (renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
|
|
2035
|
-
_this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
|
|
2036
|
-
}
|
|
2037
|
-
_this.renderQueue.forEach(function (object) {
|
|
2038
|
-
var _object$elementSVG3, _object$elementSVG4;
|
|
2285
|
+
_createClass$2(SVGRendererPlugin, [{
|
|
2286
|
+
key: "apply",
|
|
2287
|
+
value: function apply(context) {
|
|
2288
|
+
var _this = this;
|
|
2289
|
+
var renderingService = context.renderingService,
|
|
2290
|
+
renderingContext = context.renderingContext;
|
|
2291
|
+
this.context = context;
|
|
2292
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
2293
|
+
var document = this.context.config.document;
|
|
2294
|
+
var handleMounted = function handleMounted(e) {
|
|
2295
|
+
var object = e.target;
|
|
2296
|
+
// create SVG DOM Node
|
|
2297
|
+
_this.createSVGDom(document, object, _this.$camera);
|
|
2298
|
+
};
|
|
2299
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
2300
|
+
var object = e.target;
|
|
2301
|
+
_this.defElementManager.clear(object.entity);
|
|
2302
|
+
_this.clipPathUseMap.delete(object);
|
|
2303
|
+
_this.removeSVGDom(object);
|
|
2304
|
+
};
|
|
2305
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
2306
|
+
var object = e.target;
|
|
2307
|
+
// @see https://github.com/antvis/g/issues/994
|
|
2039
2308
|
// @ts-ignore
|
|
2040
|
-
|
|
2309
|
+
if (!object.elementSVG) {
|
|
2310
|
+
return;
|
|
2311
|
+
}
|
|
2312
|
+
var attrName = e.attrName;
|
|
2313
|
+
var attribtues = _this.dirtyAttributes.get(object);
|
|
2314
|
+
if (!attribtues) {
|
|
2315
|
+
_this.dirtyAttributes.set(object, []);
|
|
2316
|
+
attribtues = _this.dirtyAttributes.get(object);
|
|
2317
|
+
}
|
|
2318
|
+
attribtues.push(attrName);
|
|
2319
|
+
};
|
|
2320
|
+
var handleGeometryBoundsChanged = function handleGeometryBoundsChanged(e) {
|
|
2321
|
+
var _object$elementSVG;
|
|
2322
|
+
var object = e.target;
|
|
2041
2323
|
// @ts-ignore
|
|
2042
|
-
var $
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
_this.
|
|
2048
|
-
// clipped shapes should also be informed
|
|
2049
|
-
var $useRefs = _this.clipPathUseMap.get(object);
|
|
2050
|
-
if ($useRefs && $useRefs.length) {
|
|
2051
|
-
$useRefs.forEach(function ($use) {
|
|
2052
|
-
// <clipPath transform="matrix()"><circle /></clipPath>
|
|
2053
|
-
_this.applyTransform($use, object.getWorldTransform());
|
|
2054
|
-
// const parentInvert = mat4.invert(
|
|
2055
|
-
// mat4.create(),
|
|
2056
|
-
// (object as DisplayObject).getWorldTransform(),
|
|
2057
|
-
// );
|
|
2058
|
-
// this.applyTransform($clipPath, parentInvert);
|
|
2059
|
-
});
|
|
2060
|
-
}
|
|
2061
|
-
// finish rendering, clear dirty flag
|
|
2062
|
-
object.renderable.dirty = false;
|
|
2324
|
+
var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el;
|
|
2325
|
+
var _object$parsedStyle = object.parsedStyle,
|
|
2326
|
+
fill = _object$parsedStyle.fill,
|
|
2327
|
+
stroke = _object$parsedStyle.stroke;
|
|
2328
|
+
if (fill && !(fill instanceof gLite.CSSRGB)) {
|
|
2329
|
+
_this.defElementManager.createOrUpdateGradientAndPattern(object, $el, fill, 'fill', _this);
|
|
2063
2330
|
}
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
_this.
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2331
|
+
if (stroke && !(stroke instanceof gLite.CSSRGB)) {
|
|
2332
|
+
_this.defElementManager.createOrUpdateGradientAndPattern(object, $el, stroke, 'stroke', _this);
|
|
2333
|
+
}
|
|
2334
|
+
};
|
|
2335
|
+
renderingService.hooks.init.tapPromise(SVGRendererPlugin.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
|
|
2336
|
+
var _this$context$config, background, document, $svg;
|
|
2337
|
+
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
2338
|
+
while (1) {
|
|
2339
|
+
switch (_context.prev = _context.next) {
|
|
2340
|
+
case 0:
|
|
2341
|
+
_this$context$config = _this.context.config, background = _this$context$config.background, document = _this$context$config.document; // <defs>
|
|
2342
|
+
_this.defElementManager.init();
|
|
2343
|
+
$svg = _this.context.contextService.getContext();
|
|
2344
|
+
if (background) {
|
|
2345
|
+
$svg.style.background = background;
|
|
2346
|
+
}
|
|
2347
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
|
|
2348
|
+
$svg.setAttribute('color-interpolation-filters', 'sRGB');
|
|
2349
|
+
_this.$camera = createSVGElement('g', document);
|
|
2350
|
+
_this.$camera.id = "".concat(G_SVG_PREFIX, "-camera");
|
|
2351
|
+
_this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
|
|
2352
|
+
$svg.appendChild(_this.$camera);
|
|
2353
|
+
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
2354
|
+
canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
2355
|
+
canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
2356
|
+
canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
2357
|
+
case 13:
|
|
2358
|
+
case "end":
|
|
2359
|
+
return _context.stop();
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
}, _callee);
|
|
2363
|
+
})));
|
|
2364
|
+
renderingService.hooks.destroy.tap(SVGRendererPlugin.tag, function () {
|
|
2365
|
+
canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
2366
|
+
canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
2367
|
+
canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
2368
|
+
canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
2369
|
+
});
|
|
2370
|
+
renderingService.hooks.render.tap(SVGRendererPlugin.tag, function (object) {
|
|
2371
|
+
// if (!object.isCulled()) {
|
|
2372
|
+
_this.renderQueue.push(object);
|
|
2373
|
+
// }
|
|
2374
|
+
});
|
|
2375
|
+
|
|
2376
|
+
renderingService.hooks.beginFrame.tap(SVGRendererPlugin.tag, function () {
|
|
2377
|
+
var doc = _this.context.config.document;
|
|
2378
|
+
if (_this.pendingReorderQueue.size) {
|
|
2379
|
+
_this.pendingReorderQueue.forEach(function (object) {
|
|
2380
|
+
var _object$elementSVG2;
|
|
2381
|
+
var children = ((object === null || object === void 0 ? void 0 : object.children) || []).slice();
|
|
2382
|
+
var $parentGroupEl =
|
|
2383
|
+
// @ts-ignore
|
|
2384
|
+
object === null || object === void 0 ? void 0 : (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
|
|
2385
|
+
if ($parentGroupEl) {
|
|
2386
|
+
_this.reorderChildren(doc || document, $parentGroupEl, children || []);
|
|
2079
2387
|
}
|
|
2080
|
-
_this.updateAttribute(object, [attrName]);
|
|
2081
2388
|
});
|
|
2082
|
-
_this.
|
|
2389
|
+
_this.pendingReorderQueue.clear();
|
|
2083
2390
|
}
|
|
2084
2391
|
});
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
_proto.reorderChildren = function reorderChildren(doc, $groupEl, children) {
|
|
2092
|
-
// need to reorder parent's children
|
|
2093
|
-
children.sort(function (a, b) {
|
|
2094
|
-
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
2095
|
-
});
|
|
2096
|
-
if (children.length) {
|
|
2097
|
-
// create empty fragment
|
|
2098
|
-
var fragment = (doc || document).createDocumentFragment();
|
|
2099
|
-
children.forEach(function (child) {
|
|
2100
|
-
if (child.isConnected) {
|
|
2392
|
+
renderingService.hooks.endFrame.tap(SVGRendererPlugin.tag, function () {
|
|
2393
|
+
if (renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
|
|
2394
|
+
_this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
|
|
2395
|
+
}
|
|
2396
|
+
_this.renderQueue.forEach(function (object) {
|
|
2397
|
+
var _object$elementSVG3, _object$elementSVG4;
|
|
2101
2398
|
// @ts-ignore
|
|
2102
|
-
var $el =
|
|
2103
|
-
|
|
2104
|
-
|
|
2399
|
+
var $el = (_object$elementSVG3 = object.elementSVG) === null || _object$elementSVG3 === void 0 ? void 0 : _object$elementSVG3.$el;
|
|
2400
|
+
// @ts-ignore
|
|
2401
|
+
var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
|
|
2402
|
+
if ($el && $groupEl) {
|
|
2403
|
+
// apply local RTS transformation to <group> wrapper
|
|
2404
|
+
// account for anchor
|
|
2405
|
+
var localTransform = object.getLocalTransform();
|
|
2406
|
+
_this.applyTransform($groupEl, localTransform);
|
|
2407
|
+
// clipped shapes should also be informed
|
|
2408
|
+
var $useRefs = _this.clipPathUseMap.get(object);
|
|
2409
|
+
if ($useRefs && $useRefs.length) {
|
|
2410
|
+
$useRefs.forEach(function ($use) {
|
|
2411
|
+
// <clipPath transform="matrix()"><circle /></clipPath>
|
|
2412
|
+
_this.applyTransform($use, object.getWorldTransform());
|
|
2413
|
+
// const parentInvert = mat4.invert(
|
|
2414
|
+
// mat4.create(),
|
|
2415
|
+
// (object as DisplayObject).getWorldTransform(),
|
|
2416
|
+
// );
|
|
2417
|
+
// this.applyTransform($clipPath, parentInvert);
|
|
2418
|
+
});
|
|
2419
|
+
}
|
|
2420
|
+
// finish rendering, clear dirty flag
|
|
2421
|
+
object.renderable.dirty = false;
|
|
2105
2422
|
}
|
|
2106
|
-
|
|
2423
|
+
// update dirty attributes
|
|
2424
|
+
var attributes = _this.dirtyAttributes.get(object);
|
|
2425
|
+
if (attributes) {
|
|
2426
|
+
attributes.forEach(function (attrName) {
|
|
2427
|
+
if (attrName === 'zIndex') {
|
|
2428
|
+
var _object$parentNode, _object$parentNode$el;
|
|
2429
|
+
var parent = object.parentNode;
|
|
2430
|
+
// @ts-ignore
|
|
2431
|
+
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;
|
|
2432
|
+
var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
|
|
2433
|
+
if (_$groupEl) {
|
|
2434
|
+
_this.reorderChildren(document, _$groupEl, children);
|
|
2435
|
+
}
|
|
2436
|
+
} else if (attrName === 'increasedLineWidthForHitTesting') {
|
|
2437
|
+
_this.createOrUpdateHitArea(object, $el, $groupEl);
|
|
2438
|
+
}
|
|
2439
|
+
_this.updateAttribute(object, [attrName]);
|
|
2440
|
+
});
|
|
2441
|
+
_this.dirtyAttributes.delete(object);
|
|
2442
|
+
}
|
|
2443
|
+
});
|
|
2444
|
+
_this.renderQueue = [];
|
|
2107
2445
|
});
|
|
2108
|
-
$groupEl.appendChild(fragment);
|
|
2109
2446
|
}
|
|
2110
|
-
}
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
$el.setAttribute('transform', "matrix(" + numberToLongString(rts[0]) + "," + numberToLongString(rts[1]) + "," + numberToLongString(rts[4]) + "," + numberToLongString(rts[5]) + "," + numberToLongString(rts[12]) + "," + numberToLongString(rts[13]) + ")");
|
|
2115
|
-
};
|
|
2116
|
-
_proto.applyAttributes = function applyAttributes(object) {
|
|
2117
|
-
// @ts-ignore
|
|
2118
|
-
var elementSVG = object.elementSVG;
|
|
2119
|
-
var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
|
|
2120
|
-
var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
|
|
2121
|
-
if ($el && $groupEl) {
|
|
2122
|
-
var nodeName = object.nodeName,
|
|
2123
|
-
attributes = object.attributes;
|
|
2124
|
-
$el.setAttribute('fill', 'none');
|
|
2125
|
-
if (nodeName === gLite.Shape.IMAGE) {
|
|
2126
|
-
$el.setAttribute('preserveAspectRatio', 'none');
|
|
2127
|
-
}
|
|
2128
|
-
// apply attributes
|
|
2129
|
-
this.updateAttribute(object, Object.keys(attributes));
|
|
2447
|
+
}, {
|
|
2448
|
+
key: "getId",
|
|
2449
|
+
value: function getId(object) {
|
|
2450
|
+
return "".concat(G_SVG_PREFIX, "-").concat(object.nodeName, "-").concat(object.entity);
|
|
2130
2451
|
}
|
|
2131
|
-
}
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2452
|
+
}, {
|
|
2453
|
+
key: "reorderChildren",
|
|
2454
|
+
value: function reorderChildren(doc, $groupEl, children) {
|
|
2455
|
+
// need to reorder parent's children
|
|
2456
|
+
children.sort(function (a, b) {
|
|
2457
|
+
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
2458
|
+
});
|
|
2459
|
+
if (children.length) {
|
|
2460
|
+
// create empty fragment
|
|
2461
|
+
var fragment = (doc || document).createDocumentFragment();
|
|
2462
|
+
children.forEach(function (child) {
|
|
2463
|
+
if (child.isConnected) {
|
|
2464
|
+
// @ts-ignore
|
|
2465
|
+
var $el = child.elementSVG.$groupEl;
|
|
2466
|
+
if ($el) {
|
|
2467
|
+
fragment.appendChild($el);
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
});
|
|
2471
|
+
$groupEl.appendChild(fragment);
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
}, {
|
|
2475
|
+
key: "applyTransform",
|
|
2476
|
+
value: function applyTransform($el, rts) {
|
|
2477
|
+
// use proper precision avoiding too long string in `transform`
|
|
2478
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
2479
|
+
$el.setAttribute('transform', "matrix(".concat(numberToLongString(rts[0]), ",").concat(numberToLongString(rts[1]), ",").concat(numberToLongString(rts[4]), ",").concat(numberToLongString(rts[5]), ",").concat(numberToLongString(rts[12]), ",").concat(numberToLongString(rts[13]), ")"));
|
|
2480
|
+
}
|
|
2481
|
+
}, {
|
|
2482
|
+
key: "applyAttributes",
|
|
2483
|
+
value: function applyAttributes(object) {
|
|
2484
|
+
// @ts-ignore
|
|
2485
|
+
var elementSVG = object.elementSVG;
|
|
2486
|
+
var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
|
|
2487
|
+
var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
|
|
2488
|
+
if ($el && $groupEl) {
|
|
2489
|
+
var nodeName = object.nodeName,
|
|
2490
|
+
attributes = object.attributes;
|
|
2491
|
+
$el.setAttribute('fill', 'none');
|
|
2492
|
+
if (nodeName === gLite.Shape.IMAGE) {
|
|
2493
|
+
$el.setAttribute('preserveAspectRatio', 'none');
|
|
2494
|
+
}
|
|
2495
|
+
// apply attributes
|
|
2496
|
+
this.updateAttribute(object, Object.keys(attributes));
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
}, {
|
|
2500
|
+
key: "updateAttribute",
|
|
2501
|
+
value: function updateAttribute(object, attributes) {
|
|
2502
|
+
var _this2 = this;
|
|
2503
|
+
var document = this.context.config.document;
|
|
2504
|
+
// @ts-ignore
|
|
2505
|
+
var _object$elementSVG5 = object.elementSVG,
|
|
2506
|
+
$el = _object$elementSVG5.$el,
|
|
2507
|
+
$groupEl = _object$elementSVG5.$groupEl,
|
|
2508
|
+
$hitTestingEl = _object$elementSVG5.$hitTestingEl;
|
|
2509
|
+
var parsedStyle = object.parsedStyle,
|
|
2510
|
+
computedStyle = object.computedStyle;
|
|
2511
|
+
var shouldUpdateElementAttribute = attributes.some(function (name) {
|
|
2512
|
+
return (
|
|
2152
2513
|
// @ts-ignore
|
|
2153
|
-
_this2.context.SVGElementLifeCycleContribution.
|
|
2514
|
+
_this2.context.SVGElementLifeCycleContribution.shouldUpdateElementAttribute(object, name)
|
|
2515
|
+
);
|
|
2516
|
+
});
|
|
2517
|
+
// need re-generate path
|
|
2518
|
+
if (shouldUpdateElementAttribute && $el) {
|
|
2519
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
2520
|
+
if ($el) {
|
|
2521
|
+
// @ts-ignore
|
|
2522
|
+
_this2.context.SVGElementLifeCycleContribution.updateElementAttribute(object, $el);
|
|
2523
|
+
if (object.nodeName !== gLite.Shape.TEXT) {
|
|
2524
|
+
_this2.updateAnchorWithTransform(object);
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
});
|
|
2528
|
+
}
|
|
2529
|
+
// update common attributes
|
|
2530
|
+
attributes.forEach(function (name) {
|
|
2531
|
+
var _FORMAT_VALUE_MAP$nam, _propertyMetadataCach;
|
|
2532
|
+
var usedName = SVG_ATTR_MAP[name];
|
|
2533
|
+
var computedValue = computedStyle[name];
|
|
2534
|
+
var computedValueStr = computedValue && computedValue.toString();
|
|
2535
|
+
var formattedValueStr = ((_FORMAT_VALUE_MAP$nam = FORMAT_VALUE_MAP[name]) === null || _FORMAT_VALUE_MAP$nam === void 0 ? void 0 : _FORMAT_VALUE_MAP$nam[computedValueStr]) || computedValueStr;
|
|
2536
|
+
var usedValue = parsedStyle[name];
|
|
2537
|
+
var inherited = !!((_propertyMetadataCach = gLite.propertyMetadataCache[name]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
|
|
2538
|
+
if (!usedName) {
|
|
2539
|
+
return;
|
|
2540
|
+
}
|
|
2541
|
+
// <foreignObject>
|
|
2542
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
2543
|
+
if (name === 'lineWidth') {
|
|
2544
|
+
$el.style['border-width'] = "".concat(usedValue || 0, "px");
|
|
2545
|
+
} else if (name === 'lineDash') {
|
|
2546
|
+
$el.style['border-style'] = 'dashed';
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
if (name === 'fill') {
|
|
2550
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
2551
|
+
$el.style.background = usedValue.toString();
|
|
2552
|
+
} else {
|
|
2553
|
+
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
|
|
2554
|
+
}
|
|
2555
|
+
} else if (name === 'stroke') {
|
|
2556
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
2557
|
+
$el.style['border-color'] = usedValue.toString();
|
|
2558
|
+
$el.style['border-style'] = 'solid';
|
|
2559
|
+
} else {
|
|
2560
|
+
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
|
|
2561
|
+
}
|
|
2562
|
+
} else if (inherited && usedName) {
|
|
2563
|
+
// use computed value
|
|
2564
|
+
// update `visibility` on <group>
|
|
2565
|
+
if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
2566
|
+
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, formattedValueStr);
|
|
2567
|
+
} else {
|
|
2568
|
+
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.removeAttribute(usedName);
|
|
2569
|
+
}
|
|
2570
|
+
} else if (name === 'clipPath') {
|
|
2571
|
+
_this2.createOrUpdateClipOrTextPath(document, usedValue, object);
|
|
2572
|
+
} else if (name === 'textPath') {
|
|
2573
|
+
_this2.createOrUpdateClipOrTextPath(document, usedValue, object, true);
|
|
2574
|
+
} else if (name === 'shadowType' || name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
|
|
2575
|
+
_this2.defElementManager.createOrUpdateShadow(object, $el, name);
|
|
2576
|
+
} else if (name === 'filter') {
|
|
2577
|
+
_this2.defElementManager.createOrUpdateFilter(object, $el, usedValue);
|
|
2578
|
+
} else if (name === 'innerHTML') {
|
|
2579
|
+
_this2.createOrUpdateInnerHTML(document, $el, usedValue);
|
|
2580
|
+
} else if (name === 'anchor') {
|
|
2581
|
+
// text' anchor is controlled by `textAnchor` property
|
|
2154
2582
|
if (object.nodeName !== gLite.Shape.TEXT) {
|
|
2155
2583
|
_this2.updateAnchorWithTransform(object);
|
|
2156
2584
|
}
|
|
2585
|
+
} else {
|
|
2586
|
+
if (computedValue) {
|
|
2587
|
+
// use computed value so that we can use cascaded effect in SVG
|
|
2588
|
+
// ignore 'unset' and default value
|
|
2589
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
2590
|
+
if ($el && usedName) {
|
|
2591
|
+
if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
2592
|
+
$el.setAttribute(usedName, formattedValueStr);
|
|
2593
|
+
} else {
|
|
2594
|
+
$el.removeAttribute(usedName);
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
});
|
|
2598
|
+
}
|
|
2157
2599
|
}
|
|
2158
2600
|
});
|
|
2159
2601
|
}
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
var
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
var
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
if (
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
$el.style['border-style'] = 'dashed';
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2180
|
-
if (name === 'fill') {
|
|
2602
|
+
}, {
|
|
2603
|
+
key: "createSVGDom",
|
|
2604
|
+
value: function createSVGDom(document, object, root) {
|
|
2605
|
+
var noWrapWithGroup = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
2606
|
+
// create svg element
|
|
2607
|
+
// @ts-ignore
|
|
2608
|
+
object.elementSVG = new ElementSVG();
|
|
2609
|
+
// @ts-ignore
|
|
2610
|
+
var svgElement = object.elementSVG;
|
|
2611
|
+
// use <group> as default, eg. CustomElement
|
|
2612
|
+
var $el =
|
|
2613
|
+
// @ts-ignore
|
|
2614
|
+
this.context.SVGElementLifeCycleContribution.createElement(object);
|
|
2615
|
+
if ($el) {
|
|
2616
|
+
var _object$parentNode$el2;
|
|
2617
|
+
var $groupEl;
|
|
2618
|
+
// save $el on parsedStyle, which will be returned in getDomElement()
|
|
2181
2619
|
if (object.nodeName === gLite.Shape.HTML) {
|
|
2182
|
-
|
|
2183
|
-
} else {
|
|
2184
|
-
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
|
|
2620
|
+
object.parsedStyle.$el = $el;
|
|
2185
2621
|
}
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
$el.style['border-color'] = usedValue.toString();
|
|
2189
|
-
$el.style['border-style'] = 'solid';
|
|
2190
|
-
} else {
|
|
2191
|
-
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
|
|
2622
|
+
if (this.pluginOptions.outputSVGElementId) {
|
|
2623
|
+
$el.id = this.getId(object);
|
|
2192
2624
|
}
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
// update `visibility` on <group>
|
|
2196
|
-
if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
2197
|
-
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, formattedValueStr);
|
|
2198
|
-
} else {
|
|
2199
|
-
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.removeAttribute(usedName);
|
|
2625
|
+
if (this.pluginOptions.outputSVGElementName && object.name) {
|
|
2626
|
+
$el.setAttribute('name', object.name);
|
|
2200
2627
|
}
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
_this2.defElementManager.createOrUpdateShadow(object, $el, name);
|
|
2207
|
-
} else if (name === 'filter') {
|
|
2208
|
-
_this2.defElementManager.createOrUpdateFilter(object, $el, usedValue);
|
|
2209
|
-
} else if (name === 'innerHTML') {
|
|
2210
|
-
_this2.createOrUpdateInnerHTML(document, $el, usedValue);
|
|
2211
|
-
} else if (name === 'anchor') {
|
|
2212
|
-
// text' anchor is controlled by `textAnchor` property
|
|
2213
|
-
if (object.nodeName !== gLite.Shape.TEXT) {
|
|
2214
|
-
_this2.updateAnchorWithTransform(object);
|
|
2628
|
+
if (($el.hasAttribute('data-wrapgroup') || $el.nodeName !== 'g') && !noWrapWithGroup) {
|
|
2629
|
+
$groupEl = createSVGElement('g', document);
|
|
2630
|
+
$groupEl.appendChild($el);
|
|
2631
|
+
} else {
|
|
2632
|
+
$groupEl = $el;
|
|
2215
2633
|
}
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2634
|
+
svgElement.$el = $el;
|
|
2635
|
+
svgElement.$groupEl = $groupEl;
|
|
2636
|
+
// apply attributes at first time
|
|
2637
|
+
this.applyAttributes(object);
|
|
2638
|
+
// create hitArea if necessary
|
|
2639
|
+
this.createOrUpdateHitArea(object, $el, $groupEl);
|
|
2640
|
+
var $parentGroupEl =
|
|
2641
|
+
// @ts-ignore
|
|
2642
|
+
object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl) || root;
|
|
2643
|
+
if ($parentGroupEl) {
|
|
2644
|
+
$parentGroupEl.appendChild($groupEl);
|
|
2645
|
+
// need reorder children later
|
|
2646
|
+
this.pendingReorderQueue.add(object.parentNode);
|
|
2229
2647
|
}
|
|
2230
2648
|
}
|
|
2231
|
-
});
|
|
2232
|
-
};
|
|
2233
|
-
_proto.createSVGDom = function createSVGDom(document, object, root, noWrapWithGroup) {
|
|
2234
|
-
if (noWrapWithGroup === void 0) {
|
|
2235
|
-
noWrapWithGroup = false;
|
|
2236
2649
|
}
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
var svgElement = object.elementSVG;
|
|
2242
|
-
// use <group> as default, eg. CustomElement
|
|
2243
|
-
var $el =
|
|
2244
|
-
// @ts-ignore
|
|
2245
|
-
this.context.SVGElementLifeCycleContribution.createElement(object);
|
|
2246
|
-
if ($el) {
|
|
2247
|
-
var _object$parentNode$el2;
|
|
2248
|
-
var $groupEl;
|
|
2249
|
-
// save $el on parsedStyle, which will be returned in getDomElement()
|
|
2250
|
-
if (object.nodeName === gLite.Shape.HTML) {
|
|
2251
|
-
object.parsedStyle.$el = $el;
|
|
2252
|
-
}
|
|
2253
|
-
if (this.pluginOptions.outputSVGElementId) {
|
|
2254
|
-
$el.id = this.getId(object);
|
|
2255
|
-
}
|
|
2256
|
-
if (this.pluginOptions.outputSVGElementName && object.name) {
|
|
2257
|
-
$el.setAttribute('name', object.name);
|
|
2258
|
-
}
|
|
2259
|
-
if (($el.hasAttribute('data-wrapgroup') || $el.nodeName !== 'g') && !noWrapWithGroup) {
|
|
2260
|
-
$groupEl = createSVGElement('g', document);
|
|
2261
|
-
$groupEl.appendChild($el);
|
|
2262
|
-
} else {
|
|
2263
|
-
$groupEl = $el;
|
|
2264
|
-
}
|
|
2265
|
-
svgElement.$el = $el;
|
|
2266
|
-
svgElement.$groupEl = $groupEl;
|
|
2267
|
-
// apply attributes at first time
|
|
2268
|
-
this.applyAttributes(object);
|
|
2269
|
-
// create hitArea if necessary
|
|
2270
|
-
this.createOrUpdateHitArea(object, $el, $groupEl);
|
|
2271
|
-
var $parentGroupEl =
|
|
2650
|
+
}, {
|
|
2651
|
+
key: "removeSVGDom",
|
|
2652
|
+
value: function removeSVGDom(object) {
|
|
2653
|
+
var _object$elementSVG6;
|
|
2272
2654
|
// @ts-ignore
|
|
2273
|
-
|
|
2274
|
-
if ($
|
|
2275
|
-
$
|
|
2276
|
-
//
|
|
2277
|
-
this.
|
|
2655
|
+
var $groupEl = (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$groupEl;
|
|
2656
|
+
if ($groupEl && $groupEl.parentNode) {
|
|
2657
|
+
$groupEl.parentNode.removeChild($groupEl);
|
|
2658
|
+
// @ts-ignore
|
|
2659
|
+
this.context.SVGElementLifeCycleContribution.destroyElement(object, $groupEl);
|
|
2660
|
+
// object.entity.removeComponent(ElementSVG, true);
|
|
2278
2661
|
}
|
|
2279
2662
|
}
|
|
2280
|
-
}
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
// @ts-ignore
|
|
2284
|
-
var $groupEl = (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$groupEl;
|
|
2285
|
-
if ($groupEl && $groupEl.parentNode) {
|
|
2286
|
-
$groupEl.parentNode.removeChild($groupEl);
|
|
2663
|
+
}, {
|
|
2664
|
+
key: "createOrUpdateHitArea",
|
|
2665
|
+
value: function createOrUpdateHitArea(object, $el, $groupEl) {
|
|
2287
2666
|
// @ts-ignore
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
//
|
|
2304
|
-
|
|
2667
|
+
var svgElement = object.elementSVG;
|
|
2668
|
+
var $hitTestingEl = svgElement.$hitTestingEl;
|
|
2669
|
+
var increasedLineWidthForHitTesting = object.parsedStyle.increasedLineWidthForHitTesting;
|
|
2670
|
+
// account for hitArea
|
|
2671
|
+
if (increasedLineWidthForHitTesting) {
|
|
2672
|
+
if (!$hitTestingEl) {
|
|
2673
|
+
$hitTestingEl = $el.cloneNode();
|
|
2674
|
+
if (this.pluginOptions.outputSVGElementId) {
|
|
2675
|
+
// use the entity suffix, so that `g-plugin-svg-picker` can extract
|
|
2676
|
+
$hitTestingEl.id = "".concat(G_SVG_PREFIX, "-").concat(object.nodeName, "-hittesting-").concat(object.entity);
|
|
2677
|
+
}
|
|
2678
|
+
// clear attributes like `filter` `font-size`
|
|
2679
|
+
['filter'].forEach(function (attribute) {
|
|
2680
|
+
$hitTestingEl.removeAttribute(attribute);
|
|
2681
|
+
});
|
|
2682
|
+
// hitArea should be 'transparent' but not 'none'
|
|
2683
|
+
var hasFill = $el.getAttribute('fill') !== 'none';
|
|
2684
|
+
$hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
|
|
2685
|
+
$hitTestingEl.setAttribute('stroke', 'transparent');
|
|
2686
|
+
$groupEl.appendChild($hitTestingEl);
|
|
2687
|
+
svgElement.$hitTestingEl = $hitTestingEl;
|
|
2688
|
+
}
|
|
2689
|
+
// increase interactive line width
|
|
2690
|
+
$hitTestingEl.setAttribute('stroke-width', "".concat(increasedLineWidthForHitTesting + object.parsedStyle.lineWidth));
|
|
2691
|
+
} else {
|
|
2692
|
+
if ($hitTestingEl) {
|
|
2693
|
+
$groupEl.removeChild($hitTestingEl);
|
|
2694
|
+
svgElement.$hitTestingEl = null;
|
|
2305
2695
|
}
|
|
2306
|
-
// clear attributes like `filter` `font-size`
|
|
2307
|
-
['filter'].forEach(function (attribute) {
|
|
2308
|
-
$hitTestingEl.removeAttribute(attribute);
|
|
2309
|
-
});
|
|
2310
|
-
// hitArea should be 'transparent' but not 'none'
|
|
2311
|
-
var hasFill = $el.getAttribute('fill') !== 'none';
|
|
2312
|
-
$hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
|
|
2313
|
-
$hitTestingEl.setAttribute('stroke', 'transparent');
|
|
2314
|
-
$groupEl.appendChild($hitTestingEl);
|
|
2315
|
-
svgElement.$hitTestingEl = $hitTestingEl;
|
|
2316
|
-
}
|
|
2317
|
-
// increase interactive line width
|
|
2318
|
-
$hitTestingEl.setAttribute('stroke-width', "" + (increasedLineWidthForHitTesting + object.parsedStyle.lineWidth));
|
|
2319
|
-
} else {
|
|
2320
|
-
if ($hitTestingEl) {
|
|
2321
|
-
$groupEl.removeChild($hitTestingEl);
|
|
2322
|
-
svgElement.$hitTestingEl = null;
|
|
2323
2696
|
}
|
|
2324
2697
|
}
|
|
2325
|
-
}
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
_proto.createOrUpdateClipOrTextPath = function createOrUpdateClipOrTextPath(document, clipPath, object, isTextPath) {
|
|
2337
|
-
if (isTextPath === void 0) {
|
|
2338
|
-
isTextPath = false;
|
|
2698
|
+
}, {
|
|
2699
|
+
key: "createOrUpdateInnerHTML",
|
|
2700
|
+
value: function createOrUpdateInnerHTML(doc, $el, usedValue) {
|
|
2701
|
+
var $div = (doc || document).createElement('div');
|
|
2702
|
+
if (typeof usedValue === 'string') {
|
|
2703
|
+
$div.innerHTML = usedValue;
|
|
2704
|
+
} else {
|
|
2705
|
+
$div.appendChild(usedValue);
|
|
2706
|
+
}
|
|
2707
|
+
$el.innerHTML = '';
|
|
2708
|
+
$el.appendChild($div);
|
|
2339
2709
|
}
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
var
|
|
2347
|
-
var
|
|
2348
|
-
var
|
|
2349
|
-
if (
|
|
2350
|
-
var
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2710
|
+
}, {
|
|
2711
|
+
key: "createOrUpdateClipOrTextPath",
|
|
2712
|
+
value: function createOrUpdateClipOrTextPath(document, clipPath, object) {
|
|
2713
|
+
var isTextPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
2714
|
+
// @ts-ignore
|
|
2715
|
+
var $groupEl = object.elementSVG.$groupEl;
|
|
2716
|
+
var PREFIX = isTextPath ? TEXT_PATH_PREFIX : CLIP_PATH_PREFIX;
|
|
2717
|
+
var attributeNameCamel = isTextPath ? 'g' : 'clipPath';
|
|
2718
|
+
var attributeNameHyphen = isTextPath ? 'text-path' : 'clip-path';
|
|
2719
|
+
if (clipPath) {
|
|
2720
|
+
var clipPathId = PREFIX + clipPath.entity + '-' + object.entity;
|
|
2721
|
+
var $def = this.defElementManager.getDefElement();
|
|
2722
|
+
var existed = $def.querySelector("#".concat(clipPathId));
|
|
2723
|
+
if (!existed) {
|
|
2724
|
+
var $clipPath;
|
|
2725
|
+
if (isTextPath) {
|
|
2726
|
+
// use <path> directly instead of wrapping with <g>
|
|
2727
|
+
this.createSVGDom(document, clipPath, null, true);
|
|
2728
|
+
// @ts-ignore
|
|
2729
|
+
$clipPath = clipPath.elementSVG.$el;
|
|
2730
|
+
} else {
|
|
2731
|
+
// the clipPath is allowed to be detached from canvas
|
|
2732
|
+
if (!clipPath.isConnected) {
|
|
2733
|
+
var $existedClipPath = $def.querySelector("#".concat(this.getId(clipPath)));
|
|
2734
|
+
if (!$existedClipPath) {
|
|
2735
|
+
this.createSVGDom(document, clipPath, $def, true);
|
|
2736
|
+
}
|
|
2362
2737
|
}
|
|
2738
|
+
// create <clipPath> dom node
|
|
2739
|
+
$clipPath = createSVGElement(attributeNameCamel, document);
|
|
2740
|
+
var $use = createSVGElement('use', document);
|
|
2741
|
+
// @ts-ignore
|
|
2742
|
+
$use.setAttribute('href', "#".concat(clipPath.elementSVG.$el.id));
|
|
2743
|
+
$clipPath.appendChild($use);
|
|
2744
|
+
var $useRefs = this.clipPathUseMap.get(clipPath);
|
|
2745
|
+
if (!$useRefs) {
|
|
2746
|
+
this.clipPathUseMap.set(clipPath, []);
|
|
2747
|
+
$useRefs = this.clipPathUseMap.get(clipPath);
|
|
2748
|
+
}
|
|
2749
|
+
$useRefs.push($use);
|
|
2750
|
+
// <clipPath transform="matrix()"><circle /></clipPath>
|
|
2751
|
+
this.applyTransform($use, clipPath.getWorldTransform());
|
|
2752
|
+
var parentInvert = invert(create(), object.getWorldTransform());
|
|
2753
|
+
this.applyTransform($clipPath, parentInvert);
|
|
2363
2754
|
}
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
// @ts-ignore
|
|
2368
|
-
$use.setAttribute('href', "#" + clipPath.elementSVG.$el.id);
|
|
2369
|
-
$clipPath.appendChild($use);
|
|
2370
|
-
var $useRefs = this.clipPathUseMap.get(clipPath);
|
|
2371
|
-
if (!$useRefs) {
|
|
2372
|
-
this.clipPathUseMap.set(clipPath, []);
|
|
2373
|
-
$useRefs = this.clipPathUseMap.get(clipPath);
|
|
2374
|
-
}
|
|
2375
|
-
$useRefs.push($use);
|
|
2376
|
-
// <clipPath transform="matrix()"><circle /></clipPath>
|
|
2377
|
-
this.applyTransform($use, clipPath.getWorldTransform());
|
|
2378
|
-
var parentInvert = invert(create(), object.getWorldTransform());
|
|
2379
|
-
this.applyTransform($clipPath, parentInvert);
|
|
2755
|
+
$clipPath.id = clipPathId;
|
|
2756
|
+
// append it to <defs>
|
|
2757
|
+
$def.appendChild($clipPath);
|
|
2380
2758
|
}
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
if (!isTextPath) {
|
|
2388
|
-
// apply clipPath to $group
|
|
2389
|
-
// @see https://github.com/antvis/g/issues/961
|
|
2390
|
-
$groupEl.setAttribute(attributeNameHyphen, "url(#" + clipPathId + ")");
|
|
2391
|
-
}
|
|
2392
|
-
} else {
|
|
2393
|
-
if (!isTextPath) {
|
|
2394
|
-
// remove clip path
|
|
2395
|
-
$groupEl.removeAttribute(attributeNameHyphen);
|
|
2396
|
-
}
|
|
2397
|
-
}
|
|
2398
|
-
}
|
|
2399
|
-
/**
|
|
2400
|
-
* the origin is bounding box's top left corner
|
|
2401
|
-
*/;
|
|
2402
|
-
_proto.updateAnchorWithTransform = function updateAnchorWithTransform(object) {
|
|
2403
|
-
var _object$elementSVG7, _object$elementSVG8;
|
|
2404
|
-
var bounds = object.getGeometryBounds();
|
|
2405
|
-
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
2406
|
-
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
2407
|
-
var _ref2 = object.parsedStyle || {},
|
|
2408
|
-
anchor = _ref2.anchor;
|
|
2409
|
-
// @ts-ignore
|
|
2410
|
-
[(_object$elementSVG7 = object.elementSVG) === null || _object$elementSVG7 === void 0 ? void 0 : _object$elementSVG7.$el, (_object$elementSVG8 = object.elementSVG) === null || _object$elementSVG8 === void 0 ? void 0 : _object$elementSVG8.$hitTestingEl].forEach(function ($el) {
|
|
2411
|
-
if ($el) {
|
|
2412
|
-
var tx = -(anchor[0] * width);
|
|
2413
|
-
var ty = -(anchor[1] * height);
|
|
2414
|
-
if (tx !== 0 || ty !== 0) {
|
|
2415
|
-
// apply anchor to element's `transform` property
|
|
2416
|
-
$el.setAttribute('transform',
|
|
2417
|
-
// can't use percent unit like translate(-50%, -50%)
|
|
2418
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
|
|
2419
|
-
"translate(" + tx + "," + ty + ")");
|
|
2759
|
+
// apply attributes
|
|
2760
|
+
this.applyAttributes(clipPath);
|
|
2761
|
+
if (!isTextPath) {
|
|
2762
|
+
// apply clipPath to $group
|
|
2763
|
+
// @see https://github.com/antvis/g/issues/961
|
|
2764
|
+
$groupEl.setAttribute(attributeNameHyphen, "url(#".concat(clipPathId, ")"));
|
|
2420
2765
|
}
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2766
|
+
} else {
|
|
2767
|
+
if (!isTextPath) {
|
|
2768
|
+
// remove clip path
|
|
2769
|
+
$groupEl.removeAttribute(attributeNameHyphen);
|
|
2424
2770
|
}
|
|
2425
2771
|
}
|
|
2426
|
-
}
|
|
2427
|
-
|
|
2772
|
+
}
|
|
2773
|
+
/**
|
|
2774
|
+
* the origin is bounding box's top left corner
|
|
2775
|
+
*/
|
|
2776
|
+
}, {
|
|
2777
|
+
key: "updateAnchorWithTransform",
|
|
2778
|
+
value: function updateAnchorWithTransform(object) {
|
|
2779
|
+
var _object$elementSVG7, _object$elementSVG8;
|
|
2780
|
+
var bounds = object.getGeometryBounds();
|
|
2781
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
2782
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
2783
|
+
var _ref2 = object.parsedStyle || {},
|
|
2784
|
+
anchor = _ref2.anchor;
|
|
2785
|
+
// @ts-ignore
|
|
2786
|
+
[(_object$elementSVG7 = object.elementSVG) === null || _object$elementSVG7 === void 0 ? void 0 : _object$elementSVG7.$el, (_object$elementSVG8 = object.elementSVG) === null || _object$elementSVG8 === void 0 ? void 0 : _object$elementSVG8.$hitTestingEl].forEach(function ($el) {
|
|
2787
|
+
if ($el) {
|
|
2788
|
+
var tx = -(anchor[0] * width);
|
|
2789
|
+
var ty = -(anchor[1] * height);
|
|
2790
|
+
if (tx !== 0 || ty !== 0) {
|
|
2791
|
+
// apply anchor to element's `transform` property
|
|
2792
|
+
$el.setAttribute('transform',
|
|
2793
|
+
// can't use percent unit like translate(-50%, -50%)
|
|
2794
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
|
|
2795
|
+
"translate(".concat(tx, ",").concat(ty, ")"));
|
|
2796
|
+
}
|
|
2797
|
+
if (object.nodeName === gLite.Shape.CIRCLE || object.nodeName === gLite.Shape.ELLIPSE) {
|
|
2798
|
+
$el.setAttribute('cx', "".concat(width / 2));
|
|
2799
|
+
$el.setAttribute('cy', "".concat(height / 2));
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
});
|
|
2803
|
+
}
|
|
2804
|
+
}]);
|
|
2428
2805
|
return SVGRendererPlugin;
|
|
2429
2806
|
}();
|
|
2430
2807
|
SVGRendererPlugin.tag = 'SVGRenderer';
|
|
@@ -2480,18 +2857,18 @@
|
|
|
2480
2857
|
var lineNum = lines.length;
|
|
2481
2858
|
var styleCSSText = '';
|
|
2482
2859
|
if (dx !== 0 || dy !== 0) {
|
|
2483
|
-
styleCSSText += "transform:translate("
|
|
2860
|
+
styleCSSText += "transform:translate(".concat(dx, "px, ").concat(dy, "px);");
|
|
2484
2861
|
}
|
|
2485
2862
|
if (textDecorationLine && textDecorationLine !== 'none') {
|
|
2486
2863
|
// use CSS text-decoration since the implementation in SVG is not good enough
|
|
2487
|
-
styleCSSText += "text-decoration:"
|
|
2864
|
+
styleCSSText += "text-decoration:".concat(textDecorationLine, " ").concat(textDecorationStyle, " ").concat(textDecorationColor, ";");
|
|
2488
2865
|
}
|
|
2489
2866
|
if (styleCSSText) {
|
|
2490
2867
|
$el.setAttribute('style', styleCSSText);
|
|
2491
2868
|
}
|
|
2492
2869
|
if (lineNum === 1) {
|
|
2493
2870
|
var textContent = convertHTML(lines[0]);
|
|
2494
|
-
$el.setAttribute('dx', ""
|
|
2871
|
+
$el.setAttribute('dx', "".concat(lineWidth / 2));
|
|
2495
2872
|
// <textPath> only support one line
|
|
2496
2873
|
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/textPath
|
|
2497
2874
|
if (textPath) {
|
|
@@ -2499,12 +2876,12 @@
|
|
|
2499
2876
|
$el.innerHTML = '';
|
|
2500
2877
|
// append <textPath href="#MyPath">text</textPath>
|
|
2501
2878
|
var $textPath = createSVGElement('textPath', $el.ownerDocument);
|
|
2502
|
-
$textPath.setAttribute('href', "#"
|
|
2879
|
+
$textPath.setAttribute('href', "#".concat(TEXT_PATH_PREFIX + textPath.entity));
|
|
2503
2880
|
if (textPathSide !== 'left') {
|
|
2504
2881
|
$textPath.setAttribute('side', textPathSide);
|
|
2505
2882
|
}
|
|
2506
2883
|
if (textPathStartOffset !== 0) {
|
|
2507
|
-
$textPath.setAttribute('startOffset', ""
|
|
2884
|
+
$textPath.setAttribute('startOffset', "".concat(textPathStartOffset));
|
|
2508
2885
|
}
|
|
2509
2886
|
$textPath.innerHTML = textContent;
|
|
2510
2887
|
$el.appendChild($textPath);
|
|
@@ -2527,70 +2904,79 @@
|
|
|
2527
2904
|
} else {
|
|
2528
2905
|
dy = lineHeight;
|
|
2529
2906
|
}
|
|
2530
|
-
return "<tspan x=\"0\" dx=\""
|
|
2907
|
+
return "<tspan x=\"0\" dx=\"".concat(dx, "\" dy=\"").concat(dy, "\">").concat(convertHTML(line), "</tspan>");
|
|
2531
2908
|
}).join('');
|
|
2532
2909
|
}
|
|
2533
2910
|
}
|
|
2534
2911
|
var _SHAPE2TAGS, _SHAPE_UPDATE_DEPS;
|
|
2535
|
-
var SHAPE2TAGS = (_SHAPE2TAGS = {}, _SHAPE2TAGS
|
|
2536
|
-
var SHAPE_UPDATE_DEPS = (_SHAPE_UPDATE_DEPS = {}, _SHAPE_UPDATE_DEPS
|
|
2912
|
+
var SHAPE2TAGS = (_SHAPE2TAGS = {}, _defineProperty(_SHAPE2TAGS, gLite.Shape.RECT, 'path'), _defineProperty(_SHAPE2TAGS, gLite.Shape.CIRCLE, 'circle'), _defineProperty(_SHAPE2TAGS, gLite.Shape.ELLIPSE, 'ellipse'), _defineProperty(_SHAPE2TAGS, gLite.Shape.IMAGE, 'image'), _defineProperty(_SHAPE2TAGS, gLite.Shape.GROUP, 'g'), _defineProperty(_SHAPE2TAGS, gLite.Shape.LINE, 'line'), _defineProperty(_SHAPE2TAGS, gLite.Shape.POLYLINE, 'polyline'), _defineProperty(_SHAPE2TAGS, gLite.Shape.POLYGON, 'polygon'), _defineProperty(_SHAPE2TAGS, gLite.Shape.TEXT, 'text'), _defineProperty(_SHAPE2TAGS, gLite.Shape.PATH, 'path'), _defineProperty(_SHAPE2TAGS, gLite.Shape.HTML, 'foreignObject'), _SHAPE2TAGS);
|
|
2913
|
+
var SHAPE_UPDATE_DEPS = (_SHAPE_UPDATE_DEPS = {}, _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.CIRCLE, ['r']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.ELLIPSE, ['rx', 'ry']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.RECT, ['width', 'height', 'radius']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.IMAGE, ['img', 'width', 'height']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.LINE, ['x1', 'y1', 'x2', 'y2', 'markerStart', 'markerEnd', 'markerStartOffset', 'markerEndOffset']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.POLYLINE, ['points', 'markerStart', 'markerEnd', 'markerMid', 'markerStartOffset', 'markerEndOffset']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.POLYGON, ['points', 'markerStart', 'markerEnd', 'markerMid', 'markerStartOffset', 'markerEndOffset']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.PATH, ['path', 'markerStart', 'markerEnd', 'markerMid', 'markerStartOffset', 'markerEndOffset']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.TEXT, ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'maxLines', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'textOverflow', 'textPath', 'textPathSide', 'textPathStartOffset', 'textDecorationLine', 'textDecorationColor', 'textDecorationStyle',
|
|
2537
2914
|
// 'whiteSpace',
|
|
2538
|
-
'dx', 'dy'], _SHAPE_UPDATE_DEPS);
|
|
2915
|
+
'dx', 'dy']), _SHAPE_UPDATE_DEPS);
|
|
2539
2916
|
var DefaultElementLifeCycleContribution = /*#__PURE__*/function () {
|
|
2540
2917
|
function DefaultElementLifeCycleContribution(context) {
|
|
2918
|
+
_classCallCheck$2(this, DefaultElementLifeCycleContribution);
|
|
2541
2919
|
this.context = void 0;
|
|
2542
2920
|
this.context = context;
|
|
2543
2921
|
}
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
_proto.destroyElement = function destroyElement(object, $el) {};
|
|
2551
|
-
_proto.shouldUpdateElementAttribute = function shouldUpdateElementAttribute(object, attributeName) {
|
|
2552
|
-
var nodeName = object.nodeName;
|
|
2553
|
-
return (SHAPE_UPDATE_DEPS[nodeName] || []).indexOf(attributeName) > -1;
|
|
2554
|
-
};
|
|
2555
|
-
_proto.updateElementAttribute = function updateElementAttribute(object) {
|
|
2556
|
-
// @ts-ignore
|
|
2557
|
-
var $el = object.elementSVG.$el;
|
|
2558
|
-
var nodeName = object.nodeName,
|
|
2559
|
-
parsedStyle = object.parsedStyle;
|
|
2560
|
-
switch (nodeName) {
|
|
2561
|
-
case gLite.Shape.IMAGE:
|
|
2562
|
-
{
|
|
2563
|
-
updateImageElementAttribute($el, parsedStyle);
|
|
2564
|
-
break;
|
|
2565
|
-
}
|
|
2566
|
-
case gLite.Shape.RECT:
|
|
2567
|
-
{
|
|
2568
|
-
updateRectElementAttribute($el, parsedStyle);
|
|
2569
|
-
break;
|
|
2570
|
-
}
|
|
2571
|
-
case gLite.Shape.LINE:
|
|
2572
|
-
{
|
|
2573
|
-
updateLineElementAttribute($el, parsedStyle);
|
|
2574
|
-
break;
|
|
2575
|
-
}
|
|
2576
|
-
case gLite.Shape.POLYGON:
|
|
2577
|
-
case gLite.Shape.POLYLINE:
|
|
2578
|
-
{
|
|
2579
|
-
updatePolylineElementAttribute($el, parsedStyle);
|
|
2580
|
-
break;
|
|
2581
|
-
}
|
|
2582
|
-
case gLite.Shape.PATH:
|
|
2583
|
-
{
|
|
2584
|
-
updatePathElementAttribute($el, parsedStyle);
|
|
2585
|
-
break;
|
|
2586
|
-
}
|
|
2587
|
-
case gLite.Shape.TEXT:
|
|
2588
|
-
{
|
|
2589
|
-
updateTextElementAttribute($el, parsedStyle);
|
|
2590
|
-
break;
|
|
2591
|
-
}
|
|
2922
|
+
_createClass$2(DefaultElementLifeCycleContribution, [{
|
|
2923
|
+
key: "createElement",
|
|
2924
|
+
value: function createElement(object) {
|
|
2925
|
+
var doc = this.context.config.document;
|
|
2926
|
+
var type = SHAPE2TAGS[object.nodeName] || 'g';
|
|
2927
|
+
return createSVGElement(type, doc || document);
|
|
2592
2928
|
}
|
|
2593
|
-
}
|
|
2929
|
+
}, {
|
|
2930
|
+
key: "destroyElement",
|
|
2931
|
+
value: function destroyElement(object, $el) {}
|
|
2932
|
+
}, {
|
|
2933
|
+
key: "shouldUpdateElementAttribute",
|
|
2934
|
+
value: function shouldUpdateElementAttribute(object, attributeName) {
|
|
2935
|
+
var nodeName = object.nodeName;
|
|
2936
|
+
return (SHAPE_UPDATE_DEPS[nodeName] || []).indexOf(attributeName) > -1;
|
|
2937
|
+
}
|
|
2938
|
+
}, {
|
|
2939
|
+
key: "updateElementAttribute",
|
|
2940
|
+
value: function updateElementAttribute(object) {
|
|
2941
|
+
// @ts-ignore
|
|
2942
|
+
var $el = object.elementSVG.$el;
|
|
2943
|
+
var nodeName = object.nodeName,
|
|
2944
|
+
parsedStyle = object.parsedStyle;
|
|
2945
|
+
switch (nodeName) {
|
|
2946
|
+
case gLite.Shape.IMAGE:
|
|
2947
|
+
{
|
|
2948
|
+
updateImageElementAttribute($el, parsedStyle);
|
|
2949
|
+
break;
|
|
2950
|
+
}
|
|
2951
|
+
case gLite.Shape.RECT:
|
|
2952
|
+
{
|
|
2953
|
+
updateRectElementAttribute($el, parsedStyle);
|
|
2954
|
+
break;
|
|
2955
|
+
}
|
|
2956
|
+
case gLite.Shape.LINE:
|
|
2957
|
+
{
|
|
2958
|
+
updateLineElementAttribute($el, parsedStyle);
|
|
2959
|
+
break;
|
|
2960
|
+
}
|
|
2961
|
+
case gLite.Shape.POLYGON:
|
|
2962
|
+
case gLite.Shape.POLYLINE:
|
|
2963
|
+
{
|
|
2964
|
+
updatePolylineElementAttribute($el, parsedStyle);
|
|
2965
|
+
break;
|
|
2966
|
+
}
|
|
2967
|
+
case gLite.Shape.PATH:
|
|
2968
|
+
{
|
|
2969
|
+
updatePathElementAttribute($el, parsedStyle);
|
|
2970
|
+
break;
|
|
2971
|
+
}
|
|
2972
|
+
case gLite.Shape.TEXT:
|
|
2973
|
+
{
|
|
2974
|
+
updateTextElementAttribute($el, parsedStyle);
|
|
2975
|
+
break;
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
}]);
|
|
2594
2980
|
return DefaultElementLifeCycleContribution;
|
|
2595
2981
|
}();
|
|
2596
2982
|
var FILTER_PREFIX = 'g-filter-';
|
|
@@ -2601,7 +2987,7 @@
|
|
|
2601
2987
|
function createOrUpdateFilter(document, $def, object, $el, filters) {
|
|
2602
2988
|
// eg. filter="url(#f1) url(#f2)"
|
|
2603
2989
|
var filterName = FILTER_PREFIX + object.entity;
|
|
2604
|
-
var $existedFilters = $def.querySelectorAll("[name="
|
|
2990
|
+
var $existedFilters = $def.querySelectorAll("[name=".concat(filterName, "]"));
|
|
2605
2991
|
if ($existedFilters.length) {
|
|
2606
2992
|
$existedFilters.forEach(function ($filter) {
|
|
2607
2993
|
$def.removeChild($filter);
|
|
@@ -2636,7 +3022,7 @@
|
|
|
2636
3022
|
} else if (name === 'invert') {
|
|
2637
3023
|
createInvert(document, $filter, params);
|
|
2638
3024
|
}
|
|
2639
|
-
$filter.id = filterName
|
|
3025
|
+
$filter.id = "".concat(filterName, "-").concat(i);
|
|
2640
3026
|
$filter.setAttribute('name', filterName);
|
|
2641
3027
|
$def.appendChild($filter);
|
|
2642
3028
|
return $filter.id;
|
|
@@ -2644,7 +3030,7 @@
|
|
|
2644
3030
|
// @see https://github.com/antvis/G/issues/1114
|
|
2645
3031
|
setTimeout(function () {
|
|
2646
3032
|
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', filterIds.map(function (filterId) {
|
|
2647
|
-
return "url(#"
|
|
3033
|
+
return "url(#".concat(filterId, ")");
|
|
2648
3034
|
}).join(' '));
|
|
2649
3035
|
});
|
|
2650
3036
|
}
|
|
@@ -2658,7 +3044,7 @@
|
|
|
2658
3044
|
function createBlur(document, $filter, params) {
|
|
2659
3045
|
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
2660
3046
|
$feGaussianBlur.setAttribute('in', 'SourceGraphic');
|
|
2661
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
3047
|
+
$feGaussianBlur.setAttribute('stdDeviation', "".concat(params[0].value));
|
|
2662
3048
|
$filter.appendChild($feGaussianBlur);
|
|
2663
3049
|
}
|
|
2664
3050
|
function createFeComponentTransfer(document, $filter, _ref2) {
|
|
@@ -2670,10 +3056,10 @@
|
|
|
2670
3056
|
[createSVGElement('feFuncR', document), createSVGElement('feFuncG', document), createSVGElement('feFuncB', document)].forEach(function ($feFunc) {
|
|
2671
3057
|
$feFunc.setAttribute('type', type);
|
|
2672
3058
|
if (type === 'table') {
|
|
2673
|
-
$feFunc.setAttribute('tableValues', ""
|
|
3059
|
+
$feFunc.setAttribute('tableValues', "".concat(tableValues));
|
|
2674
3060
|
} else {
|
|
2675
|
-
$feFunc.setAttribute('slope', ""
|
|
2676
|
-
$feFunc.setAttribute('intercept', ""
|
|
3061
|
+
$feFunc.setAttribute('slope', "".concat(slope));
|
|
3062
|
+
$feFunc.setAttribute('intercept', "".concat(intercept));
|
|
2677
3063
|
}
|
|
2678
3064
|
$feComponentTransfer.appendChild($feFunc);
|
|
2679
3065
|
});
|
|
@@ -2691,7 +3077,7 @@
|
|
|
2691
3077
|
var amount = convertToAbsoluteValue(params[0]);
|
|
2692
3078
|
createFeComponentTransfer(document, $filter, {
|
|
2693
3079
|
type: 'table',
|
|
2694
|
-
tableValues: amount
|
|
3080
|
+
tableValues: "".concat(amount, " ").concat(1 - amount)
|
|
2695
3081
|
});
|
|
2696
3082
|
}
|
|
2697
3083
|
function createBrightness(document, $filter, params) {
|
|
@@ -2706,13 +3092,13 @@
|
|
|
2706
3092
|
var amount = convertToAbsoluteValue(params[0]);
|
|
2707
3093
|
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
2708
3094
|
$feColorMatrix.setAttribute('type', 'saturate');
|
|
2709
|
-
$feColorMatrix.setAttribute('values', ""
|
|
3095
|
+
$feColorMatrix.setAttribute('values', "".concat(amount));
|
|
2710
3096
|
$filter.appendChild($feColorMatrix);
|
|
2711
3097
|
}
|
|
2712
3098
|
function createHueRotate(document, $filter, params) {
|
|
2713
3099
|
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
2714
3100
|
$feColorMatrix.setAttribute('type', 'hueRotate');
|
|
2715
|
-
$feColorMatrix.setAttribute('values', ""
|
|
3101
|
+
$feColorMatrix.setAttribute('values', "".concat(params[0].to(gLite.UnitType.kDegrees).value));
|
|
2716
3102
|
$filter.appendChild($feColorMatrix);
|
|
2717
3103
|
}
|
|
2718
3104
|
function createDropShadow(document, $filter, params) {
|
|
@@ -2723,11 +3109,11 @@
|
|
|
2723
3109
|
var shadowColor = params[3].formatted;
|
|
2724
3110
|
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
2725
3111
|
$feGaussianBlur.setAttribute('in', 'SourceAlpha');
|
|
2726
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
3112
|
+
$feGaussianBlur.setAttribute('stdDeviation', "".concat(shadowBlur));
|
|
2727
3113
|
$filter.appendChild($feGaussianBlur);
|
|
2728
3114
|
var $feOffset = createSVGElement('feOffset', document);
|
|
2729
|
-
$feOffset.setAttribute('dx', ""
|
|
2730
|
-
$feOffset.setAttribute('dy', ""
|
|
3115
|
+
$feOffset.setAttribute('dx', "".concat(shadowOffsetX));
|
|
3116
|
+
$feOffset.setAttribute('dy', "".concat(shadowOffsetY));
|
|
2731
3117
|
$feOffset.setAttribute('result', 'offsetblur');
|
|
2732
3118
|
$filter.appendChild($feOffset);
|
|
2733
3119
|
var $feFlood = createSVGElement('feFlood', document);
|
|
@@ -2785,34 +3171,32 @@
|
|
|
2785
3171
|
var patternId = createOrUpdatePattern(document, $def, object, parsedColor, createImage, plugin);
|
|
2786
3172
|
// use style instead of attribute when applying <pattern>
|
|
2787
3173
|
// @see https://stackoverflow.com/a/7723115
|
|
2788
|
-
$el.style[name] = "url(#"
|
|
3174
|
+
$el.style[name] = "url(#".concat(patternId, ")");
|
|
2789
3175
|
return patternId;
|
|
2790
3176
|
} else {
|
|
2791
3177
|
if (parsedColor.length === 1) {
|
|
2792
3178
|
var gradientId = createOrUpdateGradient(document, object, $def, $el, parsedColor[0]);
|
|
2793
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#"
|
|
3179
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#".concat(gradientId, ")"));
|
|
2794
3180
|
return gradientId;
|
|
2795
3181
|
} else {
|
|
2796
3182
|
// @see https://stackoverflow.com/questions/20671502/can-i-blend-gradients-in-svg
|
|
2797
3183
|
var filterId = createOrUpdateMultiGradient(document, object, $def, $el, parsedColor);
|
|
2798
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#"
|
|
3184
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#".concat(filterId, ")"));
|
|
2799
3185
|
$el === null || $el === void 0 ? void 0 : $el.setAttribute('fill', 'black');
|
|
2800
3186
|
return filterId;
|
|
2801
3187
|
}
|
|
2802
3188
|
}
|
|
2803
3189
|
return '';
|
|
2804
3190
|
}
|
|
2805
|
-
function generateCacheKey(src
|
|
2806
|
-
|
|
2807
|
-
options = {};
|
|
2808
|
-
}
|
|
3191
|
+
function generateCacheKey(src) {
|
|
3192
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2809
3193
|
var cacheKey = '';
|
|
2810
3194
|
if (src instanceof gLite.CSSGradientValue) {
|
|
2811
3195
|
var type = src.type,
|
|
2812
3196
|
value = src.value;
|
|
2813
3197
|
if (type === gLite.GradientType.LinearGradient || type === gLite.GradientType.RadialGradient) {
|
|
2814
3198
|
// @ts-ignore
|
|
2815
|
-
var _value$options =
|
|
3199
|
+
var _value$options = _objectSpread2(_objectSpread2({}, value), options),
|
|
2816
3200
|
_type = _value$options.type,
|
|
2817
3201
|
width = _value$options.width,
|
|
2818
3202
|
height = _value$options.height,
|
|
@@ -2821,25 +3205,25 @@
|
|
|
2821
3205
|
cx = _value$options.cx,
|
|
2822
3206
|
cy = _value$options.cy,
|
|
2823
3207
|
size = _value$options.size;
|
|
2824
|
-
cacheKey = "gradient-"
|
|
3208
|
+
cacheKey = "gradient-".concat(_type, "-").concat((angle === null || angle === void 0 ? void 0 : angle.toString()) || 0, "-").concat((cx === null || cx === void 0 ? void 0 : cx.toString()) || 0, "-").concat((cy === null || cy === void 0 ? void 0 : cy.toString()) || 0, "-").concat((size === null || size === void 0 ? void 0 : size.toString()) || 0, "-").concat(width, "-").concat(height, "-").concat(steps.map(function (_ref) {
|
|
2825
3209
|
var offset = _ref.offset,
|
|
2826
3210
|
color = _ref.color;
|
|
2827
|
-
return ""
|
|
2828
|
-
}).join('-');
|
|
3211
|
+
return "".concat(offset).concat(color);
|
|
3212
|
+
}).join('-'));
|
|
2829
3213
|
}
|
|
2830
3214
|
} else if (gLite.isPattern(src)) {
|
|
2831
3215
|
if (isString(src.image)) {
|
|
2832
|
-
cacheKey = "pattern-"
|
|
3216
|
+
cacheKey = "pattern-".concat(src.image, "-").concat(src.repetition);
|
|
2833
3217
|
} else if (src.image instanceof gLite.Rect) {
|
|
2834
3218
|
// use rect's entity as key
|
|
2835
|
-
cacheKey = "pattern-rect-"
|
|
3219
|
+
cacheKey = "pattern-rect-".concat(src.image.entity);
|
|
2836
3220
|
} else {
|
|
2837
|
-
cacheKey = "pattern-"
|
|
3221
|
+
cacheKey = "pattern-".concat(counter);
|
|
2838
3222
|
}
|
|
2839
3223
|
}
|
|
2840
3224
|
if (cacheKey) {
|
|
2841
3225
|
if (!cacheKey2IDMap[cacheKey]) {
|
|
2842
|
-
cacheKey2IDMap[cacheKey] = PATTERN_PREFIX +
|
|
3226
|
+
cacheKey2IDMap[cacheKey] = PATTERN_PREFIX + "".concat(counter++);
|
|
2843
3227
|
}
|
|
2844
3228
|
}
|
|
2845
3229
|
return cacheKey2IDMap[cacheKey];
|
|
@@ -2851,55 +3235,56 @@
|
|
|
2851
3235
|
var t = parsed.t,
|
|
2852
3236
|
d = parsed.d;
|
|
2853
3237
|
if (t === 'translate') {
|
|
2854
|
-
return "translate("
|
|
3238
|
+
return "translate(".concat(d[0].value, " ").concat(d[1].value, ")");
|
|
2855
3239
|
} else if (t === 'translatex') {
|
|
2856
|
-
return "translate("
|
|
3240
|
+
return "translate(".concat(d[0].value, " 0)");
|
|
2857
3241
|
} else if (t === 'translatey') {
|
|
2858
|
-
return "translate(0 "
|
|
3242
|
+
return "translate(0 ".concat(d[0].value, ")");
|
|
2859
3243
|
} else if (t === 'rotate') {
|
|
2860
|
-
return "rotate("
|
|
3244
|
+
return "rotate(".concat(d[0].value, ")");
|
|
2861
3245
|
} else if (t === 'scale') {
|
|
2862
3246
|
// scale(1) scale(1, 1)
|
|
2863
3247
|
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
2864
3248
|
return s.value;
|
|
2865
3249
|
})) || [1, 1];
|
|
2866
|
-
return "scale("
|
|
3250
|
+
return "scale(".concat(newScale[0], ", ").concat(newScale[1], ")");
|
|
2867
3251
|
} else if (t === 'scalex') {
|
|
2868
3252
|
var _newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
2869
3253
|
return s.value;
|
|
2870
3254
|
})) || [1];
|
|
2871
|
-
return "scale("
|
|
3255
|
+
return "scale(".concat(_newScale[0], ", 1)");
|
|
2872
3256
|
} else if (t === 'scaley') {
|
|
2873
3257
|
var _newScale2 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
2874
3258
|
return s.value;
|
|
2875
3259
|
})) || [1];
|
|
2876
|
-
return "scale(1, "
|
|
3260
|
+
return "scale(1, ".concat(_newScale2[0], ")");
|
|
2877
3261
|
} else if (t === 'skew') {
|
|
2878
3262
|
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
2879
3263
|
return s.value;
|
|
2880
3264
|
})) || [0, 0];
|
|
2881
|
-
return "skewX("
|
|
3265
|
+
return "skewX(".concat(newSkew[0], ") skewY(").concat(newSkew[1], ")");
|
|
2882
3266
|
} else if (t === 'skewx') {
|
|
2883
3267
|
var _newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
2884
3268
|
return s.value;
|
|
2885
3269
|
})) || [0];
|
|
2886
|
-
return "skewX("
|
|
3270
|
+
return "skewX(".concat(_newSkew[0], ")");
|
|
2887
3271
|
} else if (t === 'skewy') {
|
|
2888
3272
|
var _newSkew2 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
2889
3273
|
return s.value;
|
|
2890
3274
|
})) || [0];
|
|
2891
|
-
return "skewY("
|
|
3275
|
+
return "skewY(".concat(_newSkew2[0], ")");
|
|
2892
3276
|
} else if (t === 'matrix') {
|
|
2893
3277
|
var _d$map = d.map(function (s) {
|
|
2894
3278
|
return s.value;
|
|
2895
3279
|
}),
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
3280
|
+
_d$map2 = _slicedToArray(_d$map, 6),
|
|
3281
|
+
a = _d$map2[0],
|
|
3282
|
+
b = _d$map2[1],
|
|
3283
|
+
c = _d$map2[2],
|
|
3284
|
+
dd = _d$map2[3],
|
|
3285
|
+
tx = _d$map2[4],
|
|
3286
|
+
ty = _d$map2[5];
|
|
3287
|
+
return "matrix(".concat(a, " ").concat(b, " ").concat(c, " ").concat(dd, " ").concat(tx, " ").concat(ty, ")");
|
|
2903
3288
|
}
|
|
2904
3289
|
}).join(' ');
|
|
2905
3290
|
}
|
|
@@ -2930,13 +3315,13 @@
|
|
|
2930
3315
|
patternWidth = halfExtents[0] * 2;
|
|
2931
3316
|
patternHeight = halfExtents[1] * 2;
|
|
2932
3317
|
}
|
|
2933
|
-
$pattern.setAttribute('width', ""
|
|
2934
|
-
$pattern.setAttribute('height', ""
|
|
3318
|
+
$pattern.setAttribute('width', "".concat(patternWidth));
|
|
3319
|
+
$pattern.setAttribute('height', "".concat(patternHeight));
|
|
2935
3320
|
return $pattern;
|
|
2936
3321
|
}
|
|
2937
3322
|
function createOrUpdatePattern(document, $def, object, pattern, createImage, plugin) {
|
|
2938
3323
|
var patternId = generateCacheKey(pattern);
|
|
2939
|
-
var $existed = $def.querySelector("#"
|
|
3324
|
+
var $existed = $def.querySelector("#".concat(patternId));
|
|
2940
3325
|
if (!$existed) {
|
|
2941
3326
|
var image = pattern.image;
|
|
2942
3327
|
var imageURL = '';
|
|
@@ -2973,8 +3358,8 @@
|
|
|
2973
3358
|
$pattern.appendChild($image);
|
|
2974
3359
|
$image.setAttribute('x', '0');
|
|
2975
3360
|
$image.setAttribute('y', '0');
|
|
2976
|
-
$image.setAttribute('width', ""
|
|
2977
|
-
$image.setAttribute('height', ""
|
|
3361
|
+
$image.setAttribute('width', "".concat(img.width));
|
|
3362
|
+
$image.setAttribute('height', "".concat(img.height));
|
|
2978
3363
|
};
|
|
2979
3364
|
if (img.complete) {
|
|
2980
3365
|
onload();
|
|
@@ -3015,7 +3400,7 @@
|
|
|
3015
3400
|
width: width,
|
|
3016
3401
|
height: height
|
|
3017
3402
|
});
|
|
3018
|
-
var $existed = $def.querySelector("#"
|
|
3403
|
+
var $existed = $def.querySelector("#".concat(gradientId));
|
|
3019
3404
|
if (!$existed) {
|
|
3020
3405
|
// <linearGradient> <radialGradient>
|
|
3021
3406
|
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/linearGradient
|
|
@@ -3033,7 +3418,7 @@
|
|
|
3033
3418
|
var offset = _ref2.offset,
|
|
3034
3419
|
color = _ref2.color;
|
|
3035
3420
|
// TODO: support absolute unit like `px`
|
|
3036
|
-
innerHTML += "<stop offset=\""
|
|
3421
|
+
innerHTML += "<stop offset=\"".concat(offset.value / 100, "\" stop-color=\"").concat(color, "\"></stop>");
|
|
3037
3422
|
});
|
|
3038
3423
|
$existed.innerHTML = innerHTML;
|
|
3039
3424
|
$existed.id = gradientId;
|
|
@@ -3046,10 +3431,10 @@
|
|
|
3046
3431
|
y1 = _computeLinearGradien.y1,
|
|
3047
3432
|
x2 = _computeLinearGradien.x2,
|
|
3048
3433
|
y2 = _computeLinearGradien.y2;
|
|
3049
|
-
$existed.setAttribute('x1', ""
|
|
3050
|
-
$existed.setAttribute('y1', ""
|
|
3051
|
-
$existed.setAttribute('x2', ""
|
|
3052
|
-
$existed.setAttribute('y2', ""
|
|
3434
|
+
$existed.setAttribute('x1', "".concat(x1));
|
|
3435
|
+
$existed.setAttribute('y1', "".concat(y1));
|
|
3436
|
+
$existed.setAttribute('x2', "".concat(x2));
|
|
3437
|
+
$existed.setAttribute('y2', "".concat(y2));
|
|
3053
3438
|
// $existed.setAttribute('gradientTransform', `rotate(${angle})`);
|
|
3054
3439
|
} else {
|
|
3055
3440
|
var _parsedColor$value = parsedColor.value,
|
|
@@ -3060,15 +3445,15 @@
|
|
|
3060
3445
|
x = _computeRadialGradien.x,
|
|
3061
3446
|
y = _computeRadialGradien.y,
|
|
3062
3447
|
r = _computeRadialGradien.r;
|
|
3063
|
-
$existed.setAttribute('cx', ""
|
|
3064
|
-
$existed.setAttribute('cy', ""
|
|
3065
|
-
$existed.setAttribute('r', ""
|
|
3448
|
+
$existed.setAttribute('cx', "".concat(x));
|
|
3449
|
+
$existed.setAttribute('cy', "".concat(y));
|
|
3450
|
+
$existed.setAttribute('r', "".concat(r));
|
|
3066
3451
|
}
|
|
3067
3452
|
return gradientId;
|
|
3068
3453
|
}
|
|
3069
3454
|
function createOrUpdateMultiGradient(document, object, $def, $el, gradients) {
|
|
3070
3455
|
var filterId = FILTER_PREFIX + object.entity + '-gradient';
|
|
3071
|
-
var $existed = $def.querySelector("#"
|
|
3456
|
+
var $existed = $def.querySelector("#".concat(filterId));
|
|
3072
3457
|
if (!$existed) {
|
|
3073
3458
|
$existed = createSVGElement('filter', document);
|
|
3074
3459
|
$existed.setAttribute('filterUnits', 'userSpaceOnUse');
|
|
@@ -3098,25 +3483,25 @@
|
|
|
3098
3483
|
$rect.setAttribute('y', '0');
|
|
3099
3484
|
$rect.setAttribute('width', '100%');
|
|
3100
3485
|
$rect.setAttribute('height', '100%');
|
|
3101
|
-
$rect.setAttribute('fill', "url(#"
|
|
3486
|
+
$rect.setAttribute('fill', "url(#".concat(gradientId, ")"));
|
|
3102
3487
|
$rect.id = rectId;
|
|
3103
3488
|
$def.appendChild($rect);
|
|
3104
3489
|
var $feImage = createSVGElement('feImage', document);
|
|
3105
|
-
$feImage.setAttribute('href', "#"
|
|
3106
|
-
$feImage.setAttribute('result', filterId
|
|
3490
|
+
$feImage.setAttribute('href', "#".concat(rectId));
|
|
3491
|
+
$feImage.setAttribute('result', "".concat(filterId, "-").concat(i));
|
|
3107
3492
|
$existed.appendChild($feImage);
|
|
3108
3493
|
if (i > 0) {
|
|
3109
3494
|
var $feBlend = createSVGElement('feBlend', document);
|
|
3110
|
-
$feBlend.setAttribute('in', i === 1 ? filterId
|
|
3111
|
-
$feBlend.setAttribute('in2', filterId
|
|
3112
|
-
$feBlend.setAttribute('result', filterId
|
|
3495
|
+
$feBlend.setAttribute('in', i === 1 ? "".concat(filterId, "-").concat(i - 1) : "".concat(filterId, "-blended-").concat(blended - 1));
|
|
3496
|
+
$feBlend.setAttribute('in2', "".concat(filterId, "-").concat(i));
|
|
3497
|
+
$feBlend.setAttribute('result', "".concat(filterId, "-blended-").concat(blended++));
|
|
3113
3498
|
// @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/blend-mode
|
|
3114
3499
|
$feBlend.setAttribute('mode', 'multiply');
|
|
3115
3500
|
$existed.appendChild($feBlend);
|
|
3116
3501
|
}
|
|
3117
3502
|
});
|
|
3118
3503
|
var $feComposite = createSVGElement('feComposite', document);
|
|
3119
|
-
$feComposite.setAttribute('in', filterId
|
|
3504
|
+
$feComposite.setAttribute('in', "".concat(filterId, "-blended-").concat(blended));
|
|
3120
3505
|
$feComposite.setAttribute('in2', 'SourceGraphic');
|
|
3121
3506
|
$feComposite.setAttribute('operator', 'in');
|
|
3122
3507
|
$existed.appendChild($feComposite);
|
|
@@ -3136,7 +3521,7 @@
|
|
|
3136
3521
|
shadowOffsetY = _object$parsedStyle.shadowOffsetY;
|
|
3137
3522
|
var hasShadow = !isNil(shadowColor) && shadowBlur > 0;
|
|
3138
3523
|
var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
|
|
3139
|
-
var $existedFilter = $def.querySelector("#"
|
|
3524
|
+
var $existedFilter = $def.querySelector("#".concat(shadowId));
|
|
3140
3525
|
if ($existedFilter) {
|
|
3141
3526
|
var existedShadowType = $existedFilter.getAttribute('data-type');
|
|
3142
3527
|
if (existedShadowType !== shadowType || !hasShadow) {
|
|
@@ -3150,7 +3535,7 @@
|
|
|
3150
3535
|
if (hasShadow) {
|
|
3151
3536
|
// use filter <feDropShadow>
|
|
3152
3537
|
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
|
|
3153
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#"
|
|
3538
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#".concat(shadowId, ")"));
|
|
3154
3539
|
} else {
|
|
3155
3540
|
$el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
|
|
3156
3541
|
return;
|
|
@@ -3160,9 +3545,9 @@
|
|
|
3160
3545
|
$existedFilter.setAttribute('data-type', shadowType);
|
|
3161
3546
|
if (shadowType === 'outer') {
|
|
3162
3547
|
var $feDropShadow = createSVGElement('feDropShadow', document);
|
|
3163
|
-
$feDropShadow.setAttribute('dx', ""
|
|
3164
|
-
$feDropShadow.setAttribute('dy', ""
|
|
3165
|
-
$feDropShadow.setAttribute('stdDeviation', ""
|
|
3548
|
+
$feDropShadow.setAttribute('dx', "".concat((shadowOffsetX || 0) / 2));
|
|
3549
|
+
$feDropShadow.setAttribute('dy', "".concat((shadowOffsetY || 0) / 2));
|
|
3550
|
+
$feDropShadow.setAttribute('stdDeviation', "".concat((shadowBlur || 0) / 4));
|
|
3166
3551
|
$feDropShadow.setAttribute('flood-color', shadowColor.toString());
|
|
3167
3552
|
$existedFilter.appendChild($feDropShadow);
|
|
3168
3553
|
} else if (shadowType === 'inner') {
|
|
@@ -3174,11 +3559,11 @@
|
|
|
3174
3559
|
$feComponentTransfer.appendChild($feFuncA);
|
|
3175
3560
|
$existedFilter.appendChild($feComponentTransfer);
|
|
3176
3561
|
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
3177
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
3562
|
+
$feGaussianBlur.setAttribute('stdDeviation', "".concat((shadowBlur || 0) / 4));
|
|
3178
3563
|
$existedFilter.appendChild($feGaussianBlur);
|
|
3179
3564
|
var $feOffset = createSVGElement('feOffset', document);
|
|
3180
|
-
$feOffset.setAttribute('dx', ""
|
|
3181
|
-
$feOffset.setAttribute('dy', ""
|
|
3565
|
+
$feOffset.setAttribute('dx', "".concat((shadowOffsetX || 0) / 2));
|
|
3566
|
+
$feOffset.setAttribute('dy', "".concat((shadowOffsetY || 0) / 2));
|
|
3182
3567
|
$feOffset.setAttribute('result', 'offsetblur');
|
|
3183
3568
|
$existedFilter.appendChild($feOffset);
|
|
3184
3569
|
var $feFlood = createSVGElement('feFlood', document);
|
|
@@ -3217,11 +3602,11 @@
|
|
|
3217
3602
|
// half the blur radius
|
|
3218
3603
|
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
3219
3604
|
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
3220
|
-
_$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
3605
|
+
_$feGaussianBlur.setAttribute('stdDeviation', "".concat((shadowBlur || 0) / 4));
|
|
3221
3606
|
} else if (name === 'shadowOffsetX') {
|
|
3222
|
-
_$feOffset.setAttribute('dx', ""
|
|
3607
|
+
_$feOffset.setAttribute('dx', "".concat((shadowOffsetX || 0) / 2));
|
|
3223
3608
|
} else if (name === 'shadowOffsetY') {
|
|
3224
|
-
_$feOffset.setAttribute('dy', ""
|
|
3609
|
+
_$feOffset.setAttribute('dy', "".concat((shadowOffsetY || 0) / 2));
|
|
3225
3610
|
}
|
|
3226
3611
|
} else if (shadowType === 'outer') {
|
|
3227
3612
|
var _$feDropShadow = $existedFilter.children[0];
|
|
@@ -3231,17 +3616,18 @@
|
|
|
3231
3616
|
// half the blur radius
|
|
3232
3617
|
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
3233
3618
|
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
3234
|
-
_$feDropShadow.setAttribute('stdDeviation', ""
|
|
3619
|
+
_$feDropShadow.setAttribute('stdDeviation', "".concat((shadowBlur || 0) / 4));
|
|
3235
3620
|
} else if (name === 'shadowOffsetX') {
|
|
3236
|
-
_$feDropShadow.setAttribute('dx', ""
|
|
3621
|
+
_$feDropShadow.setAttribute('dx', "".concat((shadowOffsetX || 0) / 2));
|
|
3237
3622
|
} else if (name === 'shadowOffsetY') {
|
|
3238
|
-
_$feDropShadow.setAttribute('dy', ""
|
|
3623
|
+
_$feDropShadow.setAttribute('dy', "".concat((shadowOffsetY || 0) / 2));
|
|
3239
3624
|
}
|
|
3240
3625
|
}
|
|
3241
3626
|
}
|
|
3242
3627
|
var urlRegexp = /url\("?#(.*)\)/;
|
|
3243
3628
|
var DefElementManager = /*#__PURE__*/function () {
|
|
3244
3629
|
function DefElementManager(context) {
|
|
3630
|
+
_classCallCheck$2(this, DefElementManager);
|
|
3245
3631
|
this.context = void 0;
|
|
3246
3632
|
this.$def = void 0;
|
|
3247
3633
|
this.gradientCache = {};
|
|
@@ -3250,106 +3636,124 @@
|
|
|
3250
3636
|
/**
|
|
3251
3637
|
* container for <gradient> <clipPath>...
|
|
3252
3638
|
*/
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
_proto.init = function init() {
|
|
3258
|
-
var document = this.context.config.document;
|
|
3259
|
-
var $svg = this.context.contextService.getContext();
|
|
3260
|
-
this.$def = createSVGElement('defs', document);
|
|
3261
|
-
$svg.appendChild(this.$def);
|
|
3262
|
-
};
|
|
3263
|
-
_proto.clear = function clear(entity) {
|
|
3264
|
-
var _this = this;
|
|
3265
|
-
Object.keys(this.gradientCache).forEach(function (id) {
|
|
3266
|
-
_this.clearUnusedDefElement(_this.gradientCache, id, entity);
|
|
3267
|
-
});
|
|
3268
|
-
};
|
|
3269
|
-
_proto.clearUnusedDefElement = function clearUnusedDefElement(cache, id, entity) {
|
|
3270
|
-
if (cache[id] && cache[id].size === 1 && cache[id].has(entity)) {
|
|
3271
|
-
var targetElement = this.$def.querySelector("#" + id);
|
|
3272
|
-
if (targetElement) {
|
|
3273
|
-
this.$def.removeChild(targetElement);
|
|
3274
|
-
}
|
|
3639
|
+
_createClass$2(DefElementManager, [{
|
|
3640
|
+
key: "getDefElement",
|
|
3641
|
+
value: function getDefElement() {
|
|
3642
|
+
return this.$def;
|
|
3275
3643
|
}
|
|
3276
|
-
}
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3644
|
+
}, {
|
|
3645
|
+
key: "init",
|
|
3646
|
+
value: function init() {
|
|
3647
|
+
var document = this.context.config.document;
|
|
3648
|
+
var $svg = this.context.contextService.getContext();
|
|
3649
|
+
this.$def = createSVGElement('defs', document);
|
|
3650
|
+
$svg.appendChild(this.$def);
|
|
3651
|
+
}
|
|
3652
|
+
}, {
|
|
3653
|
+
key: "clear",
|
|
3654
|
+
value: function clear(entity) {
|
|
3655
|
+
var _this = this;
|
|
3656
|
+
Object.keys(this.gradientCache).forEach(function (id) {
|
|
3657
|
+
_this.clearUnusedDefElement(_this.gradientCache, id, entity);
|
|
3658
|
+
});
|
|
3659
|
+
}
|
|
3660
|
+
}, {
|
|
3661
|
+
key: "clearUnusedDefElement",
|
|
3662
|
+
value: function clearUnusedDefElement(cache, id, entity) {
|
|
3663
|
+
if (cache[id] && cache[id].size === 1 && cache[id].has(entity)) {
|
|
3664
|
+
var targetElement = this.$def.querySelector("#".concat(id));
|
|
3665
|
+
if (targetElement) {
|
|
3666
|
+
this.$def.removeChild(targetElement);
|
|
3667
|
+
}
|
|
3293
3668
|
}
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3669
|
+
}
|
|
3670
|
+
}, {
|
|
3671
|
+
key: "createOrUpdateGradientAndPattern",
|
|
3672
|
+
value: function createOrUpdateGradientAndPattern$1(object, $el, parsedColor, name, plugin) {
|
|
3673
|
+
var _this$context$config = this.context.config,
|
|
3674
|
+
doc = _this$context$config.document,
|
|
3675
|
+
createImage = _this$context$config.createImage;
|
|
3676
|
+
if ($el) {
|
|
3677
|
+
var attributeValue = '';
|
|
3678
|
+
if (gLite.isPattern(parsedColor)) {
|
|
3679
|
+
// `fill: url(#${patternId})`
|
|
3680
|
+
attributeValue = $el.style[name];
|
|
3681
|
+
} else {
|
|
3682
|
+
// `url(#${gradientId})`
|
|
3683
|
+
attributeValue = $el.getAttribute(name) || '';
|
|
3684
|
+
}
|
|
3685
|
+
var matches = attributeValue.match(urlRegexp);
|
|
3686
|
+
if (matches && matches.length > 1) {
|
|
3687
|
+
this.clearUnusedDefElement(this.gradientCache, matches[1].replace('"', ''), object.entity);
|
|
3688
|
+
}
|
|
3689
|
+
var newDefElementId = createOrUpdateGradientAndPattern(doc || document, this.$def, object, $el, parsedColor, name, createImage, plugin);
|
|
3690
|
+
if (newDefElementId) {
|
|
3691
|
+
if (!this.gradientCache[newDefElementId]) {
|
|
3692
|
+
this.gradientCache[newDefElementId] = new Set();
|
|
3693
|
+
}
|
|
3694
|
+
this.gradientCache[newDefElementId].add(object.entity);
|
|
3298
3695
|
}
|
|
3299
|
-
this.gradientCache[newDefElementId].add(object.entity);
|
|
3300
3696
|
}
|
|
3301
3697
|
}
|
|
3302
|
-
}
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
createOrUpdateFilter
|
|
3310
|
-
|
|
3698
|
+
}, {
|
|
3699
|
+
key: "createOrUpdateShadow",
|
|
3700
|
+
value: function createOrUpdateShadow$1(object, $el, name) {
|
|
3701
|
+
var doc = this.context.config.document;
|
|
3702
|
+
createOrUpdateShadow(doc || document, this.$def, object, $el, name);
|
|
3703
|
+
}
|
|
3704
|
+
}, {
|
|
3705
|
+
key: "createOrUpdateFilter",
|
|
3706
|
+
value: function createOrUpdateFilter$1(object, $el, filters) {
|
|
3707
|
+
var doc = this.context.config.document;
|
|
3708
|
+
createOrUpdateFilter(doc || document, this.$def, object, $el, filters);
|
|
3709
|
+
}
|
|
3710
|
+
}]);
|
|
3311
3711
|
return DefElementManager;
|
|
3312
3712
|
}();
|
|
3313
3713
|
var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
3314
|
-
|
|
3315
|
-
|
|
3714
|
+
_inherits$2(Plugin, _AbstractRendererPlug);
|
|
3715
|
+
var _super = _createSuper$2(Plugin);
|
|
3716
|
+
function Plugin() {
|
|
3316
3717
|
var _this;
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
_this = _AbstractRendererPlug.call(this) || this;
|
|
3718
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3719
|
+
_classCallCheck$2(this, Plugin);
|
|
3720
|
+
_this = _super.call(this);
|
|
3321
3721
|
_this.options = void 0;
|
|
3322
3722
|
_this.name = 'svg-renderer';
|
|
3323
3723
|
_this.options = options;
|
|
3324
3724
|
return _this;
|
|
3325
3725
|
}
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3726
|
+
_createClass$2(Plugin, [{
|
|
3727
|
+
key: "init",
|
|
3728
|
+
value: function init() {
|
|
3729
|
+
var _this$options = this.options,
|
|
3730
|
+
outputSVGElementId = _this$options.outputSVGElementId,
|
|
3731
|
+
outputSVGElementName = _this$options.outputSVGElementName;
|
|
3732
|
+
var defElementManager = new DefElementManager(this.context);
|
|
3733
|
+
// default implementation
|
|
3734
|
+
var defaultElementLifeCycleContribution = new DefaultElementLifeCycleContribution(this.context);
|
|
3735
|
+
// @ts-ignore
|
|
3736
|
+
this.context.defaultElementLifeCycleContribution = defaultElementLifeCycleContribution;
|
|
3737
|
+
// @ts-ignore
|
|
3738
|
+
this.context.SVGElementLifeCycleContribution = defaultElementLifeCycleContribution;
|
|
3739
|
+
var SVGRendererPluginOptions = {
|
|
3740
|
+
outputSVGElementId: !isNil(outputSVGElementId) ? !!outputSVGElementId : true,
|
|
3741
|
+
outputSVGElementName: !isNil(outputSVGElementName) ? !!outputSVGElementName : true
|
|
3742
|
+
};
|
|
3743
|
+
this.addRenderingPlugin(
|
|
3744
|
+
// @ts-ignore
|
|
3745
|
+
new SVGRendererPlugin(SVGRendererPluginOptions, defElementManager, this.context));
|
|
3746
|
+
}
|
|
3747
|
+
}, {
|
|
3748
|
+
key: "destroy",
|
|
3749
|
+
value: function destroy() {
|
|
3750
|
+
this.removeAllRenderingPlugins();
|
|
3751
|
+
// @ts-ignore
|
|
3752
|
+
delete this.context.defaultElementLifeCycleContribution;
|
|
3753
|
+
// @ts-ignore
|
|
3754
|
+
delete this.context.SVGElementLifeCycleContribution;
|
|
3755
|
+
}
|
|
3756
|
+
}]);
|
|
3353
3757
|
return Plugin;
|
|
3354
3758
|
}(gLite.AbstractRendererPlugin);
|
|
3355
3759
|
|
|
@@ -3451,7 +3855,7 @@
|
|
|
3451
3855
|
if ("throw" !== record.type) {
|
|
3452
3856
|
var result = record.arg,
|
|
3453
3857
|
value = result.value;
|
|
3454
|
-
return value && "object" ==
|
|
3858
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
3455
3859
|
invoke("next", value, resolve, reject);
|
|
3456
3860
|
}, function (err) {
|
|
3457
3861
|
invoke("throw", err, resolve, reject);
|
|
@@ -3510,14 +3914,9 @@
|
|
|
3510
3914
|
};
|
|
3511
3915
|
}
|
|
3512
3916
|
function maybeInvokeDelegate(delegate, context) {
|
|
3513
|
-
var
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
3517
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
3518
|
-
}
|
|
3519
|
-
return ContinueSentinel;
|
|
3520
|
-
}
|
|
3917
|
+
var methodName = context.method,
|
|
3918
|
+
method = delegate.iterator[methodName];
|
|
3919
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
3521
3920
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
3522
3921
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
3523
3922
|
var info = record.arg;
|
|
@@ -3717,10 +4116,49 @@
|
|
|
3717
4116
|
});
|
|
3718
4117
|
};
|
|
3719
4118
|
}
|
|
3720
|
-
function
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
4119
|
+
function _classCallCheck$3(instance, Constructor) {
|
|
4120
|
+
if (!(instance instanceof Constructor)) {
|
|
4121
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4122
|
+
}
|
|
4123
|
+
}
|
|
4124
|
+
function _defineProperties$3(target, props) {
|
|
4125
|
+
for (var i = 0; i < props.length; i++) {
|
|
4126
|
+
var descriptor = props[i];
|
|
4127
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
4128
|
+
descriptor.configurable = true;
|
|
4129
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
4130
|
+
Object.defineProperty(target, _toPropertyKey$3(descriptor.key), descriptor);
|
|
4131
|
+
}
|
|
4132
|
+
}
|
|
4133
|
+
function _createClass$3(Constructor, protoProps, staticProps) {
|
|
4134
|
+
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
4135
|
+
if (staticProps) _defineProperties$3(Constructor, staticProps);
|
|
4136
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
4137
|
+
writable: false
|
|
4138
|
+
});
|
|
4139
|
+
return Constructor;
|
|
4140
|
+
}
|
|
4141
|
+
function _inherits$3(subClass, superClass) {
|
|
4142
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
4143
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
4144
|
+
}
|
|
4145
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
4146
|
+
constructor: {
|
|
4147
|
+
value: subClass,
|
|
4148
|
+
writable: true,
|
|
4149
|
+
configurable: true
|
|
4150
|
+
}
|
|
4151
|
+
});
|
|
4152
|
+
Object.defineProperty(subClass, "prototype", {
|
|
4153
|
+
writable: false
|
|
4154
|
+
});
|
|
4155
|
+
if (superClass) _setPrototypeOf$3(subClass, superClass);
|
|
4156
|
+
}
|
|
4157
|
+
function _getPrototypeOf$3(o) {
|
|
4158
|
+
_getPrototypeOf$3 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
4159
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
4160
|
+
};
|
|
4161
|
+
return _getPrototypeOf$3(o);
|
|
3724
4162
|
}
|
|
3725
4163
|
function _setPrototypeOf$3(o, p) {
|
|
3726
4164
|
_setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -3729,38 +4167,124 @@
|
|
|
3729
4167
|
};
|
|
3730
4168
|
return _setPrototypeOf$3(o, p);
|
|
3731
4169
|
}
|
|
3732
|
-
function
|
|
4170
|
+
function _isNativeReflectConstruct$3() {
|
|
4171
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
4172
|
+
if (Reflect.construct.sham) return false;
|
|
4173
|
+
if (typeof Proxy === "function") return true;
|
|
4174
|
+
try {
|
|
4175
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
4176
|
+
return true;
|
|
4177
|
+
} catch (e) {
|
|
4178
|
+
return false;
|
|
4179
|
+
}
|
|
4180
|
+
}
|
|
4181
|
+
function _assertThisInitialized$3(self) {
|
|
4182
|
+
if (self === void 0) {
|
|
4183
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4184
|
+
}
|
|
4185
|
+
return self;
|
|
4186
|
+
}
|
|
4187
|
+
function _possibleConstructorReturn$3(self, call) {
|
|
4188
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
4189
|
+
return call;
|
|
4190
|
+
} else if (call !== void 0) {
|
|
4191
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
4192
|
+
}
|
|
4193
|
+
return _assertThisInitialized$3(self);
|
|
4194
|
+
}
|
|
4195
|
+
function _createSuper$3(Derived) {
|
|
4196
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$3();
|
|
4197
|
+
return function _createSuperInternal() {
|
|
4198
|
+
var Super = _getPrototypeOf$3(Derived),
|
|
4199
|
+
result;
|
|
4200
|
+
if (hasNativeReflectConstruct) {
|
|
4201
|
+
var NewTarget = _getPrototypeOf$3(this).constructor;
|
|
4202
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
4203
|
+
} else {
|
|
4204
|
+
result = Super.apply(this, arguments);
|
|
4205
|
+
}
|
|
4206
|
+
return _possibleConstructorReturn$3(this, result);
|
|
4207
|
+
};
|
|
4208
|
+
}
|
|
4209
|
+
function _unsupportedIterableToArray$1(o, minLen) {
|
|
3733
4210
|
if (!o) return;
|
|
3734
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
4211
|
+
if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
|
|
3735
4212
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3736
4213
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
3737
4214
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
3738
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
4215
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
|
|
3739
4216
|
}
|
|
3740
|
-
function _arrayLikeToArray(arr, len) {
|
|
4217
|
+
function _arrayLikeToArray$1(arr, len) {
|
|
3741
4218
|
if (len == null || len > arr.length) len = arr.length;
|
|
3742
4219
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
3743
4220
|
arr2[i] = arr[i];
|
|
3744
4221
|
}
|
|
3745
4222
|
return arr2;
|
|
3746
4223
|
}
|
|
3747
|
-
function
|
|
4224
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
3748
4225
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
3749
|
-
if (it)
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
if (i >= o.length) return {
|
|
3755
|
-
done: true
|
|
3756
|
-
};
|
|
4226
|
+
if (!it) {
|
|
4227
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
4228
|
+
if (it) o = it;
|
|
4229
|
+
var i = 0;
|
|
4230
|
+
var F = function F() {};
|
|
3757
4231
|
return {
|
|
3758
|
-
|
|
3759
|
-
|
|
4232
|
+
s: F,
|
|
4233
|
+
n: function n() {
|
|
4234
|
+
if (i >= o.length) return {
|
|
4235
|
+
done: true
|
|
4236
|
+
};
|
|
4237
|
+
return {
|
|
4238
|
+
done: false,
|
|
4239
|
+
value: o[i++]
|
|
4240
|
+
};
|
|
4241
|
+
},
|
|
4242
|
+
e: function e(_e) {
|
|
4243
|
+
throw _e;
|
|
4244
|
+
},
|
|
4245
|
+
f: F
|
|
3760
4246
|
};
|
|
3761
|
-
}
|
|
4247
|
+
}
|
|
4248
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3762
4249
|
}
|
|
3763
|
-
|
|
4250
|
+
var normalCompletion = true,
|
|
4251
|
+
didErr = false,
|
|
4252
|
+
err;
|
|
4253
|
+
return {
|
|
4254
|
+
s: function s() {
|
|
4255
|
+
it = it.call(o);
|
|
4256
|
+
},
|
|
4257
|
+
n: function n() {
|
|
4258
|
+
var step = it.next();
|
|
4259
|
+
normalCompletion = step.done;
|
|
4260
|
+
return step;
|
|
4261
|
+
},
|
|
4262
|
+
e: function e(_e2) {
|
|
4263
|
+
didErr = true;
|
|
4264
|
+
err = _e2;
|
|
4265
|
+
},
|
|
4266
|
+
f: function f() {
|
|
4267
|
+
try {
|
|
4268
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
4269
|
+
} finally {
|
|
4270
|
+
if (didErr) throw err;
|
|
4271
|
+
}
|
|
4272
|
+
}
|
|
4273
|
+
};
|
|
4274
|
+
}
|
|
4275
|
+
function _toPrimitive$3(input, hint) {
|
|
4276
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
4277
|
+
var prim = input[Symbol.toPrimitive];
|
|
4278
|
+
if (prim !== undefined) {
|
|
4279
|
+
var res = prim.call(input, hint || "default");
|
|
4280
|
+
if (_typeof(res) !== "object") return res;
|
|
4281
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
4282
|
+
}
|
|
4283
|
+
return (hint === "string" ? String : Number)(input);
|
|
4284
|
+
}
|
|
4285
|
+
function _toPropertyKey$3(arg) {
|
|
4286
|
+
var key = _toPrimitive$3(arg, "string");
|
|
4287
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
3764
4288
|
}
|
|
3765
4289
|
|
|
3766
4290
|
/**
|
|
@@ -3770,86 +4294,106 @@
|
|
|
3770
4294
|
* 2. use elementFromPoint
|
|
3771
4295
|
*/
|
|
3772
4296
|
var SVGPickerPlugin = /*#__PURE__*/function () {
|
|
3773
|
-
function SVGPickerPlugin() {
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
var
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
4297
|
+
function SVGPickerPlugin() {
|
|
4298
|
+
_classCallCheck$3(this, SVGPickerPlugin);
|
|
4299
|
+
}
|
|
4300
|
+
_createClass$3(SVGPickerPlugin, [{
|
|
4301
|
+
key: "apply",
|
|
4302
|
+
value: function apply(context) {
|
|
4303
|
+
var _this = this;
|
|
4304
|
+
var doc = context.config.document,
|
|
4305
|
+
renderingService = context.renderingService;
|
|
4306
|
+
renderingService.hooks.pick.tapPromise(SVGPickerPlugin.tag, /*#__PURE__*/function () {
|
|
4307
|
+
var _ref = _asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee(result) {
|
|
4308
|
+
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
4309
|
+
while (1) {
|
|
4310
|
+
switch (_context.prev = _context.next) {
|
|
4311
|
+
case 0:
|
|
4312
|
+
return _context.abrupt("return", _this.pick(doc, result));
|
|
4313
|
+
case 1:
|
|
4314
|
+
case "end":
|
|
4315
|
+
return _context.stop();
|
|
4316
|
+
}
|
|
3789
4317
|
}
|
|
3790
|
-
}
|
|
3791
|
-
}
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
};
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
}
|
|
3800
|
-
}
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
var
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
4318
|
+
}, _callee);
|
|
4319
|
+
}));
|
|
4320
|
+
return function (_x) {
|
|
4321
|
+
return _ref.apply(this, arguments);
|
|
4322
|
+
};
|
|
4323
|
+
}());
|
|
4324
|
+
renderingService.hooks.pickSync.tap(SVGPickerPlugin.tag, function (result) {
|
|
4325
|
+
return _this.pick(doc, result);
|
|
4326
|
+
});
|
|
4327
|
+
}
|
|
4328
|
+
}, {
|
|
4329
|
+
key: "pick",
|
|
4330
|
+
value: function pick(doc, result) {
|
|
4331
|
+
var topmost = result.topmost,
|
|
4332
|
+
_result$position = result.position,
|
|
4333
|
+
clientX = _result$position.clientX,
|
|
4334
|
+
clientY = _result$position.clientY;
|
|
4335
|
+
try {
|
|
4336
|
+
var targets = [];
|
|
4337
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
|
|
4338
|
+
var _iterator = _createForOfIteratorHelper((doc || document).elementsFromPoint(clientX, clientY)),
|
|
4339
|
+
_step;
|
|
4340
|
+
try {
|
|
4341
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4342
|
+
var element = _step.value;
|
|
4343
|
+
// eg. g_svg_circle_345
|
|
4344
|
+
var id = element && element.getAttribute('id');
|
|
4345
|
+
if (id && id.startsWith(G_SVG_PREFIX)) {
|
|
4346
|
+
var index = id.lastIndexOf('-');
|
|
4347
|
+
var target = gLite.runtime.displayObjectPool.getByEntity(id.substring(index + 1));
|
|
4348
|
+
// don't need to account for `visibility` since DOM API already does
|
|
4349
|
+
if (target && target.isInteractive()) {
|
|
4350
|
+
targets.push(target);
|
|
4351
|
+
if (topmost) {
|
|
4352
|
+
result.picked = targets;
|
|
4353
|
+
return result;
|
|
4354
|
+
}
|
|
4355
|
+
}
|
|
3822
4356
|
}
|
|
3823
4357
|
}
|
|
4358
|
+
} catch (err) {
|
|
4359
|
+
_iterator.e(err);
|
|
4360
|
+
} finally {
|
|
4361
|
+
_iterator.f();
|
|
3824
4362
|
}
|
|
4363
|
+
result.picked = targets;
|
|
4364
|
+
} catch (e) {
|
|
4365
|
+
result.picked = [];
|
|
3825
4366
|
}
|
|
3826
|
-
result
|
|
3827
|
-
} catch (e) {
|
|
3828
|
-
result.picked = [];
|
|
4367
|
+
return result;
|
|
3829
4368
|
}
|
|
3830
|
-
|
|
3831
|
-
};
|
|
4369
|
+
}]);
|
|
3832
4370
|
return SVGPickerPlugin;
|
|
3833
4371
|
}();
|
|
3834
4372
|
SVGPickerPlugin.tag = 'SVGPicker';
|
|
3835
4373
|
var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
3836
|
-
|
|
4374
|
+
_inherits$3(Plugin, _AbstractRendererPlug);
|
|
4375
|
+
var _super = _createSuper$3(Plugin);
|
|
3837
4376
|
function Plugin() {
|
|
3838
4377
|
var _this;
|
|
4378
|
+
_classCallCheck$3(this, Plugin);
|
|
3839
4379
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3840
4380
|
args[_key] = arguments[_key];
|
|
3841
4381
|
}
|
|
3842
|
-
_this =
|
|
4382
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
3843
4383
|
_this.name = 'svg-picker';
|
|
3844
4384
|
return _this;
|
|
3845
4385
|
}
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
4386
|
+
_createClass$3(Plugin, [{
|
|
4387
|
+
key: "init",
|
|
4388
|
+
value: function init() {
|
|
4389
|
+
this.addRenderingPlugin(new SVGPickerPlugin());
|
|
4390
|
+
}
|
|
4391
|
+
}, {
|
|
4392
|
+
key: "destroy",
|
|
4393
|
+
value: function destroy() {
|
|
4394
|
+
this.removeAllRenderingPlugins();
|
|
4395
|
+
}
|
|
4396
|
+
}]);
|
|
3853
4397
|
return Plugin;
|
|
3854
4398
|
}(gLite.AbstractRendererPlugin);
|
|
3855
4399
|
|
|
@@ -3860,137 +4404,163 @@
|
|
|
3860
4404
|
|
|
3861
4405
|
var SVGContextService = /*#__PURE__*/function () {
|
|
3862
4406
|
function SVGContextService(context) {
|
|
4407
|
+
_classCallCheck(this, SVGContextService);
|
|
3863
4408
|
this.$container = void 0;
|
|
3864
4409
|
this.$namespace = void 0;
|
|
3865
4410
|
this.dpr = void 0;
|
|
3866
4411
|
this.canvasConfig = void 0;
|
|
3867
4412
|
this.canvasConfig = context.config;
|
|
3868
4413
|
}
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
var
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
if (
|
|
3881
|
-
this.$container.style.position
|
|
4414
|
+
_createClass(SVGContextService, [{
|
|
4415
|
+
key: "init",
|
|
4416
|
+
value: function () {
|
|
4417
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
4418
|
+
var _this$canvasConfig, container, doc, devicePixelRatio, $namespace, dpr;
|
|
4419
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4420
|
+
while (1) {
|
|
4421
|
+
switch (_context.prev = _context.next) {
|
|
4422
|
+
case 0:
|
|
4423
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document, devicePixelRatio = _this$canvasConfig.devicePixelRatio; // create container
|
|
4424
|
+
this.$container = isString(container) ? (doc || document).getElementById(container) : container;
|
|
4425
|
+
if (this.$container) {
|
|
4426
|
+
if (!this.$container.style.position) {
|
|
4427
|
+
this.$container.style.position = 'relative';
|
|
4428
|
+
}
|
|
4429
|
+
$namespace = createSVGElement('svg', doc);
|
|
4430
|
+
$namespace.setAttribute('width', "".concat(this.canvasConfig.width));
|
|
4431
|
+
$namespace.setAttribute('height', "".concat(this.canvasConfig.height));
|
|
4432
|
+
this.$container.appendChild($namespace);
|
|
4433
|
+
this.$namespace = $namespace;
|
|
3882
4434
|
}
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
this
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
3892
|
-
this.dpr = dpr;
|
|
3893
|
-
case 6:
|
|
3894
|
-
case "end":
|
|
3895
|
-
return _context.stop();
|
|
4435
|
+
// use user-defined dpr first
|
|
4436
|
+
dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
|
|
4437
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
4438
|
+
this.dpr = dpr;
|
|
4439
|
+
case 6:
|
|
4440
|
+
case "end":
|
|
4441
|
+
return _context.stop();
|
|
4442
|
+
}
|
|
3896
4443
|
}
|
|
3897
|
-
}
|
|
3898
|
-
}
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
}
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
};
|
|
3909
|
-
_proto.getContext = function getContext() {
|
|
3910
|
-
return this.$namespace;
|
|
3911
|
-
};
|
|
3912
|
-
_proto.getDPR = function getDPR() {
|
|
3913
|
-
return this.dpr;
|
|
3914
|
-
};
|
|
3915
|
-
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
3916
|
-
var _this$$namespace;
|
|
3917
|
-
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
3918
|
-
};
|
|
3919
|
-
_proto.destroy = function destroy() {
|
|
3920
|
-
// destroy context
|
|
3921
|
-
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
3922
|
-
this.$container.removeChild(this.$namespace);
|
|
4444
|
+
}, _callee, this);
|
|
4445
|
+
}));
|
|
4446
|
+
function init() {
|
|
4447
|
+
return _init.apply(this, arguments);
|
|
4448
|
+
}
|
|
4449
|
+
return init;
|
|
4450
|
+
}() // @ts-ignore
|
|
4451
|
+
}, {
|
|
4452
|
+
key: "getDomElement",
|
|
4453
|
+
value: function getDomElement() {
|
|
4454
|
+
return this.$namespace;
|
|
3923
4455
|
}
|
|
3924
|
-
}
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
this.$namespace.setAttribute('width', "" + width);
|
|
3929
|
-
this.$namespace.setAttribute('height', "" + height);
|
|
4456
|
+
}, {
|
|
4457
|
+
key: "getContext",
|
|
4458
|
+
value: function getContext() {
|
|
4459
|
+
return this.$namespace;
|
|
3930
4460
|
}
|
|
3931
|
-
}
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
this
|
|
4461
|
+
}, {
|
|
4462
|
+
key: "getDPR",
|
|
4463
|
+
value: function getDPR() {
|
|
4464
|
+
return this.dpr;
|
|
3935
4465
|
}
|
|
3936
|
-
}
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
var
|
|
3940
|
-
return
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
case 6:
|
|
3950
|
-
case "end":
|
|
3951
|
-
return _context2.stop();
|
|
3952
|
-
}
|
|
3953
|
-
}
|
|
3954
|
-
}, _callee2, this);
|
|
3955
|
-
}));
|
|
3956
|
-
function toDataURL(_x) {
|
|
3957
|
-
return _toDataURL.apply(this, arguments);
|
|
4466
|
+
}, {
|
|
4467
|
+
key: "getBoundingClientRect",
|
|
4468
|
+
value: function getBoundingClientRect() {
|
|
4469
|
+
var _this$$namespace;
|
|
4470
|
+
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
4471
|
+
}
|
|
4472
|
+
}, {
|
|
4473
|
+
key: "destroy",
|
|
4474
|
+
value: function destroy() {
|
|
4475
|
+
// destroy context
|
|
4476
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
4477
|
+
this.$container.removeChild(this.$namespace);
|
|
4478
|
+
}
|
|
3958
4479
|
}
|
|
3959
|
-
|
|
3960
|
-
|
|
4480
|
+
}, {
|
|
4481
|
+
key: "resize",
|
|
4482
|
+
value: function resize(width, height) {
|
|
4483
|
+
// SVG should ignore DPR
|
|
4484
|
+
if (this.$namespace) {
|
|
4485
|
+
this.$namespace.setAttribute('width', "".concat(width));
|
|
4486
|
+
this.$namespace.setAttribute('height', "".concat(height));
|
|
4487
|
+
}
|
|
4488
|
+
}
|
|
4489
|
+
}, {
|
|
4490
|
+
key: "applyCursorStyle",
|
|
4491
|
+
value: function applyCursorStyle(cursor) {
|
|
4492
|
+
if (this.$container) {
|
|
4493
|
+
this.$container.style.cursor = cursor;
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
}, {
|
|
4497
|
+
key: "toDataURL",
|
|
4498
|
+
value: function () {
|
|
4499
|
+
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
4500
|
+
var cloneNode,
|
|
4501
|
+
svgDocType,
|
|
4502
|
+
svgDoc;
|
|
4503
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4504
|
+
while (1) {
|
|
4505
|
+
switch (_context2.prev = _context2.next) {
|
|
4506
|
+
case 0:
|
|
4507
|
+
cloneNode = this.$namespace.cloneNode(true);
|
|
4508
|
+
svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
|
|
4509
|
+
svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
|
|
4510
|
+
svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
|
|
4511
|
+
return _context2.abrupt("return", "data:image/svg+xml;charset=utf8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(svgDoc))));
|
|
4512
|
+
case 6:
|
|
4513
|
+
case "end":
|
|
4514
|
+
return _context2.stop();
|
|
4515
|
+
}
|
|
4516
|
+
}
|
|
4517
|
+
}, _callee2, this);
|
|
4518
|
+
}));
|
|
4519
|
+
function toDataURL() {
|
|
4520
|
+
return _toDataURL.apply(this, arguments);
|
|
4521
|
+
}
|
|
4522
|
+
return toDataURL;
|
|
4523
|
+
}()
|
|
4524
|
+
}]);
|
|
3961
4525
|
return SVGContextService;
|
|
3962
4526
|
}();
|
|
3963
4527
|
|
|
3964
4528
|
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
3965
|
-
|
|
4529
|
+
_inherits(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
4530
|
+
var _super = _createSuper(ContextRegisterPlugin);
|
|
3966
4531
|
function ContextRegisterPlugin() {
|
|
3967
4532
|
var _this;
|
|
4533
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
3968
4534
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3969
4535
|
args[_key] = arguments[_key];
|
|
3970
4536
|
}
|
|
3971
|
-
_this =
|
|
4537
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
3972
4538
|
_this.name = 'svg-context-register';
|
|
3973
4539
|
return _this;
|
|
3974
4540
|
}
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
4541
|
+
_createClass(ContextRegisterPlugin, [{
|
|
4542
|
+
key: "init",
|
|
4543
|
+
value: function init() {
|
|
4544
|
+
// @ts-ignore
|
|
4545
|
+
this.context.ContextService = SVGContextService;
|
|
4546
|
+
}
|
|
4547
|
+
}, {
|
|
4548
|
+
key: "destroy",
|
|
4549
|
+
value: function destroy() {
|
|
4550
|
+
delete this.context.ContextService;
|
|
4551
|
+
}
|
|
4552
|
+
}]);
|
|
3983
4553
|
return ContextRegisterPlugin;
|
|
3984
4554
|
}(gLite.AbstractRendererPlugin);
|
|
3985
4555
|
|
|
3986
4556
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
3987
|
-
|
|
3988
|
-
|
|
4557
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
4558
|
+
var _super = _createSuper(Renderer);
|
|
4559
|
+
function Renderer() {
|
|
3989
4560
|
var _this;
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
_this = _AbstractRenderer.call(this, config) || this;
|
|
4561
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
4562
|
+
_classCallCheck(this, Renderer);
|
|
4563
|
+
_this = _super.call(this, config);
|
|
3994
4564
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
3995
4565
|
_this.registerPlugin(new Plugin$1({
|
|
3996
4566
|
outputSVGElementId: config.outputSVGElementId
|
|
@@ -3999,7 +4569,7 @@
|
|
|
3999
4569
|
_this.registerPlugin(new Plugin$2());
|
|
4000
4570
|
return _this;
|
|
4001
4571
|
}
|
|
4002
|
-
return Renderer;
|
|
4572
|
+
return _createClass(Renderer);
|
|
4003
4573
|
}(gLite.AbstractRenderer);
|
|
4004
4574
|
|
|
4005
4575
|
exports.DomInteraction = index_esm;
|