@antv/g 3.3.2 → 3.3.6
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/.idea/encodings.xml +5 -8
- package/.idea/workspace.xml +656 -614
- package/build/g.js +5447 -8635
- package/dist/g.min.js +1 -1
- package/lib/core/advanced-event-emitter.js +32 -0
- package/lib/core/event-emitter.js +116 -0
- package/lib/core/event.js +149 -0
- package/lib/core/mixin/event.js +185 -0
- package/lib/index.js +1 -1
- package/lib/renderers/svg/painter.js +19 -6
- package/lib/shapes/marker.js +5 -0
- package/lib/util/common.js +32 -34
- package/lib/util/path.js +4 -1
- package/package.json +2 -2
- package/src/index.js +1 -1
- package/src/renderers/svg/painter.js +16 -6
- package/src/shapes/marker.js +4 -0
- package/src/util/common.js +32 -34
- package/src/util/path.js +3 -3
- package/lib/util/dom.js +0 -175
- package/lib/util/matrix.js +0 -91
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var Util = require('../util/index');
|
|
2
|
+
|
|
3
|
+
var Event = require('../event');
|
|
4
|
+
|
|
5
|
+
var EventEmitter = require('./event-emitter');
|
|
6
|
+
|
|
7
|
+
var PROPOGATE_EVENTS = ['click', 'mousedown', 'mouseup', 'dblclick', 'contextmenu', 'mouseout', 'mouseover', 'mousemove', 'dragstart', 'drag', 'dragend', 'dragenter', 'dragleave', 'drop'];
|
|
8
|
+
|
|
9
|
+
var AdvancedEE = function AdvancedEE() {};
|
|
10
|
+
|
|
11
|
+
Util.augment(AdvancedEE, EventEmitter, {
|
|
12
|
+
emit: function emit(evt, e) {
|
|
13
|
+
var args = arguments;
|
|
14
|
+
EventEmitter.prototype.emit.apply(this, args);
|
|
15
|
+
|
|
16
|
+
if (args.length >= 2 && args[1] instanceof Event && args[1].propagationStopped) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (PROPOGATE_EVENTS.indexOf(evt) >= 0 && e.target === this
|
|
21
|
+
/* prevent bubbling multiple times */
|
|
22
|
+
) {
|
|
23
|
+
var shape = this._cfg.parent;
|
|
24
|
+
|
|
25
|
+
while (shape && !shape.get('destroyed')) {
|
|
26
|
+
shape.emit.apply(shape, args);
|
|
27
|
+
shape = shape._cfg.parent;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
module.exports = AdvancedEE;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var Util = require('../util/common');
|
|
2
|
+
|
|
3
|
+
var slice = Array.prototype.slice;
|
|
4
|
+
|
|
5
|
+
function indexOfCallback(events, callback) {
|
|
6
|
+
var i = events.length;
|
|
7
|
+
|
|
8
|
+
while (i--) {
|
|
9
|
+
if (events[i].callback === callback) {
|
|
10
|
+
return i;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return -1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
var EventEmitter = function EventEmitter() {};
|
|
18
|
+
|
|
19
|
+
Util.augment(EventEmitter, {
|
|
20
|
+
on: function on(evt, callback, one) {
|
|
21
|
+
var self = this;
|
|
22
|
+
|
|
23
|
+
if (!Util.isFunction(callback)) {
|
|
24
|
+
throw new TypeError('listener should be a function');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!self._cfg._events) {
|
|
28
|
+
self._cfg._events = {};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!self._cfg._events[evt]) {
|
|
32
|
+
self._cfg._events[evt] = [];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
self._cfg._events[evt].push({
|
|
36
|
+
callback: callback,
|
|
37
|
+
one: one
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return this;
|
|
41
|
+
},
|
|
42
|
+
one: function one(evt, callback) {
|
|
43
|
+
this.on(evt, callback, true);
|
|
44
|
+
return this;
|
|
45
|
+
},
|
|
46
|
+
emit: function emit(evt) {
|
|
47
|
+
if (this.get('destroyed')) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!this._cfg._events || Util.isEmpty(this._cfg._events)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var events = this._cfg._events[evt];
|
|
56
|
+
|
|
57
|
+
if (Util.isEmpty(events)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var args = arguments;
|
|
62
|
+
var arg = slice.call(args, 1);
|
|
63
|
+
var length = events.length;
|
|
64
|
+
|
|
65
|
+
for (var i = 0; i < length;) {
|
|
66
|
+
events[i].callback.apply(this, arg);
|
|
67
|
+
|
|
68
|
+
if (events[i].one) {
|
|
69
|
+
events.splice(i, 1);
|
|
70
|
+
length--;
|
|
71
|
+
} else {
|
|
72
|
+
i++;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
trigger: function trigger() {
|
|
77
|
+
this.emit.apply(this, arguments);
|
|
78
|
+
},
|
|
79
|
+
off: function off(evt, callback) {
|
|
80
|
+
var events = this._cfg._events;
|
|
81
|
+
|
|
82
|
+
if (!events || Util.isEmpty(events)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (arguments.length === 0) {
|
|
87
|
+
this._cfg._events = {};
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (events[evt]) {
|
|
92
|
+
var index = indexOfCallback(events[evt], callback);
|
|
93
|
+
|
|
94
|
+
if (index >= 0) {
|
|
95
|
+
events[evt].splice(index, 1);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (events[evt].length === 0) {
|
|
99
|
+
delete events[evt];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
removeEvent: function removeEvent(evt) {
|
|
104
|
+
if (typeof evt === 'undefined') {
|
|
105
|
+
this._cfg._events = {};
|
|
106
|
+
} else {
|
|
107
|
+
delete this._cfg._events[evt];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return this;
|
|
111
|
+
},
|
|
112
|
+
_getEvents: function _getEvents() {
|
|
113
|
+
return this._cfg._events || {};
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
module.exports = EventEmitter;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
var Util = require('../util/index');
|
|
2
|
+
|
|
3
|
+
var Event = require('../event');
|
|
4
|
+
|
|
5
|
+
var EVENTS = ['click', 'mousedown', 'mouseup', 'dblclick', 'contextmenu', 'mouseenter', 'mouseout', 'mouseover', 'mousemove', 'mouseleave'];
|
|
6
|
+
var preShape = null;
|
|
7
|
+
var mousedown = null;
|
|
8
|
+
var dragging = null;
|
|
9
|
+
module.exports = {
|
|
10
|
+
registerEvent: function registerEvent() {
|
|
11
|
+
var self = this;
|
|
12
|
+
var el = this.get('el');
|
|
13
|
+
Util.each(EVENTS, function (evt) {
|
|
14
|
+
el.addEventListener(evt, function (e) {
|
|
15
|
+
self._triggerEvent(evt, e);
|
|
16
|
+
}, false);
|
|
17
|
+
}); // special cases
|
|
18
|
+
|
|
19
|
+
el.addEventListener('touchstart', function (e) {
|
|
20
|
+
if (!Util.isEmpty(e.touches)) {
|
|
21
|
+
self._triggerEvent('touchstart', e.touches[0]);
|
|
22
|
+
}
|
|
23
|
+
}, false);
|
|
24
|
+
el.addEventListener('touchmove', function (e) {
|
|
25
|
+
if (!Util.isEmpty(e.touches)) {
|
|
26
|
+
self._triggerEvent('touchmove', e.touches[0]);
|
|
27
|
+
}
|
|
28
|
+
}, false);
|
|
29
|
+
el.addEventListener('touchend', function (e) {
|
|
30
|
+
if (!Util.isEmpty(e.changedTouches)) {
|
|
31
|
+
self._triggerEvent('touchend', e.changedTouches[0]);
|
|
32
|
+
}
|
|
33
|
+
}, false);
|
|
34
|
+
},
|
|
35
|
+
_getEmitter: function _getEmitter(element, event) {
|
|
36
|
+
if (element) {
|
|
37
|
+
if (Util.isEmpty(element._getEvents())) {
|
|
38
|
+
var parent = element.get('parent');
|
|
39
|
+
|
|
40
|
+
if (parent && !event.propagationStopped) {
|
|
41
|
+
return this._getEmitter(parent, event);
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
return element;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
_getEventObj: function _getEventObj(type, e, point, target) {
|
|
49
|
+
var event = new Event(type, e, true, true);
|
|
50
|
+
event.x = point.x;
|
|
51
|
+
event.y = point.y;
|
|
52
|
+
event.clientX = e.clientX;
|
|
53
|
+
event.clientY = e.clientY;
|
|
54
|
+
event.currentTarget = target;
|
|
55
|
+
event.target = target;
|
|
56
|
+
return event;
|
|
57
|
+
},
|
|
58
|
+
_triggerEvent: function _triggerEvent(type, e) {
|
|
59
|
+
var point = this.getPointByClient(e.clientX, e.clientY);
|
|
60
|
+
var shape = this.getShape(point.x, point.y, e);
|
|
61
|
+
var el = this.get('el'); // svg原生事件取不到dragover, dragout, drop等事件的对象。这边需要走数学拾取。
|
|
62
|
+
|
|
63
|
+
if (dragging && this.getRenderer() === 'svg') {
|
|
64
|
+
shape = this.getShape(point.x, point.y);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (type === 'mousemove') {
|
|
68
|
+
if (preShape && preShape !== shape) {
|
|
69
|
+
this._emitEvent('mouseout', e, point, preShape);
|
|
70
|
+
|
|
71
|
+
this._emitEvent('mouseleave', e, point, preShape);
|
|
72
|
+
|
|
73
|
+
if (dragging) {
|
|
74
|
+
this._emitEvent('dragleave', e, point, preShape);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!preShape.destroyed && !preShape.removed) {
|
|
78
|
+
el.style.cursor = preShape.attr('cursor') || 'default';
|
|
79
|
+
}
|
|
80
|
+
} // 拖拽过程中不会触发mousemove事件
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if (dragging) {
|
|
84
|
+
this._emitEvent('drag', e, point, dragging);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (shape) {
|
|
88
|
+
if (!dragging) {
|
|
89
|
+
if (mousedown === shape) {
|
|
90
|
+
dragging = shape;
|
|
91
|
+
mousedown = null;
|
|
92
|
+
|
|
93
|
+
this._emitEvent('dragstart', e, point, shape);
|
|
94
|
+
} else {
|
|
95
|
+
this._emitEvent('mousemove', e, point, shape);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (preShape !== shape) {
|
|
100
|
+
this._emitEvent('mouseenter', e, point, shape);
|
|
101
|
+
|
|
102
|
+
this._emitEvent('mouseover', e, point, shape);
|
|
103
|
+
|
|
104
|
+
if (dragging) {
|
|
105
|
+
this._emitEvent('dragenter', e, point, shape);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
var canvasmousemove = this._getEventObj('mousemove', e, point, this);
|
|
110
|
+
|
|
111
|
+
this.emit('mousemove', canvasmousemove);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
preShape = shape;
|
|
115
|
+
} else {
|
|
116
|
+
this._emitEvent(type, e, point, shape || this);
|
|
117
|
+
|
|
118
|
+
if (!dragging && type === 'mousedown') {
|
|
119
|
+
mousedown = shape;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (type === 'mouseup') {
|
|
123
|
+
mousedown = null;
|
|
124
|
+
|
|
125
|
+
if (dragging) {
|
|
126
|
+
dragging._cfg.capture = true;
|
|
127
|
+
|
|
128
|
+
this._emitEvent('dragend', e, point, dragging);
|
|
129
|
+
|
|
130
|
+
dragging = null;
|
|
131
|
+
|
|
132
|
+
this._emitEvent('drop', e, point, shape || this);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (shape && !shape.destroyed) {
|
|
138
|
+
el.style.cursor = shape.attr('cursor') || 'default';
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
_emitEvent: function _emitEvent(type, evt, point, shape) {
|
|
142
|
+
var event = this._getEventObj(type, evt, point, shape);
|
|
143
|
+
|
|
144
|
+
var emitShape = this._getEmitter(shape, evt);
|
|
145
|
+
|
|
146
|
+
emitShape && emitShape.emit(type, event);
|
|
147
|
+
return emitShape;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
var Util = require('../../util/index');
|
|
2
|
+
|
|
3
|
+
var Event = require('../../event');
|
|
4
|
+
|
|
5
|
+
var EVENTS = ['mousedown', 'mouseup', 'dblclick', 'mouseenter', 'mouseout', 'mouseover', 'mousemove', 'mouseleave'];
|
|
6
|
+
var CLICK_OFFSET = 40;
|
|
7
|
+
var LEFT_BTN_CODE = 0;
|
|
8
|
+
var preShape = null;
|
|
9
|
+
var mousedownShape = null;
|
|
10
|
+
var mousedownOffset = {};
|
|
11
|
+
var dragging = null;
|
|
12
|
+
var dragTimer = null;
|
|
13
|
+
module.exports = {
|
|
14
|
+
registerEvent: function registerEvent() {
|
|
15
|
+
var self = this;
|
|
16
|
+
var el = this.get('el');
|
|
17
|
+
Util.each(EVENTS, function (evt) {
|
|
18
|
+
el.addEventListener(evt, function (e) {
|
|
19
|
+
self._triggerEvent(evt, e);
|
|
20
|
+
}, false);
|
|
21
|
+
}); // special cases
|
|
22
|
+
|
|
23
|
+
el.addEventListener('touchstart', function (e) {
|
|
24
|
+
if (!Util.isEmpty(e.touches)) {
|
|
25
|
+
self._triggerEvent('touchstart', e.touches[0]);
|
|
26
|
+
}
|
|
27
|
+
}, false);
|
|
28
|
+
el.addEventListener('touchmove', function (e) {
|
|
29
|
+
if (!Util.isEmpty(e.touches)) {
|
|
30
|
+
self._triggerEvent('touchmove', e.touches[0]);
|
|
31
|
+
}
|
|
32
|
+
}, false);
|
|
33
|
+
el.addEventListener('touchend', function (e) {
|
|
34
|
+
if (!Util.isEmpty(e.changedTouches)) {
|
|
35
|
+
self._triggerEvent('touchend', e.changedTouches[0]);
|
|
36
|
+
}
|
|
37
|
+
}, false);
|
|
38
|
+
el.addEventListener('contextmenu', function (e) {
|
|
39
|
+
self._triggerEvent('contextmenu', e);
|
|
40
|
+
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
}, false);
|
|
43
|
+
},
|
|
44
|
+
_getEmitter: function _getEmitter(element, event) {
|
|
45
|
+
if (element) {
|
|
46
|
+
if (Util.isEmpty(element._getEvents())) {
|
|
47
|
+
var parent = element.get('parent');
|
|
48
|
+
|
|
49
|
+
if (parent && !event.propagationStopped) {
|
|
50
|
+
return this._getEmitter(parent, event);
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
return element;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
_getEventObj: function _getEventObj(type, e, point, target) {
|
|
58
|
+
var event = new Event(type, e, true, true); // 事件的x,y应该是基于画布左上角的,与canvas的matrix无关
|
|
59
|
+
|
|
60
|
+
event.x = point.x;
|
|
61
|
+
event.y = point.y;
|
|
62
|
+
event.clientX = e.clientX;
|
|
63
|
+
event.clientY = e.clientY;
|
|
64
|
+
event.currentTarget = target;
|
|
65
|
+
event.target = target;
|
|
66
|
+
return event;
|
|
67
|
+
},
|
|
68
|
+
_triggerEvent: function _triggerEvent(type, e) {
|
|
69
|
+
var self = this;
|
|
70
|
+
var point = self.getPointByClient(e.clientX, e.clientY);
|
|
71
|
+
var shape = self.getShape(point.x, point.y, e);
|
|
72
|
+
var el = self.get('el'); // svg原生事件取不到dragover, dragout, drop等事件的对象。这边需要走数学拾取。
|
|
73
|
+
|
|
74
|
+
if (dragging && self.getRenderer() === 'svg') {
|
|
75
|
+
shape = self.getShape(point.x, point.y);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (type === 'mousemove') {
|
|
79
|
+
if (preShape && preShape !== shape) {
|
|
80
|
+
self._emitEvent('mouseout', e, point, preShape);
|
|
81
|
+
|
|
82
|
+
self._emitEvent('mouseleave', e, point, preShape);
|
|
83
|
+
|
|
84
|
+
if (dragging) {
|
|
85
|
+
self._emitEvent('dragleave', e, point, preShape);
|
|
86
|
+
} // 当 mouseleave 触发时,如果拾取到其他 shape 的 mouseenter ,鼠标样式会正常
|
|
87
|
+
// 当鼠标移出 shape 但是移动到画布上时,没有shape,就不恢复样式。这里判断一下,直接重置
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
if (!shape || shape.destroyed) {
|
|
91
|
+
el.style.cursor = 'default';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (dragging) {
|
|
96
|
+
self._emitEvent('drag', e, point, dragging);
|
|
97
|
+
/**
|
|
98
|
+
* H5原生事件中drag同时不会触发mousemove
|
|
99
|
+
* 但是在上层具有嵌套关系的item事件计算中需要用到drag时的mousemove
|
|
100
|
+
* 才能计算dragenter etc.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
self._emitEvent('mousemove', e, point, shape);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (shape) {
|
|
108
|
+
if (!dragging) {
|
|
109
|
+
if (mousedownShape === shape) {
|
|
110
|
+
dragging = shape;
|
|
111
|
+
mousedownShape = null;
|
|
112
|
+
|
|
113
|
+
this._emitEvent('dragstart', e, point, shape);
|
|
114
|
+
} else {
|
|
115
|
+
self._emitEvent('mousemove', e, point, shape);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (preShape !== shape) {
|
|
120
|
+
self._emitEvent('mouseenter', e, point, shape);
|
|
121
|
+
|
|
122
|
+
self._emitEvent('mouseover', e, point, shape);
|
|
123
|
+
|
|
124
|
+
if (dragging) {
|
|
125
|
+
self._emitEvent('dragenter', e, point, shape);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
var canvasmousemove = self._getEventObj('mousemove', e, point, self);
|
|
130
|
+
|
|
131
|
+
self.emit('mousemove', canvasmousemove);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
preShape = shape;
|
|
135
|
+
} else {
|
|
136
|
+
this._emitEvent(type, e, point, shape || this); // e.button === 0 保证按下左键,防止点击右键触发click
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
if (!dragging && type === 'mousedown' && e.button === LEFT_BTN_CODE) {
|
|
140
|
+
mousedownShape = shape;
|
|
141
|
+
mousedownOffset = {
|
|
142
|
+
x: e.clientX,
|
|
143
|
+
y: e.clientY
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (type === 'mouseup' && e.button === LEFT_BTN_CODE) {
|
|
148
|
+
var dx = mousedownOffset.x - e.clientX;
|
|
149
|
+
var dy = mousedownOffset.y - e.clientY;
|
|
150
|
+
var dist = dx * dx + dy * dy;
|
|
151
|
+
|
|
152
|
+
if (dist < CLICK_OFFSET) {
|
|
153
|
+
clearTimeout(dragTimer);
|
|
154
|
+
dragTimer = null;
|
|
155
|
+
|
|
156
|
+
this._emitEvent('click', e, point, mousedownShape || this);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (dragging) {
|
|
160
|
+
dragging._cfg.capture = true;
|
|
161
|
+
|
|
162
|
+
this._emitEvent('dragend', e, point, dragging);
|
|
163
|
+
|
|
164
|
+
dragging = null;
|
|
165
|
+
|
|
166
|
+
this._emitEvent('drop', e, point, shape || this);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
mousedownShape = null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (shape && !shape.get('destroyed')) {
|
|
174
|
+
el.style.cursor = shape.attr('cursor') || 'default';
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
_emitEvent: function _emitEvent(type, evt, point, shape) {
|
|
178
|
+
var event = this._getEventObj(type, evt, point, shape);
|
|
179
|
+
|
|
180
|
+
var emitShape = this._getEmitter(shape, evt);
|
|
181
|
+
|
|
182
|
+
emitShape && !emitShape.get('destroyed') && emitShape.emit(type, event);
|
|
183
|
+
return emitShape;
|
|
184
|
+
}
|
|
185
|
+
};
|
package/lib/index.js
CHANGED
|
@@ -105,6 +105,8 @@ function () {
|
|
|
105
105
|
});
|
|
106
106
|
|
|
107
107
|
try {
|
|
108
|
+
model.resetMatrix();
|
|
109
|
+
|
|
108
110
|
self._drawGroup(model, false);
|
|
109
111
|
} catch (ev) {
|
|
110
112
|
// 绘制时异常,中断重绘
|
|
@@ -526,7 +528,13 @@ function () {
|
|
|
526
528
|
transform.push(matrix[i] + ',' + matrix[i + 1]);
|
|
527
529
|
}
|
|
528
530
|
|
|
529
|
-
|
|
531
|
+
transform = transform.join(',');
|
|
532
|
+
|
|
533
|
+
if (transform.indexOf('NaN') === -1) {
|
|
534
|
+
el.setAttribute('transform', "matrix(" + transform + ")");
|
|
535
|
+
} else {
|
|
536
|
+
console.warn('invalid matrix:', matrix);
|
|
537
|
+
}
|
|
530
538
|
};
|
|
531
539
|
|
|
532
540
|
_proto._setImage = function _setImage(model, img) {
|
|
@@ -768,13 +776,18 @@ function () {
|
|
|
768
776
|
blur: attrs.shadowBlur,
|
|
769
777
|
color: attrs.shadowColor
|
|
770
778
|
};
|
|
771
|
-
var id = this.context.find('filter', cfg);
|
|
772
779
|
|
|
773
|
-
if (!
|
|
774
|
-
|
|
775
|
-
}
|
|
780
|
+
if (!cfg.dx && !cfg.dy && !cfg.blur && !cfg.color) {
|
|
781
|
+
el.removeAttribute('filter');
|
|
782
|
+
} else {
|
|
783
|
+
var id = this.context.find('filter', cfg);
|
|
776
784
|
|
|
777
|
-
|
|
785
|
+
if (!id) {
|
|
786
|
+
id = this.context.addShadow(cfg, this);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
el.setAttribute('filter', "url(#" + id + ")");
|
|
790
|
+
}
|
|
778
791
|
};
|
|
779
792
|
|
|
780
793
|
return Painter;
|
package/lib/shapes/marker.js
CHANGED
package/lib/util/common.js
CHANGED
|
@@ -1,43 +1,41 @@
|
|
|
1
|
-
var Util = require('@antv/util/lib');
|
|
2
|
-
|
|
3
1
|
module.exports = {
|
|
4
|
-
isFunction:
|
|
5
|
-
isObject:
|
|
6
|
-
isBoolean:
|
|
7
|
-
isNil:
|
|
8
|
-
isString:
|
|
9
|
-
isArray:
|
|
10
|
-
isNumber:
|
|
11
|
-
isEmpty:
|
|
2
|
+
isFunction: require('@antv/util/lib/type/is-function'),
|
|
3
|
+
isObject: require('@antv/util/lib/type/is-object'),
|
|
4
|
+
isBoolean: require('@antv/util/lib/type/is-boolean'),
|
|
5
|
+
isNil: require('@antv/util/lib/type/is-nil'),
|
|
6
|
+
isString: require('@antv/util/lib/type/is-string'),
|
|
7
|
+
isArray: require('@antv/util/lib/type/is-array'),
|
|
8
|
+
isNumber: require('@antv/util/lib/type/is-number'),
|
|
9
|
+
isEmpty: require('@antv/util/lib/is-empty'),
|
|
12
10
|
// isBlank
|
|
13
|
-
uniqueId:
|
|
14
|
-
clone:
|
|
15
|
-
deepMix:
|
|
16
|
-
assign:
|
|
11
|
+
uniqueId: require('@antv/util/lib/unique-id'),
|
|
12
|
+
clone: require('@antv/util/lib/clone'),
|
|
13
|
+
deepMix: require('@antv/util/lib/deep-mix'),
|
|
14
|
+
assign: require('@antv/util/lib/mix'),
|
|
17
15
|
// simpleMix
|
|
18
|
-
merge:
|
|
16
|
+
merge: require('@antv/util/lib/deep-mix'),
|
|
19
17
|
// mix
|
|
20
|
-
upperFirst:
|
|
18
|
+
upperFirst: require('@antv/util/lib/string/upper-first'),
|
|
21
19
|
// ucfirst
|
|
22
|
-
each:
|
|
23
|
-
isEqual:
|
|
24
|
-
toArray:
|
|
25
|
-
extend:
|
|
26
|
-
augment:
|
|
27
|
-
remove:
|
|
28
|
-
isNumberEqual:
|
|
29
|
-
toRadian:
|
|
30
|
-
toDegree:
|
|
31
|
-
mod:
|
|
32
|
-
clamp:
|
|
33
|
-
createDom:
|
|
34
|
-
modifyCSS:
|
|
35
|
-
requestAnimationFrame:
|
|
20
|
+
each: require('@antv/util/lib/each'),
|
|
21
|
+
isEqual: require('@antv/util/lib/is-equal'),
|
|
22
|
+
toArray: require('@antv/util/lib/to-array'),
|
|
23
|
+
extend: require('@antv/util/lib/extend'),
|
|
24
|
+
augment: require('@antv/util/lib/augment'),
|
|
25
|
+
remove: require('@antv/util/lib/array/pull'),
|
|
26
|
+
isNumberEqual: require('@antv/util/lib/math/is-number-equal'),
|
|
27
|
+
toRadian: require('@antv/util/lib/math/to-radian'),
|
|
28
|
+
toDegree: require('@antv/util/lib/math/to-degree'),
|
|
29
|
+
mod: require('@antv/util/lib/math/mod'),
|
|
30
|
+
clamp: require('@antv/util/lib/math/clamp'),
|
|
31
|
+
createDom: require('@antv/util/lib/dom/create-dom'),
|
|
32
|
+
modifyCSS: require('@antv/util/lib/dom/modify-css'),
|
|
33
|
+
requestAnimationFrame: require('@antv/util/lib/dom/request-animation-frame'),
|
|
36
34
|
getRatio: function getRatio() {
|
|
37
35
|
return window.devicePixelRatio ? window.devicePixelRatio : 2;
|
|
38
36
|
},
|
|
39
|
-
mat3:
|
|
40
|
-
vec2:
|
|
41
|
-
vec3:
|
|
42
|
-
transform:
|
|
37
|
+
mat3: require('@antv/util/lib/matrix/mat3'),
|
|
38
|
+
vec2: require('@antv/util/lib/matrix/vec2'),
|
|
39
|
+
vec3: require('@antv/util/lib/matrix/vec3'),
|
|
40
|
+
transform: require('@antv/util/lib/matrix/transform')
|
|
43
41
|
};
|
package/lib/util/path.js
CHANGED
|
@@ -1301,14 +1301,17 @@ var fillPathByDiff = function fillPathByDiff(source, target) {
|
|
|
1301
1301
|
|
|
1302
1302
|
|
|
1303
1303
|
sourceLen = source.length;
|
|
1304
|
+
var diff = targetLen - sourceLen;
|
|
1304
1305
|
|
|
1305
1306
|
if (sourceLen < targetLen) {
|
|
1306
|
-
for (var _i6 = 0; _i6 <
|
|
1307
|
+
for (var _i6 = 0; _i6 < diff; _i6++) {
|
|
1307
1308
|
if (source[sourceLen - 1][0] === 'z' || source[sourceLen - 1][0] === 'Z') {
|
|
1308
1309
|
source.splice(sourceLen - 2, 0, source[sourceLen - 2]);
|
|
1309
1310
|
} else {
|
|
1310
1311
|
source.push(source[sourceLen - 1]);
|
|
1311
1312
|
}
|
|
1313
|
+
|
|
1314
|
+
sourceLen += 1;
|
|
1312
1315
|
}
|
|
1313
1316
|
}
|
|
1314
1317
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.6",
|
|
4
4
|
"description": "A canvas library which providing 2d draw for G2.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"canvas",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@antv/gl-matrix": "~2.7.1",
|
|
73
|
-
"@antv/util": "~1.
|
|
73
|
+
"@antv/util": "~1.3.1",
|
|
74
74
|
"d3-ease": "~1.0.3",
|
|
75
75
|
"d3-interpolate": "~1.1.5",
|
|
76
76
|
"d3-timer": "~1.0.6",
|
package/src/index.js
CHANGED