jmgraph 3.2.7 → 3.2.9
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/README.md +0 -1
- package/build/npminstall-debug.log +199 -0
- package/dist/jmgraph.core.min.js +1 -1
- package/dist/jmgraph.core.min.js.map +1 -1
- package/dist/jmgraph.js +3631 -2076
- package/dist/jmgraph.min.js +1 -1
- package/example/ball.html +8 -14
- package/example/cell.html +1 -1
- package/example/controls/arc.html +10 -7
- package/example/controls/arrowline.html +1 -0
- package/example/controls/img.html +30 -23
- package/example/controls/label.html +6 -4
- package/example/controls/line.html +54 -51
- package/example/controls/resize.html +47 -10
- package/example/index.html +2 -1
- package/example/music.html +101 -82
- package/example/webgl.html +48 -25
- package/package.json +56 -56
- package/src/core/jmControl.js +214 -116
- package/src/core/jmEvents.js +2 -2
- package/src/core/jmGradient.js +5 -3
- package/src/core/jmGraph.js +12 -22
- package/src/core/jmPath.js +1 -17
- package/src/core/jmUtils.js +7 -1
- package/src/lib/webgl/base.js +253 -1
- package/src/lib/webgl/core/buffer.js +2 -1
- package/src/lib/webgl/core/program.js +2 -2
- package/src/lib/webgl/core/texture.js +8 -8
- package/src/lib/webgl/gradient.js +11 -38
- package/src/lib/webgl/path.js +118 -235
- package/src/shapes/jmImage.js +18 -3
- package/src/shapes/jmLabel.js +84 -38
- package/src/shapes/jmRect.js +5 -2
- package/src/shapes/jmResize.js +70 -16
- package/build/package-lock.json +0 -19282
- package/docs/_config.yml +0 -1
- package/docs/about.html +0 -41
- package/docs/api/jmGraph.md +0 -2302
- package/docs/css/index.css +0 -131
- package/docs/images/ball.gif +0 -0
- package/docs/images/bezier.gif +0 -0
- package/docs/images/cell.gif +0 -0
- package/docs/images/chart.gif +0 -0
- package/docs/images/editor.gif +0 -0
- package/docs/images/sort.gif +0 -0
- package/docs/index.html +0 -80
- package/docs/js/helper.js +0 -89
- package/docs/js/jquery.min.js +0 -6
- package/example/love/img/music/bg.mp3 +0 -0
- package/example/love/img/music/bg_2019130144035.mp3 +0 -0
- package/example/love/img/music/f.mp3 +0 -0
- package/example/love/img/music/fail.mp3 +0 -0
- package/example/love/img/music/s.mp3 +0 -0
- package/example/love/img/music/s_201913014415.mp3 +0 -0
package/src/shapes/jmResize.js
CHANGED
|
@@ -20,6 +20,9 @@ export default class jmResize extends jmRect {
|
|
|
20
20
|
this.rectSize = params.rectSize || 8;
|
|
21
21
|
this.style.close = this.style.close || true;
|
|
22
22
|
|
|
23
|
+
// 方块鼠标指针方向
|
|
24
|
+
this.rectCursors = ['w-resize','nw-resize','n-resize','ne-resize','e-resize','se-resize','s-resize','sw-resize'];
|
|
25
|
+
|
|
23
26
|
this.init(params);
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
@@ -67,9 +70,9 @@ export default class jmResize extends jmRect {
|
|
|
67
70
|
rectStyle.close = true;
|
|
68
71
|
rectStyle.fill = rectStyle.fill || 'transparent';
|
|
69
72
|
|
|
70
|
-
for(let i = 0;i<8;i++) {
|
|
73
|
+
for(let i = 0; i<8; i++) {
|
|
71
74
|
//生成改变大小方块
|
|
72
|
-
|
|
75
|
+
const r = (this.graph || params.graph).createShape(jmRect,{
|
|
73
76
|
position:{x:0,y:0},
|
|
74
77
|
width: rs,
|
|
75
78
|
height: rs,
|
|
@@ -95,9 +98,9 @@ export default class jmResize extends jmRect {
|
|
|
95
98
|
*/
|
|
96
99
|
bindRectEvents() {
|
|
97
100
|
for(let i =0; i<this.resizeRects.length; i++) {
|
|
98
|
-
|
|
101
|
+
const r = this.resizeRects[i];
|
|
99
102
|
//小方块移动监听
|
|
100
|
-
r.on('move',function(arg) {
|
|
103
|
+
r.on('move',function(arg) {
|
|
101
104
|
let px=0, py=0, dx=0, dy=0;
|
|
102
105
|
if(this.index == 0) {
|
|
103
106
|
dx = - arg.offsetX;
|
|
@@ -135,15 +138,66 @@ export default class jmResize extends jmRect {
|
|
|
135
138
|
dy = arg.offsetY;
|
|
136
139
|
}
|
|
137
140
|
//重新定位
|
|
138
|
-
this.parent.reset(px,py,dx,dy);
|
|
141
|
+
this.parent.reset(px, py, dx, dy);
|
|
139
142
|
this.needUpdate = true;
|
|
140
143
|
});
|
|
141
144
|
//鼠标指针
|
|
142
|
-
r.bind('mousemove',function() {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
r.bind('mousemove', function() {
|
|
146
|
+
// 如果有旋转方位,则重新定义小块的作用
|
|
147
|
+
const rotation = this.parent.getRotation();
|
|
148
|
+
let cursor = this.parent.rectCursors[this.index];
|
|
149
|
+
|
|
150
|
+
// 旋转一定角度后的位置
|
|
151
|
+
const position = rotation && rotation.angle? this.graph.utils.rotatePoints(this.graph.utils.clone(this.position), rotation, rotation.angle): this.position;
|
|
152
|
+
const center = {
|
|
153
|
+
x: this.parent.width / 2,
|
|
154
|
+
y: this.parent.height / 2
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
this.rotationAngleByCenter = Math.atan((position.y - center.y) / (position.x - center.x));// 与中心连线和x轴的夹角
|
|
158
|
+
// 把90度分割成三个区域,不同的指针
|
|
159
|
+
const angleSplit1 = Math.atan(center.y / center.x) / 2;
|
|
160
|
+
const angleSplit2 = angleSplit1 * 2 + Math.PI / 4;
|
|
161
|
+
|
|
162
|
+
// 如果在左边,
|
|
163
|
+
if(position.x < center.x) {
|
|
164
|
+
if(this.rotationAngleByCenter >= -angleSplit1 && this.rotationAngleByCenter <= angleSplit1) {
|
|
165
|
+
cursor = this.parent.rectCursors[0];
|
|
166
|
+
}
|
|
167
|
+
else if(this.rotationAngleByCenter > angleSplit1 && this.rotationAngleByCenter < angleSplit2) {
|
|
168
|
+
cursor = this.parent.rectCursors[1];
|
|
169
|
+
}
|
|
170
|
+
else if(this.rotationAngleByCenter >= angleSplit2) {
|
|
171
|
+
cursor = this.parent.rectCursors[2];
|
|
172
|
+
}
|
|
173
|
+
else if(this.rotationAngleByCenter <= -angleSplit1 && this.rotationAngleByCenter > -angleSplit2) {
|
|
174
|
+
cursor = this.parent.rectCursors[7];
|
|
175
|
+
}
|
|
176
|
+
else if(this.rotationAngleByCenter <= -angleSplit2) {
|
|
177
|
+
cursor = this.parent.rectCursors[6];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
if(this.rotationAngleByCenter >= -angleSplit1 && this.rotationAngleByCenter <= angleSplit1) {
|
|
182
|
+
cursor = this.parent.rectCursors[4];
|
|
183
|
+
}
|
|
184
|
+
else if(this.rotationAngleByCenter > angleSplit1 && this.rotationAngleByCenter < angleSplit2) {
|
|
185
|
+
cursor = this.parent.rectCursors[5];
|
|
186
|
+
}
|
|
187
|
+
else if(this.rotationAngleByCenter >= angleSplit2) {
|
|
188
|
+
cursor = this.parent.rectCursors[6];
|
|
189
|
+
}
|
|
190
|
+
else if(this.rotationAngleByCenter <= -angleSplit1 && this.rotationAngleByCenter > -angleSplit2) {
|
|
191
|
+
cursor = this.parent.rectCursors[3];
|
|
192
|
+
}
|
|
193
|
+
else if(this.rotationAngleByCenter <= -angleSplit2) {
|
|
194
|
+
cursor = this.parent.rectCursors[2];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
this.cursor = cursor;
|
|
145
199
|
});
|
|
146
|
-
r.bind('mouseleave',function() {
|
|
200
|
+
r.bind('mouseleave', function() {
|
|
147
201
|
this.cursor = 'default';
|
|
148
202
|
});
|
|
149
203
|
}
|
|
@@ -192,13 +246,13 @@ export default class jmResize extends jmRect {
|
|
|
192
246
|
* @param {number} dy 大小y轴偏移
|
|
193
247
|
*/
|
|
194
248
|
reset(px, py, dx, dy) {
|
|
195
|
-
|
|
196
|
-
|
|
249
|
+
const minWidth = typeof this.style.minWidth=='undefined'?5:this.style.minWidth;
|
|
250
|
+
const minHeight = typeof this.style.minHeight=='undefined'?5:this.style.minHeight;
|
|
197
251
|
|
|
198
|
-
|
|
252
|
+
const location = this.getLocation();
|
|
199
253
|
if(dx != 0 || dy != 0) {
|
|
200
|
-
|
|
201
|
-
|
|
254
|
+
const w = location.width + dx;
|
|
255
|
+
const h = location.height + dy;
|
|
202
256
|
if(w >= minWidth || h >= minHeight) {
|
|
203
257
|
if(w >= minWidth) {
|
|
204
258
|
this.width = w;
|
|
@@ -216,7 +270,7 @@ export default class jmResize extends jmRect {
|
|
|
216
270
|
}
|
|
217
271
|
//如果当前控件能移动才能改变其位置
|
|
218
272
|
if(this.movable !== false && (px||py)) {
|
|
219
|
-
|
|
273
|
+
const p = this.position;
|
|
220
274
|
p.x = location.left + px;
|
|
221
275
|
p.y = location.top + py;
|
|
222
276
|
this.position = p;
|
|
@@ -227,7 +281,7 @@ export default class jmResize extends jmRect {
|
|
|
227
281
|
}
|
|
228
282
|
|
|
229
283
|
for(let i in this.resizeRects) {
|
|
230
|
-
|
|
284
|
+
const r = this.resizeRects[i];
|
|
231
285
|
switch(r.index) {
|
|
232
286
|
case 0: {
|
|
233
287
|
r.position.x = -r.width / 2;
|