MCPcopy
hub / github.com/greensock/GSAP / PathEditor

Function PathEditor

esm/utils/PathEditor.js:774–884  ·  view source on GitHub ↗
(target, vars)

Source from the content-addressed store, hash-verified

772
773export var PathEditor = /*#__PURE__*/function () {
774 function PathEditor(target, vars) {
775 vars = vars || {};
776 _coreInitted || _initCore();
777 this.vars = vars;
778 this.path = typeof target === "string" ? _doc.querySelectorAll(target)[0] : target;
779 this._g = _createSVG("g", this.path.ownerSVGElement, {
780 "class": "path-editor-g path-editor"
781 });
782 this._selectionHittest = _createSVG("path", this._g, {
783 stroke: "transparent",
784 strokeWidth: 16,
785 fill: "none",
786 vectorEffect: "non-scaling-stroke"
787 });
788 this._selection = vars._selection || _createSVG("g", this._g, {
789 "class": "path-editor-selection path-editor"
790 });
791 this._selectionPath = _createSVG("path", this._selection, {
792 stroke: _selectionColor,
793 strokeWidth: 2,
794 fill: "none",
795 vectorEffect: "non-scaling-stroke"
796 });
797 this._selectedAnchors = [];
798 this._line1 = _createSVG("polyline", this._selection, {
799 stroke: _selectionColor,
800 strokeWidth: 2,
801 vectorEffect: "non-scaling-stroke"
802 });
803 this._line2 = _createSVG("polyline", this._selection, {
804 stroke: _selectionColor,
805 strokeWidth: 2,
806 vectorEffect: "non-scaling-stroke"
807 });
808 this._line1.style.pointerEvents = this._line2.style.pointerEvents = this._selectionPath.style.pointerEvents = "none";
809 this._enabled = true;
810 var ctm = this.path.parentNode.getScreenCTM().inverse(),
811 size = (ctm.a + ctm.d) / 2 * (vars.handleSize || 5);
812 this._squareHandle = _getSquarePathData(size);
813 this._circleHandle = _getCirclePathData(size * 1.15);
814 this._handle1 = _createSVG("path", this._selection, {
815 d: this._squareHandle,
816 fill: _selectionColor,
817 stroke: "transparent",
818 strokeWidth: 6
819 });
820 this._handle2 = _createSVG("path", this._selection, {
821 d: this._squareHandle,
822 fill: _selectionColor,
823 stroke: "transparent",
824 strokeWidth: 6
825 });
826 this._handle1._draggable = new DraggableSVG(this._handle1, {
827 onDrag: this._onDragHandle1,
828 callbackScope: this,
829 onPress: this._onPressHandle1,
830 onRelease: this._onReleaseHandle,
831 onClick: this._onClickHandle1,

Callers

nothing calls this directly

Calls 10

inverseMethod · 0.80
_saveStateMethod · 0.80
_initCoreFunction · 0.70
_createSVGFunction · 0.70
_getSquarePathDataFunction · 0.70
_getCirclePathDataFunction · 0.70
_addListenerFunction · 0.70
_bindFunction · 0.70
_contextFunction · 0.50
initMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…