@joint/core 4.0.0
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/LICENSE +376 -0
- package/README.md +49 -0
- package/dist/geometry.js +6486 -0
- package/dist/geometry.min.js +8 -0
- package/dist/joint.d.ts +5536 -0
- package/dist/joint.js +39629 -0
- package/dist/joint.min.js +8 -0
- package/dist/joint.nowrap.js +39626 -0
- package/dist/joint.nowrap.min.js +8 -0
- package/dist/vectorizer.js +9135 -0
- package/dist/vectorizer.min.js +8 -0
- package/dist/version.mjs +3 -0
- package/index.js +3 -0
- package/joint.mjs +27 -0
- package/package.json +192 -0
- package/src/V/annotation.mjs +0 -0
- package/src/V/index.mjs +2642 -0
- package/src/anchors/index.mjs +123 -0
- package/src/config/index.mjs +12 -0
- package/src/connectionPoints/index.mjs +202 -0
- package/src/connectionStrategies/index.mjs +73 -0
- package/src/connectors/curve.mjs +553 -0
- package/src/connectors/index.mjs +6 -0
- package/src/connectors/jumpover.mjs +452 -0
- package/src/connectors/normal.mjs +12 -0
- package/src/connectors/rounded.mjs +17 -0
- package/src/connectors/smooth.mjs +44 -0
- package/src/connectors/straight.mjs +110 -0
- package/src/dia/Cell.mjs +945 -0
- package/src/dia/CellView.mjs +1316 -0
- package/src/dia/Element.mjs +519 -0
- package/src/dia/ElementView.mjs +859 -0
- package/src/dia/Graph.mjs +1112 -0
- package/src/dia/HighlighterView.mjs +319 -0
- package/src/dia/Link.mjs +565 -0
- package/src/dia/LinkView.mjs +2207 -0
- package/src/dia/Paper.mjs +3171 -0
- package/src/dia/PaperLayer.mjs +75 -0
- package/src/dia/ToolView.mjs +69 -0
- package/src/dia/ToolsView.mjs +128 -0
- package/src/dia/attributes/calc.mjs +128 -0
- package/src/dia/attributes/connection.mjs +75 -0
- package/src/dia/attributes/defs.mjs +76 -0
- package/src/dia/attributes/eval.mjs +64 -0
- package/src/dia/attributes/index.mjs +69 -0
- package/src/dia/attributes/legacy.mjs +148 -0
- package/src/dia/attributes/offset.mjs +53 -0
- package/src/dia/attributes/props.mjs +30 -0
- package/src/dia/attributes/shape.mjs +92 -0
- package/src/dia/attributes/text.mjs +180 -0
- package/src/dia/index.mjs +13 -0
- package/src/dia/layers/GridLayer.mjs +176 -0
- package/src/dia/ports.mjs +874 -0
- package/src/elementTools/Control.mjs +153 -0
- package/src/elementTools/HoverConnect.mjs +37 -0
- package/src/elementTools/index.mjs +5 -0
- package/src/env/index.mjs +43 -0
- package/src/g/bezier.mjs +175 -0
- package/src/g/curve.mjs +956 -0
- package/src/g/ellipse.mjs +245 -0
- package/src/g/extend.mjs +64 -0
- package/src/g/geometry.helpers.mjs +58 -0
- package/src/g/index.mjs +17 -0
- package/src/g/intersection.mjs +511 -0
- package/src/g/line.bearing.mjs +30 -0
- package/src/g/line.length.mjs +5 -0
- package/src/g/line.mjs +356 -0
- package/src/g/line.squaredLength.mjs +10 -0
- package/src/g/path.mjs +2260 -0
- package/src/g/point.mjs +375 -0
- package/src/g/points.mjs +247 -0
- package/src/g/polygon.mjs +51 -0
- package/src/g/polyline.mjs +523 -0
- package/src/g/rect.mjs +556 -0
- package/src/g/types.mjs +10 -0
- package/src/highlighters/addClass.mjs +27 -0
- package/src/highlighters/index.mjs +5 -0
- package/src/highlighters/list.mjs +111 -0
- package/src/highlighters/mask.mjs +220 -0
- package/src/highlighters/opacity.mjs +17 -0
- package/src/highlighters/stroke.mjs +100 -0
- package/src/layout/index.mjs +4 -0
- package/src/layout/ports/port.mjs +188 -0
- package/src/layout/ports/portLabel.mjs +224 -0
- package/src/linkAnchors/index.mjs +76 -0
- package/src/linkTools/Anchor.mjs +235 -0
- package/src/linkTools/Arrowhead.mjs +103 -0
- package/src/linkTools/Boundary.mjs +48 -0
- package/src/linkTools/Button.mjs +121 -0
- package/src/linkTools/Connect.mjs +85 -0
- package/src/linkTools/HoverConnect.mjs +161 -0
- package/src/linkTools/Segments.mjs +393 -0
- package/src/linkTools/Vertices.mjs +253 -0
- package/src/linkTools/helpers.mjs +33 -0
- package/src/linkTools/index.mjs +8 -0
- package/src/mvc/Collection.mjs +560 -0
- package/src/mvc/Data.mjs +46 -0
- package/src/mvc/Dom/Dom.mjs +587 -0
- package/src/mvc/Dom/Event.mjs +130 -0
- package/src/mvc/Dom/animations.mjs +122 -0
- package/src/mvc/Dom/events.mjs +69 -0
- package/src/mvc/Dom/index.mjs +13 -0
- package/src/mvc/Dom/methods.mjs +392 -0
- package/src/mvc/Dom/props.mjs +77 -0
- package/src/mvc/Dom/vars.mjs +5 -0
- package/src/mvc/Events.mjs +337 -0
- package/src/mvc/Listener.mjs +33 -0
- package/src/mvc/Model.mjs +239 -0
- package/src/mvc/View.mjs +323 -0
- package/src/mvc/ViewBase.mjs +182 -0
- package/src/mvc/index.mjs +9 -0
- package/src/mvc/mvcUtils.mjs +90 -0
- package/src/polyfills/array.js +4 -0
- package/src/polyfills/base64.js +68 -0
- package/src/polyfills/index.mjs +5 -0
- package/src/polyfills/number.js +3 -0
- package/src/polyfills/string.js +3 -0
- package/src/polyfills/typedArray.js +47 -0
- package/src/routers/index.mjs +6 -0
- package/src/routers/manhattan.mjs +856 -0
- package/src/routers/metro.mjs +91 -0
- package/src/routers/normal.mjs +6 -0
- package/src/routers/oneSide.mjs +60 -0
- package/src/routers/orthogonal.mjs +323 -0
- package/src/routers/rightAngle.mjs +1056 -0
- package/src/shapes/index.mjs +3 -0
- package/src/shapes/standard.mjs +755 -0
- package/src/util/cloneCells.mjs +67 -0
- package/src/util/getRectPoint.mjs +65 -0
- package/src/util/index.mjs +5 -0
- package/src/util/svgTagTemplate.mjs +110 -0
- package/src/util/util.mjs +1754 -0
- package/src/util/utilHelpers.mjs +2402 -0
- package/src/util/wrappers.mjs +56 -0
- package/types/geometry.d.ts +815 -0
- package/types/index.d.ts +53 -0
- package/types/joint.d.ts +4391 -0
- package/types/joint.head.d.ts +12 -0
- package/types/vectorizer.d.ts +327 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { evalCalcAttribute, isCalcAttribute } from '../dia/attributes/calc.mjs';
|
|
2
|
+
import { ToolView } from '../dia/ToolView.mjs';
|
|
3
|
+
import { getViewBBox } from './helpers.mjs';
|
|
4
|
+
import * as util from '../util/index.mjs';
|
|
5
|
+
import * as g from '../g/index.mjs';
|
|
6
|
+
import V from '../V/index.mjs';
|
|
7
|
+
|
|
8
|
+
export const Button = ToolView.extend({
|
|
9
|
+
name: 'button',
|
|
10
|
+
events: {
|
|
11
|
+
'mousedown': 'onPointerDown',
|
|
12
|
+
'touchstart': 'onPointerDown'
|
|
13
|
+
},
|
|
14
|
+
options: {
|
|
15
|
+
distance: 0,
|
|
16
|
+
offset: 0,
|
|
17
|
+
scale: null,
|
|
18
|
+
rotate: false
|
|
19
|
+
},
|
|
20
|
+
onRender: function() {
|
|
21
|
+
this.renderChildren(this.options.markup);
|
|
22
|
+
this.update();
|
|
23
|
+
},
|
|
24
|
+
update: function() {
|
|
25
|
+
this.position();
|
|
26
|
+
return this;
|
|
27
|
+
},
|
|
28
|
+
position: function() {
|
|
29
|
+
const { vel } = this;
|
|
30
|
+
vel.transform(this.getCellMatrix(), { absolute: true });
|
|
31
|
+
},
|
|
32
|
+
getCellMatrix() {
|
|
33
|
+
return this.relatedView.model.isLink() ? this.getLinkMatrix() : this.getElementMatrix();
|
|
34
|
+
},
|
|
35
|
+
getElementMatrix() {
|
|
36
|
+
const { relatedView: view, options } = this;
|
|
37
|
+
let { x = 0, y = 0, offset = {}, useModelGeometry, rotate, scale } = options;
|
|
38
|
+
let bbox = getViewBBox(view, useModelGeometry);
|
|
39
|
+
const angle = view.model.angle();
|
|
40
|
+
if (!rotate) bbox = bbox.bbox(angle);
|
|
41
|
+
const { x: offsetX = 0, y: offsetY = 0 } = offset;
|
|
42
|
+
if (util.isPercentage(x)) {
|
|
43
|
+
x = parseFloat(x) / 100 * bbox.width;
|
|
44
|
+
} else if (isCalcAttribute(x)) {
|
|
45
|
+
x = Number(evalCalcAttribute(x, bbox));
|
|
46
|
+
}
|
|
47
|
+
if (util.isPercentage(y)) {
|
|
48
|
+
y = parseFloat(y) / 100 * bbox.height;
|
|
49
|
+
} else if (isCalcAttribute(y)) {
|
|
50
|
+
y = Number(evalCalcAttribute(y, bbox));
|
|
51
|
+
}
|
|
52
|
+
let matrix = V.createSVGMatrix().translate(bbox.x + bbox.width / 2, bbox.y + bbox.height / 2);
|
|
53
|
+
if (rotate) matrix = matrix.rotate(angle);
|
|
54
|
+
matrix = matrix.translate(x + offsetX - bbox.width / 2, y + offsetY - bbox.height / 2);
|
|
55
|
+
if (scale) matrix = matrix.scale(scale);
|
|
56
|
+
return matrix;
|
|
57
|
+
},
|
|
58
|
+
getLinkMatrix() {
|
|
59
|
+
const { relatedView: view, options } = this;
|
|
60
|
+
const { offset = 0, distance = 0, rotate, scale } = options;
|
|
61
|
+
let tangent, position, angle;
|
|
62
|
+
if (util.isPercentage(distance)) {
|
|
63
|
+
tangent = view.getTangentAtRatio(parseFloat(distance) / 100);
|
|
64
|
+
} else {
|
|
65
|
+
tangent = view.getTangentAtLength(distance);
|
|
66
|
+
}
|
|
67
|
+
if (tangent) {
|
|
68
|
+
position = tangent.start;
|
|
69
|
+
angle = tangent.vector().vectorAngle(new g.Point(1, 0)) || 0;
|
|
70
|
+
} else {
|
|
71
|
+
position = view.getConnection().start;
|
|
72
|
+
angle = 0;
|
|
73
|
+
}
|
|
74
|
+
let matrix = V.createSVGMatrix()
|
|
75
|
+
.translate(position.x, position.y)
|
|
76
|
+
.rotate(angle)
|
|
77
|
+
.translate(0, offset);
|
|
78
|
+
if (!rotate) matrix = matrix.rotate(-angle);
|
|
79
|
+
if (scale) matrix = matrix.scale(scale);
|
|
80
|
+
return matrix;
|
|
81
|
+
},
|
|
82
|
+
onPointerDown: function(evt) {
|
|
83
|
+
if (this.guard(evt)) return;
|
|
84
|
+
evt.stopPropagation();
|
|
85
|
+
evt.preventDefault();
|
|
86
|
+
var actionFn = this.options.action;
|
|
87
|
+
if (typeof actionFn === 'function') {
|
|
88
|
+
actionFn.call(this.relatedView, evt, this.relatedView, this);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export const Remove = Button.extend({
|
|
94
|
+
name: 'remove',
|
|
95
|
+
children: [{
|
|
96
|
+
tagName: 'circle',
|
|
97
|
+
selector: 'button',
|
|
98
|
+
attributes: {
|
|
99
|
+
'r': 7,
|
|
100
|
+
'fill': '#FF1D00',
|
|
101
|
+
'cursor': 'pointer'
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
tagName: 'path',
|
|
105
|
+
selector: 'icon',
|
|
106
|
+
attributes: {
|
|
107
|
+
'd': 'M -3 -3 3 3 M -3 3 3 -3',
|
|
108
|
+
'fill': 'none',
|
|
109
|
+
'stroke': '#FFFFFF',
|
|
110
|
+
'stroke-width': 2,
|
|
111
|
+
'pointer-events': 'none'
|
|
112
|
+
}
|
|
113
|
+
}],
|
|
114
|
+
options: {
|
|
115
|
+
distance: 60,
|
|
116
|
+
offset: 0,
|
|
117
|
+
action: function(evt, view, tool) {
|
|
118
|
+
view.model.remove({ ui: true, tool: tool.cid });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Button } from './Button.mjs';
|
|
2
|
+
import * as util from '../util/index.mjs';
|
|
3
|
+
|
|
4
|
+
export const Connect = Button.extend({
|
|
5
|
+
name: 'connect',
|
|
6
|
+
documentEvents: {
|
|
7
|
+
mousemove: 'drag',
|
|
8
|
+
touchmove: 'drag',
|
|
9
|
+
mouseup: 'dragend',
|
|
10
|
+
touchend: 'dragend',
|
|
11
|
+
touchcancel: 'dragend'
|
|
12
|
+
},
|
|
13
|
+
children: [{
|
|
14
|
+
tagName: 'circle',
|
|
15
|
+
selector: 'button',
|
|
16
|
+
attributes: {
|
|
17
|
+
'r': 7,
|
|
18
|
+
'fill': '#333333',
|
|
19
|
+
'cursor': 'pointer'
|
|
20
|
+
}
|
|
21
|
+
}, {
|
|
22
|
+
tagName: 'path',
|
|
23
|
+
selector: 'icon',
|
|
24
|
+
attributes: {
|
|
25
|
+
'd': 'M -4 -1 L 0 -1 L 0 -4 L 4 0 L 0 4 0 1 -4 1 z',
|
|
26
|
+
'fill': '#FFFFFF',
|
|
27
|
+
'stroke': 'none',
|
|
28
|
+
'stroke-width': 2,
|
|
29
|
+
'pointer-events': 'none'
|
|
30
|
+
}
|
|
31
|
+
}],
|
|
32
|
+
options: {
|
|
33
|
+
distance: 80,
|
|
34
|
+
offset: 0,
|
|
35
|
+
magnet: (view) => view.el,
|
|
36
|
+
action: (evt, _view, tool) => tool.dragstart(evt),
|
|
37
|
+
},
|
|
38
|
+
getMagnetNode: function() {
|
|
39
|
+
const { options, relatedView } = this;
|
|
40
|
+
const { magnet } = options;
|
|
41
|
+
let magnetNode;
|
|
42
|
+
switch (typeof magnet) {
|
|
43
|
+
case 'function': {
|
|
44
|
+
magnetNode = magnet.call(this, relatedView, this);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case 'string': {
|
|
48
|
+
magnetNode = relatedView.findNode(magnet);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
default: {
|
|
52
|
+
magnetNode = magnet;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (!magnetNode) magnetNode = relatedView.el;
|
|
57
|
+
if (magnetNode instanceof SVGElement) return magnetNode;
|
|
58
|
+
throw new Error('Connect: magnet must be an SVGElement');
|
|
59
|
+
},
|
|
60
|
+
dragstart: function(evt) {
|
|
61
|
+
const { paper, relatedView } = this;
|
|
62
|
+
const normalizedEvent = util.normalizeEvent(evt);
|
|
63
|
+
const { x, y } = paper.clientToLocalPoint(normalizedEvent.clientX, normalizedEvent.clientY);
|
|
64
|
+
relatedView.dragLinkStart(normalizedEvent, this.getMagnetNode(), x, y);
|
|
65
|
+
paper.undelegateEvents();
|
|
66
|
+
this.delegateDocumentEvents(null, normalizedEvent.data);
|
|
67
|
+
this.focus();
|
|
68
|
+
},
|
|
69
|
+
drag: function(evt) {
|
|
70
|
+
const { paper, relatedView } = this;
|
|
71
|
+
const normalizedEvent = util.normalizeEvent(evt);
|
|
72
|
+
const { x, y } = paper.snapToGrid(normalizedEvent.clientX, normalizedEvent.clientY);
|
|
73
|
+
relatedView.dragLink(normalizedEvent, x, y);
|
|
74
|
+
},
|
|
75
|
+
dragend: function(evt) {
|
|
76
|
+
const { paper, relatedView } = this;
|
|
77
|
+
const normalizedEvent = util.normalizeEvent(evt);
|
|
78
|
+
const { x, y } = paper.snapToGrid(normalizedEvent.clientX, normalizedEvent.clientY);
|
|
79
|
+
relatedView.dragLinkEnd(normalizedEvent, x, y);
|
|
80
|
+
this.undelegateDocumentEvents();
|
|
81
|
+
paper.delegateEvents();
|
|
82
|
+
this.blur();
|
|
83
|
+
relatedView.checkMouseleave(normalizedEvent);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Connect } from '../linkTools/Connect.mjs';
|
|
2
|
+
import V from '../V/index.mjs';
|
|
3
|
+
import $ from '../mvc/Dom/index.mjs';
|
|
4
|
+
import * as util from '../util/index.mjs';
|
|
5
|
+
import * as g from '../g/index.mjs';
|
|
6
|
+
|
|
7
|
+
export const HoverConnect = Connect.extend({
|
|
8
|
+
|
|
9
|
+
name: 'hover-connect',
|
|
10
|
+
|
|
11
|
+
defaultMarkup: [
|
|
12
|
+
{
|
|
13
|
+
tagName: 'circle',
|
|
14
|
+
attributes: {
|
|
15
|
+
'r': 7,
|
|
16
|
+
'fill': '#333333',
|
|
17
|
+
'cursor': 'pointer'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
tagName: 'path',
|
|
22
|
+
attributes: {
|
|
23
|
+
'd': 'M -4 -1 L 0 -1 L 0 -4 L 4 0 L 0 4 0 1 -4 1 z',
|
|
24
|
+
'fill': '#FFFFFF',
|
|
25
|
+
'stroke': 'none',
|
|
26
|
+
'stroke-width': 2
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
children() {
|
|
32
|
+
const { options, defaultMarkup } = this;
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
tagName: 'path',
|
|
36
|
+
selector: 'track',
|
|
37
|
+
attributes: {
|
|
38
|
+
'fill': 'none',
|
|
39
|
+
'stroke': 'transparent',
|
|
40
|
+
'stroke-width': options.trackWidth || 15,
|
|
41
|
+
'cursor': 'pointer'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
tagName: 'g',
|
|
46
|
+
selector: 'button',
|
|
47
|
+
attributes: {
|
|
48
|
+
'pointer-events': 'none',
|
|
49
|
+
'display': 'none'
|
|
50
|
+
},
|
|
51
|
+
children: options.markup || defaultMarkup
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
events: Object.assign({
|
|
57
|
+
mousemove: 'onMousemove',
|
|
58
|
+
mouseenter: 'onMouseenter',
|
|
59
|
+
mouseleave: 'onMouseleave'
|
|
60
|
+
}, Connect.prototype.events),
|
|
61
|
+
|
|
62
|
+
onRender: function() {
|
|
63
|
+
this.renderChildren();
|
|
64
|
+
this.update();
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
trackPath: null,
|
|
68
|
+
|
|
69
|
+
update() {
|
|
70
|
+
const { childNodes } = this;
|
|
71
|
+
this.trackPath = this.getTrackPath();
|
|
72
|
+
Connect.prototype.update.apply(this, arguments);
|
|
73
|
+
childNodes.track.setAttribute(
|
|
74
|
+
'd',
|
|
75
|
+
this.trackPath.serialize()
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
position() {
|
|
80
|
+
const { el, childNodes } = this;
|
|
81
|
+
childNodes.button.setAttribute(
|
|
82
|
+
'transform',
|
|
83
|
+
V.matrixToTransformString(this.getButtonMatrix())
|
|
84
|
+
);
|
|
85
|
+
el.setAttribute(
|
|
86
|
+
'transform',
|
|
87
|
+
V.matrixToTransformString(this.getTrackMatrix())
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
getButtonMatrix() {
|
|
92
|
+
const { options, trackPath } = this;
|
|
93
|
+
const { offset = 0, distance = 0, rotate, scale } = options;
|
|
94
|
+
let tangent, position, angle;
|
|
95
|
+
if (util.isPercentage(distance)) {
|
|
96
|
+
tangent = trackPath.tangentAtRatio(parseFloat(distance) / 100);
|
|
97
|
+
} else {
|
|
98
|
+
tangent = trackPath.tangentAtLength(distance);
|
|
99
|
+
}
|
|
100
|
+
if (tangent) {
|
|
101
|
+
position = tangent.start;
|
|
102
|
+
angle = tangent.vector().vectorAngle(new g.Point(1, 0)) || 0;
|
|
103
|
+
} else {
|
|
104
|
+
position = trackPath.start;
|
|
105
|
+
angle = 0;
|
|
106
|
+
}
|
|
107
|
+
let matrix = V.createSVGMatrix()
|
|
108
|
+
.translate(position.x, position.y)
|
|
109
|
+
.rotate(angle)
|
|
110
|
+
.translate(0, offset);
|
|
111
|
+
if (!rotate) matrix = matrix.rotate(-angle);
|
|
112
|
+
if (scale) matrix = matrix.scale(scale);
|
|
113
|
+
return matrix;
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
getTrackPath() {
|
|
117
|
+
return this.relatedView.getConnection();
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
getTrackMatrix() {
|
|
121
|
+
return V.createSVGMatrix();
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
getTrackRatioFromEvent(evt) {
|
|
125
|
+
const { relatedView, trackPath } = this;
|
|
126
|
+
const localPoint = relatedView.paper.clientToLocalPoint(evt.clientX, evt.clientY);
|
|
127
|
+
const trackPoint = V.transformPoint(localPoint, this.getTrackMatrix().inverse());
|
|
128
|
+
return trackPath.closestPointLength(trackPoint);
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
canShowButton() {
|
|
132
|
+
// Has been the paper events undelegated? If so, we can't show the button.
|
|
133
|
+
// TODO: add a method to the paper to check if the events are delegated.
|
|
134
|
+
return $.event.has(this.paper.el);
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
showButton() {
|
|
138
|
+
this.childNodes.button.style.display = 'block';
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
hideButton() {
|
|
142
|
+
this.childNodes.button.style.display = '';
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
onMousemove(evt) {
|
|
146
|
+
const { trackPath } = this;
|
|
147
|
+
if (!trackPath) return;
|
|
148
|
+
const { options } = this;
|
|
149
|
+
options.distance = this.getTrackRatioFromEvent(evt);
|
|
150
|
+
this.position();
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
onMouseenter() {
|
|
154
|
+
if (!this.canShowButton()) return;
|
|
155
|
+
this.showButton();
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
onMouseleave() {
|
|
159
|
+
this.hideButton();
|
|
160
|
+
}
|
|
161
|
+
});
|