@leafer-in/viewport 1.9.7 → 1.9.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/dist/viewport.cjs CHANGED
@@ -85,6 +85,13 @@ register("design", design);
85
85
  register("document", document);
86
86
 
87
87
  const MultiTouchHelper = {
88
+ state: {
89
+ type: "none",
90
+ typeCount: 0,
91
+ startTime: 0,
92
+ totalData: null,
93
+ center: {}
94
+ },
88
95
  getData(list) {
89
96
  const a = list[0], b = list[1];
90
97
  const lastCenter = core.PointHelper.getCenter(a.from, b.from);
@@ -103,9 +110,53 @@ const MultiTouchHelper = {
103
110
  rotation: rotation,
104
111
  center: center
105
112
  };
113
+ },
114
+ getType(data, config) {
115
+ const moveScore = Math.hypot(data.move.x, data.move.y) / (config.move || 5);
116
+ const scaleScore = Math.abs(data.scale - 1) / (config.scale || .03);
117
+ const rotateScore = Math.abs(data.rotation) / (config.rotation || 2);
118
+ if (moveScore < 1 && scaleScore < 1 && rotateScore < 1) return "none";
119
+ if (moveScore >= scaleScore && moveScore >= rotateScore) return "move";
120
+ if (scaleScore >= rotateScore) return "zoom";
121
+ return "rotate";
122
+ },
123
+ detect(data, config) {
124
+ const {state: state} = M;
125
+ const type = M.getType(data, config);
126
+ if (!state.totalData) {
127
+ state.startTime = Date.now();
128
+ state.center = data.center;
129
+ }
130
+ M.add(data, state.totalData);
131
+ state.totalData = data;
132
+ if (type === state.type) {
133
+ state.typeCount++;
134
+ if (state.typeCount >= (config.count || 3) && type !== "none") return type;
135
+ } else {
136
+ state.type = type;
137
+ state.typeCount = 1;
138
+ }
139
+ if (Date.now() - state.startTime >= (config.time || 160)) return M.getType(state.totalData, config);
140
+ return "none";
141
+ },
142
+ add(data, add) {
143
+ if (!add) return;
144
+ core.PointHelper.move(data.move, add.move);
145
+ data.scale *= add.scale;
146
+ data.rotation += add.rotation;
147
+ data.center = add.center;
148
+ },
149
+ reset() {
150
+ const {state: state} = M;
151
+ state.type = "none";
152
+ state.typeCount = 0;
153
+ state.startTime = 0;
154
+ state.totalData = null;
106
155
  }
107
156
  };
108
157
 
158
+ const M = MultiTouchHelper;
159
+
109
160
  const {abs: abs$1, max: max} = Math, {sign: sign, within: within} = core.MathHelper;
110
161
 
111
162
  const WheelEventHelper = {
@@ -145,9 +196,20 @@ const WheelEventHelper = {
145
196
  }
146
197
  };
147
198
 
199
+ let totalX, totalY, totalScale, totalRotation;
200
+
148
201
  class Transformer {
149
202
  get transforming() {
150
- return !!(this.moveData || this.zoomData || this.rotateData);
203
+ return this.moving || this.zooming || this.rotating;
204
+ }
205
+ get moving() {
206
+ return !!this.moveData;
207
+ }
208
+ get zooming() {
209
+ return !!this.zoomData;
210
+ }
211
+ get rotating() {
212
+ return !!this.rotateData;
151
213
  }
152
214
  constructor(interaction) {
153
215
  this.interaction = interaction;
@@ -157,13 +219,18 @@ class Transformer {
157
219
  if (!data.moveType) data.moveType = "move";
158
220
  if (!this.moveData) {
159
221
  this.setPath(data);
222
+ totalX = 0, totalY = 0;
160
223
  this.moveData = Object.assign(Object.assign({}, data), {
161
224
  moveX: 0,
162
- moveY: 0
225
+ moveY: 0,
226
+ totalX: totalX,
227
+ totalY: totalY
163
228
  });
164
229
  interaction.emit(core.MoveEvent.START, this.moveData);
165
230
  }
166
231
  data.path = this.moveData.path;
232
+ data.totalX = totalX = totalX + data.moveX;
233
+ data.totalY = totalY = totalY + data.moveY;
167
234
  interaction.emit(core.MoveEvent.BEFORE_MOVE, data);
168
235
  interaction.emit(core.MoveEvent.MOVE, data);
169
236
  this.transformEndWait();
@@ -172,12 +239,15 @@ class Transformer {
172
239
  const {interaction: interaction} = this;
173
240
  if (!this.zoomData) {
174
241
  this.setPath(data);
242
+ totalScale = 1;
175
243
  this.zoomData = Object.assign(Object.assign({}, data), {
176
- scale: 1
244
+ scale: 1,
245
+ totalScale: totalScale
177
246
  });
178
247
  interaction.emit(core.ZoomEvent.START, this.zoomData);
179
248
  }
180
249
  data.path = this.zoomData.path;
250
+ data.totalScale = totalScale = totalScale * data.scale;
181
251
  interaction.emit(core.ZoomEvent.BEFORE_ZOOM, data);
182
252
  interaction.emit(core.ZoomEvent.ZOOM, data);
183
253
  this.transformEndWait();
@@ -186,12 +256,15 @@ class Transformer {
186
256
  const {interaction: interaction} = this;
187
257
  if (!this.rotateData) {
188
258
  this.setPath(data);
259
+ totalRotation = 0;
189
260
  this.rotateData = Object.assign(Object.assign({}, data), {
190
- rotation: 0
261
+ rotation: 0,
262
+ totalRotation: totalRotation
191
263
  });
192
264
  interaction.emit(core.RotateEvent.START, this.rotateData);
193
265
  }
194
266
  data.path = this.rotateData.path;
267
+ data.totalRotation = totalRotation = totalRotation + data.rotation;
195
268
  interaction.emit(core.RotateEvent.BEFORE_ROTATE, data);
196
269
  interaction.emit(core.RotateEvent.ROTATE, data);
197
270
  this.transformEndWait();
@@ -210,9 +283,16 @@ class Transformer {
210
283
  }
211
284
  transformEnd() {
212
285
  const {interaction: interaction, moveData: moveData, zoomData: zoomData, rotateData: rotateData} = this;
213
- if (moveData) interaction.emit(core.MoveEvent.END, moveData);
214
- if (zoomData) interaction.emit(core.ZoomEvent.END, zoomData);
215
- if (rotateData) interaction.emit(core.RotateEvent.END, rotateData);
286
+ if (moveData) interaction.emit(core.MoveEvent.END, Object.assign(Object.assign({}, moveData), {
287
+ totalX: totalX,
288
+ totalY: totalY
289
+ }));
290
+ if (zoomData) interaction.emit(core.ZoomEvent.END, Object.assign(Object.assign({}, zoomData), {
291
+ totalScale: totalScale
292
+ }));
293
+ if (rotateData) interaction.emit(core.RotateEvent.END, Object.assign(Object.assign({}, rotateData), {
294
+ totalRotation: totalRotation
295
+ }));
216
296
  this.reset();
217
297
  }
218
298
  reset() {
@@ -310,14 +390,39 @@ interaction.wheel = function(data) {
310
390
  };
311
391
 
312
392
  interaction.multiTouch = function(data, list) {
313
- if (this.config.multiTouch.disabled) return;
314
- const {move: move, rotation: rotation, scale: scale, center: center} = MultiTouchHelper.getData(list);
315
- Object.assign(data, center);
316
- data.multiTouch = true;
393
+ const {disabled: disabled, singleGesture: singleGesture} = this.config.multiTouch;
394
+ if (disabled) return;
317
395
  this.pointerWaitCancel();
318
- this.rotate(getRotateEventData(rotation, data));
319
- this.zoom(getZoomEventData(scale, data));
320
- this.move(getMoveEventData(move, data));
396
+ let gestureData = MultiTouchHelper.getData(list);
397
+ let {moving: moving, zooming: zooming, rotating: rotating} = this.transformer;
398
+ if (singleGesture) {
399
+ if (!this.transformer.transforming) {
400
+ const type = MultiTouchHelper.detect(gestureData, core.isObject(singleGesture) ? singleGesture : {});
401
+ switch (type) {
402
+ case "move":
403
+ moving = true;
404
+ break;
405
+
406
+ case "zoom":
407
+ zooming = true;
408
+ break;
409
+
410
+ case "rotate":
411
+ rotating = true;
412
+ break;
413
+
414
+ default:
415
+ return;
416
+ }
417
+ MultiTouchHelper.reset();
418
+ }
419
+ if (!moving) gestureData.center = MultiTouchHelper.state.center;
420
+ } else moving = zooming = rotating = true;
421
+ Object.assign(data, gestureData.center);
422
+ data.multiTouch = true;
423
+ if (rotating) this.rotate(getRotateEventData(gestureData.rotation, data));
424
+ if (zooming) this.zoom(getZoomEventData(gestureData.scale, data));
425
+ if (moving) this.move(getMoveEventData(gestureData.move, data));
321
426
  };
322
427
 
323
428
  const dragger = core.Dragger.prototype;
@@ -1,4 +1,4 @@
1
- import { MoveEvent, LeafHelper, ZoomEvent, DataHelper, Debug, PointHelper, MathHelper, Platform, RotateEvent, Leafer, Bounds, Point, DragBoundsHelper, InteractionBase, Dragger, isNumber, BoundsHelper, Plugin } from "@leafer-ui/core";
1
+ import { MoveEvent, LeafHelper, ZoomEvent, DataHelper, Debug, PointHelper, MathHelper, Platform, RotateEvent, Leafer, Bounds, Point, DragBoundsHelper, InteractionBase, isObject, Dragger, isNumber, BoundsHelper, Plugin } from "@leafer-ui/core";
2
2
 
3
3
  function addViewport(leafer, mergeConfig, custom) {
4
4
  addViewportConfig(leafer.parentApp ? leafer.parentApp : leafer, mergeConfig);
@@ -83,6 +83,13 @@ register("design", design);
83
83
  register("document", document);
84
84
 
85
85
  const MultiTouchHelper = {
86
+ state: {
87
+ type: "none",
88
+ typeCount: 0,
89
+ startTime: 0,
90
+ totalData: null,
91
+ center: {}
92
+ },
86
93
  getData(list) {
87
94
  const a = list[0], b = list[1];
88
95
  const lastCenter = PointHelper.getCenter(a.from, b.from);
@@ -101,9 +108,53 @@ const MultiTouchHelper = {
101
108
  rotation: rotation,
102
109
  center: center
103
110
  };
111
+ },
112
+ getType(data, config) {
113
+ const moveScore = Math.hypot(data.move.x, data.move.y) / (config.move || 5);
114
+ const scaleScore = Math.abs(data.scale - 1) / (config.scale || .03);
115
+ const rotateScore = Math.abs(data.rotation) / (config.rotation || 2);
116
+ if (moveScore < 1 && scaleScore < 1 && rotateScore < 1) return "none";
117
+ if (moveScore >= scaleScore && moveScore >= rotateScore) return "move";
118
+ if (scaleScore >= rotateScore) return "zoom";
119
+ return "rotate";
120
+ },
121
+ detect(data, config) {
122
+ const {state: state} = M;
123
+ const type = M.getType(data, config);
124
+ if (!state.totalData) {
125
+ state.startTime = Date.now();
126
+ state.center = data.center;
127
+ }
128
+ M.add(data, state.totalData);
129
+ state.totalData = data;
130
+ if (type === state.type) {
131
+ state.typeCount++;
132
+ if (state.typeCount >= (config.count || 3) && type !== "none") return type;
133
+ } else {
134
+ state.type = type;
135
+ state.typeCount = 1;
136
+ }
137
+ if (Date.now() - state.startTime >= (config.time || 160)) return M.getType(state.totalData, config);
138
+ return "none";
139
+ },
140
+ add(data, add) {
141
+ if (!add) return;
142
+ PointHelper.move(data.move, add.move);
143
+ data.scale *= add.scale;
144
+ data.rotation += add.rotation;
145
+ data.center = add.center;
146
+ },
147
+ reset() {
148
+ const {state: state} = M;
149
+ state.type = "none";
150
+ state.typeCount = 0;
151
+ state.startTime = 0;
152
+ state.totalData = null;
104
153
  }
105
154
  };
106
155
 
156
+ const M = MultiTouchHelper;
157
+
107
158
  const {abs: abs$1, max: max} = Math, {sign: sign, within: within} = MathHelper;
108
159
 
109
160
  const WheelEventHelper = {
@@ -143,9 +194,20 @@ const WheelEventHelper = {
143
194
  }
144
195
  };
145
196
 
197
+ let totalX, totalY, totalScale, totalRotation;
198
+
146
199
  class Transformer {
147
200
  get transforming() {
148
- return !!(this.moveData || this.zoomData || this.rotateData);
201
+ return this.moving || this.zooming || this.rotating;
202
+ }
203
+ get moving() {
204
+ return !!this.moveData;
205
+ }
206
+ get zooming() {
207
+ return !!this.zoomData;
208
+ }
209
+ get rotating() {
210
+ return !!this.rotateData;
149
211
  }
150
212
  constructor(interaction) {
151
213
  this.interaction = interaction;
@@ -155,13 +217,18 @@ class Transformer {
155
217
  if (!data.moveType) data.moveType = "move";
156
218
  if (!this.moveData) {
157
219
  this.setPath(data);
220
+ totalX = 0, totalY = 0;
158
221
  this.moveData = Object.assign(Object.assign({}, data), {
159
222
  moveX: 0,
160
- moveY: 0
223
+ moveY: 0,
224
+ totalX: totalX,
225
+ totalY: totalY
161
226
  });
162
227
  interaction.emit(MoveEvent.START, this.moveData);
163
228
  }
164
229
  data.path = this.moveData.path;
230
+ data.totalX = totalX = totalX + data.moveX;
231
+ data.totalY = totalY = totalY + data.moveY;
165
232
  interaction.emit(MoveEvent.BEFORE_MOVE, data);
166
233
  interaction.emit(MoveEvent.MOVE, data);
167
234
  this.transformEndWait();
@@ -170,12 +237,15 @@ class Transformer {
170
237
  const {interaction: interaction} = this;
171
238
  if (!this.zoomData) {
172
239
  this.setPath(data);
240
+ totalScale = 1;
173
241
  this.zoomData = Object.assign(Object.assign({}, data), {
174
- scale: 1
242
+ scale: 1,
243
+ totalScale: totalScale
175
244
  });
176
245
  interaction.emit(ZoomEvent.START, this.zoomData);
177
246
  }
178
247
  data.path = this.zoomData.path;
248
+ data.totalScale = totalScale = totalScale * data.scale;
179
249
  interaction.emit(ZoomEvent.BEFORE_ZOOM, data);
180
250
  interaction.emit(ZoomEvent.ZOOM, data);
181
251
  this.transformEndWait();
@@ -184,12 +254,15 @@ class Transformer {
184
254
  const {interaction: interaction} = this;
185
255
  if (!this.rotateData) {
186
256
  this.setPath(data);
257
+ totalRotation = 0;
187
258
  this.rotateData = Object.assign(Object.assign({}, data), {
188
- rotation: 0
259
+ rotation: 0,
260
+ totalRotation: totalRotation
189
261
  });
190
262
  interaction.emit(RotateEvent.START, this.rotateData);
191
263
  }
192
264
  data.path = this.rotateData.path;
265
+ data.totalRotation = totalRotation = totalRotation + data.rotation;
193
266
  interaction.emit(RotateEvent.BEFORE_ROTATE, data);
194
267
  interaction.emit(RotateEvent.ROTATE, data);
195
268
  this.transformEndWait();
@@ -208,9 +281,16 @@ class Transformer {
208
281
  }
209
282
  transformEnd() {
210
283
  const {interaction: interaction, moveData: moveData, zoomData: zoomData, rotateData: rotateData} = this;
211
- if (moveData) interaction.emit(MoveEvent.END, moveData);
212
- if (zoomData) interaction.emit(ZoomEvent.END, zoomData);
213
- if (rotateData) interaction.emit(RotateEvent.END, rotateData);
284
+ if (moveData) interaction.emit(MoveEvent.END, Object.assign(Object.assign({}, moveData), {
285
+ totalX: totalX,
286
+ totalY: totalY
287
+ }));
288
+ if (zoomData) interaction.emit(ZoomEvent.END, Object.assign(Object.assign({}, zoomData), {
289
+ totalScale: totalScale
290
+ }));
291
+ if (rotateData) interaction.emit(RotateEvent.END, Object.assign(Object.assign({}, rotateData), {
292
+ totalRotation: totalRotation
293
+ }));
214
294
  this.reset();
215
295
  }
216
296
  reset() {
@@ -308,14 +388,39 @@ interaction.wheel = function(data) {
308
388
  };
309
389
 
310
390
  interaction.multiTouch = function(data, list) {
311
- if (this.config.multiTouch.disabled) return;
312
- const {move: move, rotation: rotation, scale: scale, center: center} = MultiTouchHelper.getData(list);
313
- Object.assign(data, center);
314
- data.multiTouch = true;
391
+ const {disabled: disabled, singleGesture: singleGesture} = this.config.multiTouch;
392
+ if (disabled) return;
315
393
  this.pointerWaitCancel();
316
- this.rotate(getRotateEventData(rotation, data));
317
- this.zoom(getZoomEventData(scale, data));
318
- this.move(getMoveEventData(move, data));
394
+ let gestureData = MultiTouchHelper.getData(list);
395
+ let {moving: moving, zooming: zooming, rotating: rotating} = this.transformer;
396
+ if (singleGesture) {
397
+ if (!this.transformer.transforming) {
398
+ const type = MultiTouchHelper.detect(gestureData, isObject(singleGesture) ? singleGesture : {});
399
+ switch (type) {
400
+ case "move":
401
+ moving = true;
402
+ break;
403
+
404
+ case "zoom":
405
+ zooming = true;
406
+ break;
407
+
408
+ case "rotate":
409
+ rotating = true;
410
+ break;
411
+
412
+ default:
413
+ return;
414
+ }
415
+ MultiTouchHelper.reset();
416
+ }
417
+ if (!moving) gestureData.center = MultiTouchHelper.state.center;
418
+ } else moving = zooming = rotating = true;
419
+ Object.assign(data, gestureData.center);
420
+ data.multiTouch = true;
421
+ if (rotating) this.rotate(getRotateEventData(gestureData.rotation, data));
422
+ if (zooming) this.zoom(getZoomEventData(gestureData.scale, data));
423
+ if (moving) this.move(getMoveEventData(gestureData.move, data));
319
424
  };
320
425
 
321
426
  const dragger = Dragger.prototype;
@@ -1,2 +1,2 @@
1
- import{MoveEvent as t,LeafHelper as e,ZoomEvent as o,DataHelper as a,Debug as i,PointHelper as n,MathHelper as s,Platform as r,RotateEvent as c,Leafer as m,Bounds as h,Point as l,DragBoundsHelper as u,InteractionBase as d,Dragger as g,isNumber as f,BoundsHelper as v,Plugin as p}from"@leafer-ui/core";function D(a,i,n){y(a.parentApp?a.parentApp:a,i),a.isApp||n||a.__eventIds.push(a.on_(t.BEFORE_MOVE,t=>{a.zoomLayer.move(a.getValidMove(t.moveX,t.moveY,!1))}),a.on_(t.END,t=>{e.animateMove(a.zoomLayer,a.getValidMove(t.moveX,t.moveY))}),a.on_(o.BEFORE_ZOOM,t=>{const{zoomLayer:e}=a,o=a.getValidScale(t.scale);1!==o&&e.scaleOfWorld(t,o)}))}function y(t,e){const o={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&a.assign(o,e),a.assign(t.config,o,t.userConfig)}const O=i.get("LeaferTypeCreator"),M={list:{},register(t,e){E[t]&&O.repeat(t),E[t]=e},run(t,e){const o=E[t];o&&o(e)}},{list:E,register:T}=M;T("viewport",D),T("custom",function(t){D(t,null,!0)}),T("design",function(t){D(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),T("document",function(t){D(t,{zoom:{min:1},move:{scroll:"limit"}})});const b={getData(t){const e=t[0],o=t[1],a=n.getCenter(e.from,o.from),i=n.getCenter(e.to,o.to),s={x:i.x-a.x,y:i.y-a.y},r=n.getDistance(e.from,o.from);return{move:s,scale:n.getDistance(e.to,o.to)/r,rotation:n.getRotation(e.from,o.from,e.to,o.to),center:i}}},{abs:x,max:z}=Math,{sign:j,within:X}=s,Y={getMove(t,e){let{moveSpeed:o}=e,{deltaX:a,deltaY:i}=t;t.shiftKey&&!a&&(a=i,i=0);const n=x(a),s=x(i);return n>50&&(a=z(50,n/3)*j(a)),s>50&&(i=z(50,s/3)*j(i)),{x:-a*o*2,y:-i*o*2}},getScale(t,e){let o,a=1,{zoomMode:i,zoomSpeed:n}=e;const s=t.deltaY||t.deltaX;if(i?(o="mouse"===i||!t.deltaX&&(r.intWheelDeltaY?Math.abs(s)>17:Math.ceil(s)!==s),(t.shiftKey||t.metaKey||t.ctrlKey)&&(o=!0)):o=!t.shiftKey&&(t.metaKey||t.ctrlKey),o){n=X(n,0,1);const o=t.deltaY?e.delta.y:e.delta.x,i=X(1-x(s)/(4*o)*n,.5,2);a=s>0?i:1/i}return a}};class R{get transforming(){return!!(this.moveData||this.zoomData||this.rotateData)}constructor(t){this.interaction=t}move(e){const{interaction:o}=this;e.moveType||(e.moveType="move"),this.moveData||(this.setPath(e),this.moveData=Object.assign(Object.assign({},e),{moveX:0,moveY:0}),o.emit(t.START,this.moveData)),e.path=this.moveData.path,o.emit(t.BEFORE_MOVE,e),o.emit(t.MOVE,e),this.transformEndWait()}zoom(t){const{interaction:e}=this;this.zoomData||(this.setPath(t),this.zoomData=Object.assign(Object.assign({},t),{scale:1}),e.emit(o.START,this.zoomData)),t.path=this.zoomData.path,e.emit(o.BEFORE_ZOOM,t),e.emit(o.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;this.rotateData||(this.setPath(t),this.rotateData=Object.assign(Object.assign({},t),{rotation:0}),e.emit(c.START,this.rotateData)),t.path=this.rotateData.path,e.emit(c.BEFORE_ROTATE,t),e.emit(c.ROTATE,t),this.transformEndWait()}setPath(t){const{interaction:e}=this,{path:o}=e.selector.getByPoint(t,e.hitRadius);t.path=o,e.cancelHover()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout(()=>{this.transformEnd()},this.interaction.p.transformTime)}transformEnd(){const{interaction:e,moveData:a,zoomData:i,rotateData:n}=this;a&&e.emit(t.END,a),i&&e.emit(o.END,i),n&&e.emit(c.END,n),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const S=m.prototype,_=new h,w=new l;function A(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function C(t,e){return Object.assign(Object.assign({},e),{scale:t})}S.initType=function(t){M.run(t,this)},S.getValidMove=function(t,e,o=!0){const{scroll:a,disabled:i}=this.app.config.move;if(w.set(t,e),a){const t=!0===a?"":a;t.includes("x")?w.y=0:t.includes("y")?w.x=0:Math.abs(w.x)>Math.abs(w.y)?w.y=0:w.x=0,o&&t.includes("limit")&&(_.set(this.__world).addPoint(this.zoomLayer),u.getValidMove(_,this.canvas.bounds,"inner",w,!0),t.includes("x")?w.y=0:t.includes("y")&&(w.x=0))}return{x:i?0:w.x,y:i?0:w.y}},S.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:o,max:a,disabled:i}=this.app.config.zoom,n=Math.abs(e*t);return o&&n<o?t=o/e:a&&n>a&&(t=a/e),i?1:t};const K=d.prototype;K.createTransformer=function(){this.transformer=new R(this)},K.move=function(t){this.transformer.move(t)},K.zoom=function(t){this.transformer.zoom(t)},K.rotate=function(t){this.transformer.rotate(t)},K.transformEnd=function(){this.transformer.transformEnd()},K.wheel=function(t){const{wheel:e,pointer:o}=this.config,{posDeltaSpeed:a,negDeltaSpeed:i}=e;if(e.disabled)return;t.deltaX>0?a&&(t.deltaX*=a):i&&(t.deltaX*=i),t.deltaY>0?a&&(t.deltaY*=a):i&&(t.deltaY*=i);const s=e.getScale?e.getScale(t,e):Y.getScale(t,e);if(1!==s)this.zoom(C(s,t));else{const a=e.getMove?e.getMove(t,e):Y.getMove(t,e);o.snap&&n.round(a),this.move(A(a,t))}},K.multiTouch=function(t,e){if(this.config.multiTouch.disabled)return;const{move:o,rotation:a,scale:i,center:n}=b.getData(e);Object.assign(t,n),t.multiTouch=!0,this.pointerWaitCancel(),this.rotate(function(t,e){return Object.assign(Object.assign({},e),{rotation:t})}(a,t)),this.zoom(C(i,t)),this.move(A(o,t))};const V=g.prototype,{abs:W}=Math;V.checkDragEndAnimate=function(t,e){const{moveX:o,moveY:a}=this.dragData,i=W(o),s=W(a),r=e?1:.1,c=this.canAnimate&&this.moving&&(i>r||s>r)&&this.interaction.m.dragAnimate;if(c){const r="touch"===t.pointerType?3:1,m=70;i*(e=e?f(c)?c:.95:r)>m?e=m/i:s*e>m&&(e=m/s),t=Object.assign({},t),n.move(t,o*e,a*e),this.drag(t),this.animate(()=>{this.dragEnd(t,1)})}return c},V.animate=function(t,e){const o=t||this.animateWait;o&&this.interaction.target.nextRender(o,null,e),this.animateWait=t},V.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},V.autoMoveOnDragOut=function(t){const{interaction:e,downData:o,canDragOut:a}=this,{autoDistance:i,dragOut:s}=e.m;if(!s||!a||!i)return;const r=e.shrinkCanvasBounds,{x:c,y:m}=r,h=v.maxX(r),l=v.maxY(r),u=t.x<c?i:h<t.x?-i:0,d=t.y<m?i:l<t.y?-i:0;let g=0,f=0;this.autoMoveTimer=setInterval(()=>{g+=u,f+=d,n.move(o,u,d),n.move(this.dragData,u,d),e.move(Object.assign(Object.assign({},t),{moveX:u,moveY:d,totalX:g,totalY:f,moveType:"drag"})),e.pointerMoveReal(t)},10)},V.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},p.add("viewport");export{M as LeaferTypeCreator,b as MultiTouchHelper,R as Transformer,Y as WheelEventHelper,D as addViewport,y as addViewportConfig};
1
+ import{MoveEvent as t,LeafHelper as e,ZoomEvent as o,DataHelper as a,Debug as n,PointHelper as i,MathHelper as s,Platform as r,RotateEvent as c,Leafer as m,Bounds as l,Point as h,DragBoundsHelper as u,InteractionBase as g,isObject as d,Dragger as v,isNumber as f,BoundsHelper as p,Plugin as y}from"@leafer-ui/core";function D(a,n,i){O(a.parentApp?a.parentApp:a,n),a.isApp||i||a.__eventIds.push(a.on_(t.BEFORE_MOVE,t=>{a.zoomLayer.move(a.getValidMove(t.moveX,t.moveY,!1))}),a.on_(t.END,t=>{e.animateMove(a.zoomLayer,a.getValidMove(t.moveX,t.moveY))}),a.on_(o.BEFORE_ZOOM,t=>{const{zoomLayer:e}=a,o=a.getValidScale(t.scale);1!==o&&e.scaleOfWorld(t,o)}))}function O(t,e){const o={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&a.assign(o,e),a.assign(t.config,o,t.userConfig)}const b=n.get("LeaferTypeCreator"),M={list:{},register(t,e){T[t]&&b.repeat(t),T[t]=e},run(t,e){const o=T[t];o&&o(e)}},{list:T,register:E}=M;E("viewport",D),E("custom",function(t){D(t,null,!0)}),E("design",function(t){D(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),E("document",function(t){D(t,{zoom:{min:1},move:{scroll:"limit"}})});const z={state:{type:"none",typeCount:0,startTime:0,totalData:null,center:{}},getData(t){const e=t[0],o=t[1],a=i.getCenter(e.from,o.from),n=i.getCenter(e.to,o.to),s={x:n.x-a.x,y:n.y-a.y},r=i.getDistance(e.from,o.from);return{move:s,scale:i.getDistance(e.to,o.to)/r,rotation:i.getRotation(e.from,o.from,e.to,o.to),center:n}},getType(t,e){const o=Math.hypot(t.move.x,t.move.y)/(e.move||5),a=Math.abs(t.scale-1)/(e.scale||.03),n=Math.abs(t.rotation)/(e.rotation||2);return o<1&&a<1&&n<1?"none":o>=a&&o>=n?"move":a>=n?"zoom":"rotate"},detect(t,e){const{state:o}=x,a=x.getType(t,e);if(o.totalData||(o.startTime=Date.now(),o.center=t.center),x.add(t,o.totalData),o.totalData=t,a===o.type){if(o.typeCount++,o.typeCount>=(e.count||3)&&"none"!==a)return a}else o.type=a,o.typeCount=1;return Date.now()-o.startTime>=(e.time||160)?x.getType(o.totalData,e):"none"},add(t,e){e&&(i.move(t.move,e.move),t.scale*=e.scale,t.rotation+=e.rotation,t.center=e.center)},reset(){const{state:t}=x;t.type="none",t.typeCount=0,t.startTime=0,t.totalData=null}},x=z,{abs:j,max:X}=Math,{sign:Y,within:R}=s,S={getMove(t,e){let{moveSpeed:o}=e,{deltaX:a,deltaY:n}=t;t.shiftKey&&!a&&(a=n,n=0);const i=j(a),s=j(n);return i>50&&(a=X(50,i/3)*Y(a)),s>50&&(n=X(50,s/3)*Y(n)),{x:-a*o*2,y:-n*o*2}},getScale(t,e){let o,a=1,{zoomMode:n,zoomSpeed:i}=e;const s=t.deltaY||t.deltaX;if(n?(o="mouse"===n||!t.deltaX&&(r.intWheelDeltaY?Math.abs(s)>17:Math.ceil(s)!==s),(t.shiftKey||t.metaKey||t.ctrlKey)&&(o=!0)):o=!t.shiftKey&&(t.metaKey||t.ctrlKey),o){i=R(i,0,1);const o=t.deltaY?e.delta.y:e.delta.x,n=R(1-j(s)/(4*o)*i,.5,2);a=s>0?n:1/n}return a}};let w,C,_,A;class K{get transforming(){return this.moving||this.zooming||this.rotating}get moving(){return!!this.moveData}get zooming(){return!!this.zoomData}get rotating(){return!!this.rotateData}constructor(t){this.interaction=t}move(e){const{interaction:o}=this;e.moveType||(e.moveType="move"),this.moveData||(this.setPath(e),w=0,C=0,this.moveData=Object.assign(Object.assign({},e),{moveX:0,moveY:0,totalX:w,totalY:C}),o.emit(t.START,this.moveData)),e.path=this.moveData.path,e.totalX=w+=e.moveX,e.totalY=C+=e.moveY,o.emit(t.BEFORE_MOVE,e),o.emit(t.MOVE,e),this.transformEndWait()}zoom(t){const{interaction:e}=this;this.zoomData||(this.setPath(t),_=1,this.zoomData=Object.assign(Object.assign({},t),{scale:1,totalScale:_}),e.emit(o.START,this.zoomData)),t.path=this.zoomData.path,t.totalScale=_*=t.scale,e.emit(o.BEFORE_ZOOM,t),e.emit(o.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;this.rotateData||(this.setPath(t),A=0,this.rotateData=Object.assign(Object.assign({},t),{rotation:0,totalRotation:A}),e.emit(c.START,this.rotateData)),t.path=this.rotateData.path,t.totalRotation=A+=t.rotation,e.emit(c.BEFORE_ROTATE,t),e.emit(c.ROTATE,t),this.transformEndWait()}setPath(t){const{interaction:e}=this,{path:o}=e.selector.getByPoint(t,e.hitRadius);t.path=o,e.cancelHover()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout(()=>{this.transformEnd()},this.interaction.p.transformTime)}transformEnd(){const{interaction:e,moveData:a,zoomData:n,rotateData:i}=this;a&&e.emit(t.END,Object.assign(Object.assign({},a),{totalX:w,totalY:C})),n&&e.emit(o.END,Object.assign(Object.assign({},n),{totalScale:_})),i&&e.emit(c.END,Object.assign(Object.assign({},i),{totalRotation:A})),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const V=m.prototype,W=new l,B=new h;function k(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function P(t,e){return Object.assign(Object.assign({},e),{scale:t})}V.initType=function(t){M.run(t,this)},V.getValidMove=function(t,e,o=!0){const{scroll:a,disabled:n}=this.app.config.move;if(B.set(t,e),a){const t=!0===a?"":a;t.includes("x")?B.y=0:t.includes("y")?B.x=0:Math.abs(B.x)>Math.abs(B.y)?B.y=0:B.x=0,o&&t.includes("limit")&&(W.set(this.__world).addPoint(this.zoomLayer),u.getValidMove(W,this.canvas.bounds,"inner",B,!0),t.includes("x")?B.y=0:t.includes("y")&&(B.x=0))}return{x:n?0:B.x,y:n?0:B.y}},V.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:o,max:a,disabled:n}=this.app.config.zoom,i=Math.abs(e*t);return o&&i<o?t=o/e:a&&i>a&&(t=a/e),n?1:t};const L=g.prototype;L.createTransformer=function(){this.transformer=new K(this)},L.move=function(t){this.transformer.move(t)},L.zoom=function(t){this.transformer.zoom(t)},L.rotate=function(t){this.transformer.rotate(t)},L.transformEnd=function(){this.transformer.transformEnd()},L.wheel=function(t){const{wheel:e,pointer:o}=this.config,{posDeltaSpeed:a,negDeltaSpeed:n}=e;if(e.disabled)return;t.deltaX>0?a&&(t.deltaX*=a):n&&(t.deltaX*=n),t.deltaY>0?a&&(t.deltaY*=a):n&&(t.deltaY*=n);const s=e.getScale?e.getScale(t,e):S.getScale(t,e);if(1!==s)this.zoom(P(s,t));else{const a=e.getMove?e.getMove(t,e):S.getMove(t,e);o.snap&&i.round(a),this.move(k(a,t))}},L.multiTouch=function(t,e){const{disabled:o,singleGesture:a}=this.config.multiTouch;if(o)return;this.pointerWaitCancel();let n=z.getData(e),{moving:i,zooming:s,rotating:r}=this.transformer;if(a){if(!this.transformer.transforming){switch(z.detect(n,d(a)?a:{})){case"move":i=!0;break;case"zoom":s=!0;break;case"rotate":r=!0;break;default:return}z.reset()}i||(n.center=z.state.center)}else i=s=r=!0;var c,m;Object.assign(t,n.center),t.multiTouch=!0,r&&this.rotate((c=n.rotation,m=t,Object.assign(Object.assign({},m),{rotation:c}))),s&&this.zoom(P(n.scale,t)),i&&this.move(k(n.move,t))};const F=v.prototype,{abs:N}=Math;F.checkDragEndAnimate=function(t,e){const{moveX:o,moveY:a}=this.dragData,n=N(o),s=N(a),r=e?1:.1,c=this.canAnimate&&this.moving&&(n>r||s>r)&&this.interaction.m.dragAnimate;if(c){const r="touch"===t.pointerType?3:1,m=70;n*(e=e?f(c)?c:.95:r)>m?e=m/n:s*e>m&&(e=m/s),t=Object.assign({},t),i.move(t,o*e,a*e),this.drag(t),this.animate(()=>{this.dragEnd(t,1)})}return c},F.animate=function(t,e){const o=t||this.animateWait;o&&this.interaction.target.nextRender(o,null,e),this.animateWait=t},F.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},F.autoMoveOnDragOut=function(t){const{interaction:e,downData:o,canDragOut:a}=this,{autoDistance:n,dragOut:s}=e.m;if(!s||!a||!n)return;const r=e.shrinkCanvasBounds,{x:c,y:m}=r,l=p.maxX(r),h=p.maxY(r),u=t.x<c?n:l<t.x?-n:0,g=t.y<m?n:h<t.y?-n:0;let d=0,v=0;this.autoMoveTimer=setInterval(()=>{d+=u,v+=g,i.move(o,u,g),i.move(this.dragData,u,g),e.move(Object.assign(Object.assign({},t),{moveX:u,moveY:g,totalX:d,totalY:v,moveType:"drag"})),e.pointerMoveReal(t)},10)},F.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},y.add("viewport");export{M as LeaferTypeCreator,z as MultiTouchHelper,K as Transformer,S as WheelEventHelper,D as addViewport,O as addViewportConfig};
2
2
  //# sourceMappingURL=viewport.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewport.esm.min.js","sources":["../../../../../../src/in/packages/viewport/src/type/viewport.ts","../../../../../../src/in/packages/viewport/src/LeaferTypeCreator.ts","../../../../../../src/in/packages/viewport/src/type/custom.ts","../../../../../../src/in/packages/viewport/src/type/design.ts","../../../../../../src/in/packages/viewport/src/type/document.ts","../../../../../../src/in/packages/viewport/src/interaction/MultiTouchHelper.ts","../../../../../../src/in/packages/viewport/src/interaction/WheelEventHelper.ts","../../../../../../src/in/packages/viewport/src/interaction/Transformer.ts","../../../../../../src/in/packages/viewport/src/Leafer.ts","../../../../../../src/in/packages/viewport/src/interaction/Interaction.ts","../../../../../../src/in/packages/viewport/src/interaction/Dragger.ts","../../../../../../src/in/packages/viewport/src/index.ts"],"sourcesContent":["import { ILeaferBase, ILeaferConfig } from '@leafer-ui/interface'\n\nimport { MoveEvent, ZoomEvent, DataHelper, LeafHelper } from '@leafer-ui/core'\n\n\nexport function addViewport(leafer: ILeaferBase, mergeConfig?: ILeaferConfig, custom?: boolean): void {\n addViewportConfig(leafer.parentApp ? leafer.parentApp : leafer, mergeConfig)\n if (leafer.isApp || custom) return\n\n leafer.__eventIds.push(\n leafer.on_(MoveEvent.BEFORE_MOVE, (e: MoveEvent) => {\n leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY, false))\n }),\n leafer.on_(MoveEvent.END, (e: MoveEvent) => {\n LeafHelper.animateMove(leafer.zoomLayer, leafer.getValidMove(e.moveX, e.moveY))\n }),\n leafer.on_(ZoomEvent.BEFORE_ZOOM, (e: ZoomEvent) => {\n const { zoomLayer } = leafer\n const changeScale = leafer.getValidScale(e.scale)\n if (changeScale !== 1) zoomLayer.scaleOfWorld(e, changeScale)\n })\n )\n}\n\nexport function addViewportConfig(leafer: ILeaferBase, mergeConfig?: ILeaferConfig): void {\n const viewportConfig: ILeaferConfig = {\n wheel: { preventDefault: true },\n touch: { preventDefault: true },\n pointer: { preventDefaultMenu: true }\n }\n if (mergeConfig) DataHelper.assign(viewportConfig, mergeConfig)\n DataHelper.assign(leafer.config, viewportConfig, leafer.userConfig)\n}","import { ILeaferBase, ILeaferTypeList, ILeaferTypeFunction } from '@leafer-ui/interface'\n\nimport { Debug } from '@leafer-ui/core'\n\nimport { addViewport } from './type/viewport'\nimport { custom } from './type/custom'\nimport { design } from './type/design'\nimport { document } from './type/document'\n\n\nconst debug = Debug.get('LeaferTypeCreator')\n\nexport const LeaferTypeCreator = {\n\n list: {} as ILeaferTypeList,\n\n register(name: string, fn: ILeaferTypeFunction): void {\n list[name] && debug.repeat(name)\n list[name] = fn\n },\n\n run(name: string, leafer: ILeaferBase): void {\n const fn = list[name]\n fn && fn(leafer)\n }\n\n}\n\nconst { list, register } = LeaferTypeCreator\n\nregister('viewport', addViewport)\nregister('custom', custom)\nregister('design', design)\nregister('document', document)","import { ILeaferBase } from '@leafer-ui/interface'\n\nimport { addViewport } from './viewport'\n\n\nexport function custom(leafer: ILeaferBase): void {\n addViewport(leafer, null, true)\n}\n","import { ILeaferBase } from '@leafer-ui/interface'\n\nimport { addViewport } from './viewport'\n\n\nexport function design(leafer: ILeaferBase): void {\n addViewport(leafer, {\n zoom: {\n min: 0.01,\n max: 256\n },\n move: {\n holdSpaceKey: true,\n holdMiddleKey: true,\n }\n })\n}\n","import { ILeaferBase } from '@leafer-ui/interface'\n\nimport { addViewport } from './viewport'\n\n\nexport function document(leafer: ILeaferBase): void {\n addViewport(leafer, {\n zoom: { min: 1 },\n move: { scroll: 'limit' }\n })\n}\n","import { IMultiTouchData, IKeepTouchData } from '@leafer-ui/interface'\n\nimport { PointHelper } from '@leafer-ui/core'\n\n\nexport const MultiTouchHelper = {\n\n getData(list: IKeepTouchData[]): IMultiTouchData {\n const a = list[0], b = list[1]\n const lastCenter = PointHelper.getCenter(a.from, b.from)\n const center = PointHelper.getCenter(a.to, b.to)\n const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y }\n\n const lastDistance = PointHelper.getDistance(a.from, b.from)\n const distance = PointHelper.getDistance(a.to, b.to)\n const scale = distance / lastDistance\n\n const rotation = PointHelper.getRotation(a.from, b.from, a.to, b.to)\n\n return { move, scale, rotation, center }\n }\n\n}","import { IPointData, IWheelEvent, IWheelConfig } from '@leafer-ui/interface'\n\nimport { MathHelper, Platform } from '@leafer-ui/core'\n\n\nconst { abs, max } = Math, { sign, within } = MathHelper\n\nexport const WheelEventHelper = {\n\n getMove(event: IWheelEvent, config: IWheelConfig): IPointData {\n let { moveSpeed } = config\n let { deltaX, deltaY } = event\n if (event.shiftKey && !deltaX) { // Window\n deltaX = deltaY\n deltaY = 0\n }\n const absX = abs(deltaX), absY = abs(deltaY)\n if (absX > 50) deltaX = max(50, absX / 3) * sign(deltaX)\n if (absY > 50) deltaY = max(50, absY / 3) * sign(deltaY)\n return { x: -deltaX * moveSpeed * 2, y: -deltaY * moveSpeed * 2 }\n },\n\n getScale(event: IWheelEvent, config: IWheelConfig): number {\n\n let zoom: boolean\n let scale = 1\n let { zoomMode, zoomSpeed } = config\n\n const delta = event.deltaY || event.deltaX\n\n if (zoomMode) {\n // mac 触摸板滚动手势的deltaY是整数, 鼠标滚动/触摸板缩放的deltaY有小数点, firfox鼠标滚动为整数,为18或19的倍数\n // windows 始终是整数\n zoom = (zoomMode === 'mouse') ? true : (!event.deltaX && (Platform.intWheelDeltaY ? Math.abs(delta) > 17 : Math.ceil(delta) !== delta))\n if (event.shiftKey || event.metaKey || event.ctrlKey) zoom = true\n } else {\n zoom = !event.shiftKey && (event.metaKey || event.ctrlKey)\n }\n\n if (zoom) {\n zoomSpeed = within(zoomSpeed, 0, 1)\n const min = event.deltaY ? config.delta.y : config.delta.x\n const absScale = within(1 - abs(delta) / (min * 4) * zoomSpeed, 0.5, 2)\n scale = delta > 0 ? absScale : 1 / absScale // 让 scale 放大、缩小可以定位在有规律的刻度上\n }\n\n return scale\n }\n\n}","import { IMoveEvent, IZoomEvent, IRotateEvent, ITimer } from '@leafer-ui/interface'\n\nimport { InteractionBase, MoveEvent, ZoomEvent, RotateEvent } from '@leafer-ui/core'\n\n\nexport class Transformer {\n\n public get transforming(): boolean { return !!(this.moveData || this.zoomData || this.rotateData) }\n\n protected interaction: InteractionBase\n protected moveData: IMoveEvent\n protected zoomData: IZoomEvent\n protected rotateData: IRotateEvent\n protected transformTimer: ITimer\n\n constructor(interaction: InteractionBase) {\n this.interaction = interaction\n }\n\n public move(data: IMoveEvent): void {\n const { interaction } = this\n if (!data.moveType) data.moveType = 'move'\n\n if (!this.moveData) {\n this.setPath(data)\n this.moveData = { ...data, moveX: 0, moveY: 0 }\n interaction.emit(MoveEvent.START, this.moveData)\n }\n\n data.path = this.moveData.path\n interaction.emit(MoveEvent.BEFORE_MOVE, data)\n interaction.emit(MoveEvent.MOVE, data)\n\n this.transformEndWait()\n }\n\n public zoom(data: IZoomEvent): void {\n const { interaction } = this\n\n if (!this.zoomData) {\n this.setPath(data)\n this.zoomData = { ...data, scale: 1 }\n interaction.emit(ZoomEvent.START, this.zoomData)\n }\n\n data.path = this.zoomData.path\n interaction.emit(ZoomEvent.BEFORE_ZOOM, data)\n interaction.emit(ZoomEvent.ZOOM, data)\n\n this.transformEndWait()\n }\n\n public rotate(data: IRotateEvent): void {\n const { interaction } = this\n\n if (!this.rotateData) {\n this.setPath(data)\n this.rotateData = { ...data, rotation: 0 }\n interaction.emit(RotateEvent.START, this.rotateData)\n }\n\n data.path = this.rotateData.path\n interaction.emit(RotateEvent.BEFORE_ROTATE, data)\n interaction.emit(RotateEvent.ROTATE, data)\n\n this.transformEndWait()\n }\n\n public setPath(data: any): void {\n const { interaction } = this\n const { path } = interaction.selector.getByPoint(data, interaction.hitRadius)\n data.path = path\n interaction.cancelHover()\n }\n\n protected transformEndWait(): void {\n clearTimeout(this.transformTimer)\n this.transformTimer = setTimeout(() => {\n this.transformEnd()\n }, this.interaction.p.transformTime)\n }\n\n public transformEnd(): void {\n const { interaction, moveData, zoomData, rotateData } = this\n if (moveData) interaction.emit(MoveEvent.END, moveData)\n if (zoomData) interaction.emit(ZoomEvent.END, zoomData)\n if (rotateData) interaction.emit(RotateEvent.END, rotateData)\n this.reset()\n }\n\n public reset(): void {\n this.zoomData = this.moveData = this.rotateData = null\n }\n\n public destroy(): void {\n this.reset()\n }\n}","import { ILeaferType, IPointData } from '@leafer-ui/interface'\n\nimport { Leafer, Bounds, Point, DragBoundsHelper } from '@leafer-ui/core'\n\nimport { LeaferTypeCreator } from './LeaferTypeCreator'\n\n\nconst leafer = Leafer.prototype\nconst bounds = new Bounds(), move = new Point()\n\nleafer.initType = function (type: ILeaferType) {\n LeaferTypeCreator.run(type, this)\n}\n\nleafer.getValidMove = function (moveX: number, moveY: number, checkLimit = true): IPointData {\n const { scroll, disabled } = this.app.config.move\n move.set(moveX, moveY)\n\n if (scroll) {\n const type = scroll === true ? '' : scroll\n\n if (type.includes('x')) move.y = 0\n else if (type.includes('y')) move.x = 0\n else Math.abs(move.x) > Math.abs(move.y) ? move.y = 0 : move.x = 0\n\n if (checkLimit && type.includes('limit')) {\n bounds.set(this.__world).addPoint(this.zoomLayer as IPointData)\n DragBoundsHelper.getValidMove(bounds, this.canvas.bounds, 'inner', move, true)\n if (type.includes('x')) move.y = 0\n else if (type.includes('y')) move.x = 0\n }\n }\n\n return { x: disabled ? 0 : move.x, y: disabled ? 0 : move.y }\n}\n\nleafer.getValidScale = function (changeScale: number): number {\n const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale)\n if (min && absScale < min) changeScale = min / scaleX\n else if (max && absScale > max) changeScale = max / scaleX\n return disabled ? 1 : changeScale // fix 不能过滤小数位\n}","import { IMoveEvent, IZoomEvent, IRotateEvent, IWheelEvent, IKeepTouchData, IPointData, IEvent, IPointerEvent } from '@leafer-ui/interface'\n\nimport { InteractionBase, PointHelper } from '@leafer-ui/core'\n\nimport { WheelEventHelper } from './WheelEventHelper'\nimport { Transformer } from './Transformer'\nimport { MultiTouchHelper } from './MultiTouchHelper'\n\n\nfunction getMoveEventData(move: IPointData, event: IEvent): IMoveEvent {\n return { ...event, moveX: move.x, moveY: move.y } as IMoveEvent\n}\n\nfunction getRotateEventData(rotation: number, event: IEvent): IRotateEvent {\n return { ...event, rotation } as IRotateEvent\n}\n\nfunction getZoomEventData(scale: number, event: IEvent): IZoomEvent {\n return { ...event, scale, } as IZoomEvent\n}\n\n\nconst interaction = InteractionBase.prototype\n\ninteraction.createTransformer = function (): void {\n this.transformer = new Transformer(this)\n}\n\ninteraction.move = function (data: IMoveEvent): void {\n this.transformer.move(data)\n}\n\ninteraction.zoom = function (data: IZoomEvent): void {\n this.transformer.zoom(data)\n}\n\ninteraction.rotate = function (data: IRotateEvent): void {\n this.transformer.rotate(data)\n}\n\ninteraction.transformEnd = function (): void {\n this.transformer.transformEnd()\n}\n\n\ninteraction.wheel = function (data: IWheelEvent): void {\n const { wheel, pointer } = this.config, { posDeltaSpeed, negDeltaSpeed } = wheel\n if (wheel.disabled) return\n\n if (data.deltaX > 0) posDeltaSpeed && (data.deltaX *= posDeltaSpeed)\n else negDeltaSpeed && (data.deltaX *= negDeltaSpeed)\n\n if (data.deltaY > 0) posDeltaSpeed && (data.deltaY *= posDeltaSpeed)\n else negDeltaSpeed && (data.deltaY *= negDeltaSpeed)\n\n const scale = wheel.getScale ? wheel.getScale(data, wheel) : WheelEventHelper.getScale(data, wheel)\n if (scale !== 1) this.zoom(getZoomEventData(scale, data))\n else {\n const move = wheel.getMove ? wheel.getMove(data, wheel) : WheelEventHelper.getMove(data, wheel)\n if (pointer.snap) PointHelper.round(move)\n this.move(getMoveEventData(move, data))\n }\n}\n\n\ninteraction.multiTouch = function (data: IPointerEvent, list: IKeepTouchData[]): void {\n if (this.config.multiTouch.disabled) return\n const { move, rotation, scale, center } = MultiTouchHelper.getData(list)\n\n Object.assign(data, center)\n data.multiTouch = true\n\n this.pointerWaitCancel()\n\n this.rotate(getRotateEventData(rotation, data))\n this.zoom(getZoomEventData(scale, data))\n this.move(getMoveEventData(move, data))\n}","import { IPointerEvent, IFunction } from '@leafer-ui/interface'\n\nimport { Dragger, BoundsHelper, PointHelper, isNumber } from '@leafer-ui/core'\n\n\nconst dragger = Dragger.prototype\nconst { abs } = Math\n\ndragger.checkDragEndAnimate = function (data: IPointerEvent, speed?: number): boolean | number {\n const { moveX, moveY } = this.dragData\n const absMoveX = abs(moveX), absMoveY = abs(moveY), minMove = speed ? 1 : 0.1\n const dragAnimate = this.canAnimate && this.moving && (absMoveX > minMove || absMoveY > minMove) && this.interaction.m.dragAnimate\n\n if (dragAnimate) {\n const inertia = data.pointerType === 'touch' ? 3 : 1, maxMove = 70\n speed = speed ? (isNumber(dragAnimate) ? dragAnimate : 0.95) : inertia\n if (absMoveX * speed > maxMove) speed = maxMove / absMoveX\n else if (absMoveY * speed > maxMove) speed = maxMove / absMoveY\n\n data = { ...data }\n PointHelper.move(data, moveX * speed, moveY * speed)\n\n this.drag(data)\n this.animate(() => { this.dragEnd(data, 1) })\n }\n\n return dragAnimate\n}\n\ndragger.animate = function (func?: IFunction, off?: 'off'): void { // dragEnd animation\n const animateWait = func || this.animateWait\n if (animateWait) this.interaction.target.nextRender(animateWait, null, off)\n this.animateWait = func\n}\n\ndragger.checkDragOut = function (data: IPointerEvent): void {\n const { interaction } = this\n this.autoMoveCancel()\n if (this.dragging && !interaction.shrinkCanvasBounds.hitPoint(data)) this.autoMoveOnDragOut(data)\n}\n\ndragger.autoMoveOnDragOut = function (data: IPointerEvent): void {\n const { interaction, downData, canDragOut } = this\n const { autoDistance, dragOut } = interaction.m\n if (!dragOut || !canDragOut || !autoDistance) return\n\n const bounds = interaction.shrinkCanvasBounds\n const { x, y } = bounds\n const right = BoundsHelper.maxX(bounds)\n const bottom = BoundsHelper.maxY(bounds)\n\n const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0)\n const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0)\n let totalX = 0, totalY = 0\n\n this.autoMoveTimer = setInterval(() => {\n totalX += moveX\n totalY += moveY\n\n PointHelper.move(downData, moveX, moveY)\n PointHelper.move(this.dragData, moveX, moveY)\n\n interaction.move({ ...data, moveX, moveY, totalX, totalY, moveType: 'drag' })\n interaction.pointerMoveReal(data)\n }, 10)\n}\n\ndragger.autoMoveCancel = function (): void {\n if (this.autoMoveTimer) {\n clearInterval(this.autoMoveTimer)\n this.autoMoveTimer = 0\n }\n}","export { LeaferTypeCreator } from './LeaferTypeCreator'\nexport { addViewport, addViewportConfig } from './type/viewport'\nexport { MultiTouchHelper } from './interaction/MultiTouchHelper'\nexport { WheelEventHelper } from './interaction/WheelEventHelper'\nexport { Transformer } from './interaction/Transformer'\n\nimport { Plugin } from '@leafer-ui/core'\n\nimport './Leafer'\nimport './interaction/Interaction'\nimport './interaction/Dragger'\n\nPlugin.add('viewport')"],"names":["addViewport","leafer","mergeConfig","custom","addViewportConfig","parentApp","isApp","__eventIds","push","on_","MoveEvent","BEFORE_MOVE","e","zoomLayer","move","getValidMove","moveX","moveY","END","LeafHelper","animateMove","ZoomEvent","BEFORE_ZOOM","changeScale","getValidScale","scale","scaleOfWorld","viewportConfig","wheel","preventDefault","touch","pointer","preventDefaultMenu","DataHelper","assign","config","userConfig","debug","Debug","get","LeaferTypeCreator","list","register","name","fn","repeat","run","zoom","min","max","holdSpaceKey","holdMiddleKey","scroll","MultiTouchHelper","getData","a","b","lastCenter","PointHelper","getCenter","from","center","to","x","y","lastDistance","getDistance","rotation","getRotation","abs","Math","sign","within","MathHelper","WheelEventHelper","getMove","event","moveSpeed","deltaX","deltaY","shiftKey","absX","absY","getScale","zoomMode","zoomSpeed","delta","Platform","intWheelDeltaY","ceil","metaKey","ctrlKey","absScale","Transformer","transforming","this","moveData","zoomData","rotateData","constructor","interaction","data","moveType","setPath","Object","emit","START","path","MOVE","transformEndWait","ZOOM","rotate","RotateEvent","BEFORE_ROTATE","ROTATE","selector","getByPoint","hitRadius","cancelHover","clearTimeout","transformTimer","setTimeout","transformEnd","p","transformTime","reset","destroy","Leafer","prototype","bounds","Bounds","Point","getMoveEventData","getZoomEventData","initType","type","checkLimit","disabled","app","set","includes","__world","addPoint","DragBoundsHelper","canvas","scaleX","__","InteractionBase","createTransformer","transformer","posDeltaSpeed","negDeltaSpeed","snap","round","multiTouch","pointerWaitCancel","getRotateEventData","dragger","Dragger","checkDragEndAnimate","speed","dragData","absMoveX","absMoveY","minMove","dragAnimate","canAnimate","moving","m","inertia","pointerType","maxMove","isNumber","drag","animate","dragEnd","func","off","animateWait","target","nextRender","checkDragOut","autoMoveCancel","dragging","shrinkCanvasBounds","hitPoint","autoMoveOnDragOut","downData","canDragOut","autoDistance","dragOut","right","BoundsHelper","maxX","bottom","maxY","totalX","totalY","autoMoveTimer","setInterval","pointerMoveReal","clearInterval","Plugin","add"],"mappings":"sTAKgBA,EAAYC,EAAqBC,EAA6BC,GAC1EC,EAAkBH,EAAOI,UAAYJ,EAAOI,UAAYJ,EAAQC,GAC5DD,EAAOK,OAASH,GAEpBF,EAAOM,WAAWC,KACdP,EAAOQ,IAAIC,EAAUC,YAAcC,IAC/BX,EAAOY,UAAUC,KAAKb,EAAOc,aAAaH,EAAEI,MAAOJ,EAAEK,OAAO,MAEhEhB,EAAOQ,IAAIC,EAAUQ,IAAMN,IACvBO,EAAWC,YAAYnB,EAAOY,UAAWZ,EAAOc,aAAaH,EAAEI,MAAOJ,EAAEK,UAE5EhB,EAAOQ,IAAIY,EAAUC,YAAcV,IAC/B,MAAMC,UAAEA,GAAcZ,EAChBsB,EAActB,EAAOuB,cAAcZ,EAAEa,OACvB,IAAhBF,GAAmBV,EAAUa,aAAad,EAAGW,KAG7D,CAEM,SAAUnB,EAAkBH,EAAqBC,GACnD,MAAMyB,EAAgC,CAClCC,MAAO,CAAEC,gBAAgB,GACzBC,MAAO,CAAED,gBAAgB,GACzBE,QAAS,CAAEC,oBAAoB,IAE/B9B,GAAa+B,EAAWC,OAAOP,EAAgBzB,GACnD+B,EAAWC,OAAOjC,EAAOkC,OAAQR,EAAgB1B,EAAOmC,WAC5D,CCtBA,MAAMC,EAAQC,EAAMC,IAAI,qBAEXC,EAAoB,CAE7BC,KAAM,CAAA,EAEN,QAAAC,CAASC,EAAcC,GACnBH,EAAKE,IAASN,EAAMQ,OAAOF,GAC3BF,EAAKE,GAAQC,CACjB,EAEA,GAAAE,CAAIH,EAAc1C,GACd,MAAM2C,EAAKH,EAAKE,GAChBC,GAAMA,EAAG3C,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,KAAK6K,EAAU3K,EAAOC,GAClCyC,EAAY5C,KAAKiF,KAAKkE,SAAUjJ,EAAOC,GAEvCmF,EAAYtF,KAAI0F,OAAAtE,OAAAsE,OAAAtE,OAAA,GAAMmE,GAAI,CAAErF,QAAOC,QAAOmL,SAAQC,SAAQ/F,SAAU,UACpEF,EAAYoG,gBAAgBnG,IAC7B,GACP,EAEAwD,EAAQyB,eAAiB,WACjBvF,KAAKuG,gBACLG,cAAc1G,KAAKuG,eACnBvG,KAAKuG,cAAgB,EAE7B,EC5DAI,EAAOC,IAAI"}
1
+ {"version":3,"file":"viewport.esm.min.js","sources":["../../../../../../src/in/packages/viewport/src/type/viewport.ts","../../../../../../src/in/packages/viewport/src/LeaferTypeCreator.ts","../../../../../../src/in/packages/viewport/src/type/custom.ts","../../../../../../src/in/packages/viewport/src/type/design.ts","../../../../../../src/in/packages/viewport/src/type/document.ts","../../../../../../src/in/packages/viewport/src/interaction/MultiTouchHelper.ts","../../../../../../src/in/packages/viewport/src/interaction/WheelEventHelper.ts","../../../../../../src/in/packages/viewport/src/interaction/Transformer.ts","../../../../../../src/in/packages/viewport/src/Leafer.ts","../../../../../../src/in/packages/viewport/src/interaction/Interaction.ts","../../../../../../src/in/packages/viewport/src/interaction/Dragger.ts","../../../../../../src/in/packages/viewport/src/index.ts"],"sourcesContent":["import { ILeaferBase, ILeaferConfig } from '@leafer-ui/interface'\n\nimport { MoveEvent, ZoomEvent, DataHelper, LeafHelper } from '@leafer-ui/core'\n\n\nexport function addViewport(leafer: ILeaferBase, mergeConfig?: ILeaferConfig, custom?: boolean): void {\n addViewportConfig(leafer.parentApp ? leafer.parentApp : leafer, mergeConfig)\n if (leafer.isApp || custom) return\n\n leafer.__eventIds.push(\n leafer.on_(MoveEvent.BEFORE_MOVE, (e: MoveEvent) => {\n leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY, false))\n }),\n leafer.on_(MoveEvent.END, (e: MoveEvent) => {\n LeafHelper.animateMove(leafer.zoomLayer, leafer.getValidMove(e.moveX, e.moveY))\n }),\n leafer.on_(ZoomEvent.BEFORE_ZOOM, (e: ZoomEvent) => {\n const { zoomLayer } = leafer\n const changeScale = leafer.getValidScale(e.scale)\n if (changeScale !== 1) zoomLayer.scaleOfWorld(e, changeScale)\n })\n )\n}\n\nexport function addViewportConfig(leafer: ILeaferBase, mergeConfig?: ILeaferConfig): void {\n const viewportConfig: ILeaferConfig = {\n wheel: { preventDefault: true },\n touch: { preventDefault: true },\n pointer: { preventDefaultMenu: true }\n }\n if (mergeConfig) DataHelper.assign(viewportConfig, mergeConfig)\n DataHelper.assign(leafer.config, viewportConfig, leafer.userConfig)\n}","import { ILeaferBase, ILeaferTypeList, ILeaferTypeFunction } from '@leafer-ui/interface'\n\nimport { Debug } from '@leafer-ui/core'\n\nimport { addViewport } from './type/viewport'\nimport { custom } from './type/custom'\nimport { design } from './type/design'\nimport { document } from './type/document'\n\n\nconst debug = Debug.get('LeaferTypeCreator')\n\nexport const LeaferTypeCreator = {\n\n list: {} as ILeaferTypeList,\n\n register(name: string, fn: ILeaferTypeFunction): void {\n list[name] && debug.repeat(name)\n list[name] = fn\n },\n\n run(name: string, leafer: ILeaferBase): void {\n const fn = list[name]\n fn && fn(leafer)\n }\n\n}\n\nconst { list, register } = LeaferTypeCreator\n\nregister('viewport', addViewport)\nregister('custom', custom)\nregister('design', design)\nregister('document', document)","import { ILeaferBase } from '@leafer-ui/interface'\n\nimport { addViewport } from './viewport'\n\n\nexport function custom(leafer: ILeaferBase): void {\n addViewport(leafer, null, true)\n}\n","import { ILeaferBase } from '@leafer-ui/interface'\n\nimport { addViewport } from './viewport'\n\n\nexport function design(leafer: ILeaferBase): void {\n addViewport(leafer, {\n zoom: {\n min: 0.01,\n max: 256\n },\n move: {\n holdSpaceKey: true,\n holdMiddleKey: true,\n }\n })\n}\n","import { ILeaferBase } from '@leafer-ui/interface'\n\nimport { addViewport } from './viewport'\n\n\nexport function document(leafer: ILeaferBase): void {\n addViewport(leafer, {\n zoom: { min: 1 },\n move: { scroll: 'limit' }\n })\n}\n","import { IMultiTouchData, IKeepTouchData, IGestureType, IPointData, ISingleGestureConfig } from '@leafer-ui/interface'\n\nimport { PointHelper } from '@leafer-ui/core'\n\n\nexport const MultiTouchHelper = {\n\n state: { // 单一手势识别状态\n type: 'none' as IGestureType,\n typeCount: 0,\n startTime: 0,\n totalData: null as IMultiTouchData,\n center: {} as IPointData\n },\n\n getData(list: IKeepTouchData[]): IMultiTouchData {\n const a = list[0], b = list[1]\n const lastCenter = PointHelper.getCenter(a.from, b.from)\n const center = PointHelper.getCenter(a.to, b.to)\n const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y }\n\n const lastDistance = PointHelper.getDistance(a.from, b.from)\n const distance = PointHelper.getDistance(a.to, b.to)\n const scale = distance / lastDistance\n\n const rotation = PointHelper.getRotation(a.from, b.from, a.to, b.to)\n return { move, scale, rotation, center }\n },\n\n getType(data: IMultiTouchData, config: ISingleGestureConfig): IGestureType {\n const moveScore = Math.hypot(data.move.x, data.move.y) / (config.move || 5)\n const scaleScore = Math.abs(data.scale - 1) / (config.scale || 0.03)\n const rotateScore = Math.abs(data.rotation) / (config.rotation || 2)\n\n if (moveScore < 1 && scaleScore < 1 && rotateScore < 1) return 'none'\n if (moveScore >= scaleScore && moveScore >= rotateScore) return 'move'\n if (scaleScore >= rotateScore) return 'zoom'\n return 'rotate'\n },\n\n // 识别单一手势\n detect(data: IMultiTouchData, config: ISingleGestureConfig): IGestureType {\n const { state } = M\n const type = M.getType(data, config)\n\n if (!state.totalData) {\n state.startTime = Date.now()\n state.center = data.center\n }\n\n M.add(data, state.totalData)\n state.totalData = data\n\n if (type === state.type) { // 连续多帧一样的类型才进行锁定\n state.typeCount++\n if (state.typeCount >= (config.count || 3) && type !== 'none') return type\n } else {\n state.type = type\n state.typeCount = 1\n }\n\n if ((Date.now() - state.startTime) >= (config.time || 160)) return M.getType(state.totalData, config) // 限制最长识别时间\n\n return 'none'\n },\n\n add(data: IMultiTouchData, add: IMultiTouchData): void {\n if (!add) return\n PointHelper.move(data.move, add.move)\n data.scale *= add.scale\n data.rotation += add.rotation\n data.center = add.center\n },\n\n reset() {\n const { state } = M\n state.type = 'none'\n state.typeCount = 0\n state.startTime = 0\n state.totalData = null\n }\n\n}\n\nconst M = MultiTouchHelper","import { IPointData, IWheelEvent, IWheelConfig } from '@leafer-ui/interface'\n\nimport { MathHelper, Platform } from '@leafer-ui/core'\n\n\nconst { abs, max } = Math, { sign, within } = MathHelper\n\nexport const WheelEventHelper = {\n\n getMove(event: IWheelEvent, config: IWheelConfig): IPointData {\n let { moveSpeed } = config\n let { deltaX, deltaY } = event\n if (event.shiftKey && !deltaX) { // Window\n deltaX = deltaY\n deltaY = 0\n }\n const absX = abs(deltaX), absY = abs(deltaY)\n if (absX > 50) deltaX = max(50, absX / 3) * sign(deltaX)\n if (absY > 50) deltaY = max(50, absY / 3) * sign(deltaY)\n return { x: -deltaX * moveSpeed * 2, y: -deltaY * moveSpeed * 2 }\n },\n\n getScale(event: IWheelEvent, config: IWheelConfig): number {\n\n let zoom: boolean\n let scale = 1\n let { zoomMode, zoomSpeed } = config\n\n const delta = event.deltaY || event.deltaX\n\n if (zoomMode) {\n // mac 触摸板滚动手势的deltaY是整数, 鼠标滚动/触摸板缩放的deltaY有小数点, firfox鼠标滚动为整数,为18或19的倍数\n // windows 始终是整数\n zoom = (zoomMode === 'mouse') ? true : (!event.deltaX && (Platform.intWheelDeltaY ? Math.abs(delta) > 17 : Math.ceil(delta) !== delta))\n if (event.shiftKey || event.metaKey || event.ctrlKey) zoom = true\n } else {\n zoom = !event.shiftKey && (event.metaKey || event.ctrlKey)\n }\n\n if (zoom) {\n zoomSpeed = within(zoomSpeed, 0, 1)\n const min = event.deltaY ? config.delta.y : config.delta.x\n const absScale = within(1 - abs(delta) / (min * 4) * zoomSpeed, 0.5, 2)\n scale = delta > 0 ? absScale : 1 / absScale // 让 scale 放大、缩小可以定位在有规律的刻度上\n }\n\n return scale\n }\n\n}","import { IMoveEvent, IZoomEvent, IRotateEvent, ITimer } from '@leafer-ui/interface'\n\nimport { InteractionBase, MoveEvent, ZoomEvent, RotateEvent } from '@leafer-ui/core'\n\n\nlet totalX: number, totalY: number, totalScale: number, totalRotation: number\n\nexport class Transformer {\n\n public get transforming(): boolean { return this.moving || this.zooming || this.rotating }\n public get moving(): boolean { return !!this.moveData }\n public get zooming(): boolean { return !!this.zoomData }\n public get rotating(): boolean { return !!this.rotateData }\n\n public moveData: IMoveEvent\n public zoomData: IZoomEvent\n public rotateData: IRotateEvent\n\n protected interaction: InteractionBase\n protected transformTimer: ITimer\n\n constructor(interaction: InteractionBase) {\n this.interaction = interaction\n }\n\n public move(data: IMoveEvent): void {\n const { interaction } = this\n if (!data.moveType) data.moveType = 'move'\n\n if (!this.moveData) {\n this.setPath(data)\n totalX = 0, totalY = 0\n this.moveData = { ...data, moveX: 0, moveY: 0, totalX, totalY }\n interaction.emit(MoveEvent.START, this.moveData)\n }\n\n data.path = this.moveData.path\n data.totalX = totalX = totalX + data.moveX\n data.totalY = totalY = totalY + data.moveY\n interaction.emit(MoveEvent.BEFORE_MOVE, data)\n interaction.emit(MoveEvent.MOVE, data)\n\n this.transformEndWait()\n }\n\n public zoom(data: IZoomEvent): void {\n const { interaction } = this\n\n if (!this.zoomData) {\n this.setPath(data)\n totalScale = 1\n this.zoomData = { ...data, scale: 1, totalScale }\n interaction.emit(ZoomEvent.START, this.zoomData)\n }\n\n data.path = this.zoomData.path\n data.totalScale = totalScale = totalScale * data.scale\n interaction.emit(ZoomEvent.BEFORE_ZOOM, data)\n interaction.emit(ZoomEvent.ZOOM, data)\n\n this.transformEndWait()\n }\n\n public rotate(data: IRotateEvent): void {\n const { interaction } = this\n\n if (!this.rotateData) {\n this.setPath(data)\n totalRotation = 0\n this.rotateData = { ...data, rotation: 0, totalRotation }\n interaction.emit(RotateEvent.START, this.rotateData)\n }\n\n data.path = this.rotateData.path\n data.totalRotation = totalRotation = totalRotation + data.rotation\n interaction.emit(RotateEvent.BEFORE_ROTATE, data)\n interaction.emit(RotateEvent.ROTATE, data)\n\n this.transformEndWait()\n }\n\n public setPath(data: any): void {\n const { interaction } = this\n const { path } = interaction.selector.getByPoint(data, interaction.hitRadius)\n data.path = path\n interaction.cancelHover()\n }\n\n protected transformEndWait(): void {\n clearTimeout(this.transformTimer)\n this.transformTimer = setTimeout(() => {\n this.transformEnd()\n }, this.interaction.p.transformTime)\n }\n\n public transformEnd(): void {\n const { interaction, moveData, zoomData, rotateData } = this\n if (moveData) interaction.emit(MoveEvent.END, { ...moveData, totalX, totalY } as IMoveEvent)\n if (zoomData) interaction.emit(ZoomEvent.END, { ...zoomData, totalScale } as IZoomEvent)\n if (rotateData) interaction.emit(RotateEvent.END, { ...rotateData, totalRotation } as IRotateEvent)\n this.reset()\n }\n\n public reset(): void {\n this.zoomData = this.moveData = this.rotateData = null\n }\n\n public destroy(): void {\n this.reset()\n }\n}","import { ILeaferType, IPointData } from '@leafer-ui/interface'\n\nimport { Leafer, Bounds, Point, DragBoundsHelper } from '@leafer-ui/core'\n\nimport { LeaferTypeCreator } from './LeaferTypeCreator'\n\n\nconst leafer = Leafer.prototype\nconst bounds = new Bounds(), move = new Point()\n\nleafer.initType = function (type: ILeaferType) {\n LeaferTypeCreator.run(type, this)\n}\n\nleafer.getValidMove = function (moveX: number, moveY: number, checkLimit = true): IPointData {\n const { scroll, disabled } = this.app.config.move\n move.set(moveX, moveY)\n\n if (scroll) {\n const type = scroll === true ? '' : scroll\n\n if (type.includes('x')) move.y = 0\n else if (type.includes('y')) move.x = 0\n else Math.abs(move.x) > Math.abs(move.y) ? move.y = 0 : move.x = 0\n\n if (checkLimit && type.includes('limit')) {\n bounds.set(this.__world).addPoint(this.zoomLayer as IPointData)\n DragBoundsHelper.getValidMove(bounds, this.canvas.bounds, 'inner', move, true)\n if (type.includes('x')) move.y = 0\n else if (type.includes('y')) move.x = 0\n }\n }\n\n return { x: disabled ? 0 : move.x, y: disabled ? 0 : move.y }\n}\n\nleafer.getValidScale = function (changeScale: number): number {\n const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale)\n if (min && absScale < min) changeScale = min / scaleX\n else if (max && absScale > max) changeScale = max / scaleX\n return disabled ? 1 : changeScale // fix 不能过滤小数位\n}","import { IMoveEvent, IZoomEvent, IRotateEvent, IWheelEvent, IKeepTouchData, IPointData, IEvent, IPointerEvent, ISingleGestureConfig } from '@leafer-ui/interface'\n\nimport { InteractionBase, PointHelper, isObject } from '@leafer-ui/core'\n\nimport { WheelEventHelper } from './WheelEventHelper'\nimport { Transformer } from './Transformer'\nimport { MultiTouchHelper } from './MultiTouchHelper'\n\n\nfunction getMoveEventData(move: IPointData, event: IEvent): IMoveEvent {\n return { ...event, moveX: move.x, moveY: move.y } as IMoveEvent\n}\n\nfunction getRotateEventData(rotation: number, event: IEvent): IRotateEvent {\n return { ...event, rotation } as IRotateEvent\n}\n\nfunction getZoomEventData(scale: number, event: IEvent): IZoomEvent {\n return { ...event, scale, } as IZoomEvent\n}\n\n\nconst interaction = InteractionBase.prototype\n\ninteraction.createTransformer = function (): void {\n this.transformer = new Transformer(this)\n}\n\ninteraction.move = function (data: IMoveEvent): void {\n this.transformer.move(data)\n}\n\ninteraction.zoom = function (data: IZoomEvent): void {\n this.transformer.zoom(data)\n}\n\ninteraction.rotate = function (data: IRotateEvent): void {\n this.transformer.rotate(data)\n}\n\ninteraction.transformEnd = function (): void {\n this.transformer.transformEnd()\n}\n\n\ninteraction.wheel = function (data: IWheelEvent): void {\n const { wheel, pointer } = this.config, { posDeltaSpeed, negDeltaSpeed } = wheel\n if (wheel.disabled) return\n\n if (data.deltaX > 0) posDeltaSpeed && (data.deltaX *= posDeltaSpeed)\n else negDeltaSpeed && (data.deltaX *= negDeltaSpeed)\n\n if (data.deltaY > 0) posDeltaSpeed && (data.deltaY *= posDeltaSpeed)\n else negDeltaSpeed && (data.deltaY *= negDeltaSpeed)\n\n const scale = wheel.getScale ? wheel.getScale(data, wheel) : WheelEventHelper.getScale(data, wheel)\n if (scale !== 1) this.zoom(getZoomEventData(scale, data))\n else {\n const move = wheel.getMove ? wheel.getMove(data, wheel) : WheelEventHelper.getMove(data, wheel)\n if (pointer.snap) PointHelper.round(move)\n this.move(getMoveEventData(move, data))\n }\n}\n\n\ninteraction.multiTouch = function (data: IPointerEvent, list: IKeepTouchData[]): void {\n const { disabled, singleGesture } = this.config.multiTouch\n if (disabled) return\n this.pointerWaitCancel()\n\n let gestureData = MultiTouchHelper.getData(list)\n let { moving, zooming, rotating } = this.transformer\n\n if (singleGesture) {\n\n if (!this.transformer.transforming) {\n\n const type = MultiTouchHelper.detect(gestureData, isObject(singleGesture) ? singleGesture : {} as ISingleGestureConfig)\n\n switch (type) {\n case 'move': moving = true; break\n case 'zoom': zooming = true; break\n case 'rotate': rotating = true; break\n default: return\n }\n\n MultiTouchHelper.reset()\n\n }\n\n if (!moving) gestureData.center = MultiTouchHelper.state.center\n\n } else moving = zooming = rotating = true\n\n Object.assign(data, gestureData.center)\n data.multiTouch = true\n\n if (rotating) this.rotate(getRotateEventData(gestureData.rotation, data))\n if (zooming) this.zoom(getZoomEventData(gestureData.scale, data))\n if (moving) this.move(getMoveEventData(gestureData.move, data))\n}","import { IPointerEvent, IFunction } from '@leafer-ui/interface'\n\nimport { Dragger, BoundsHelper, PointHelper, isNumber } from '@leafer-ui/core'\n\n\nconst dragger = Dragger.prototype\nconst { abs } = Math\n\ndragger.checkDragEndAnimate = function (data: IPointerEvent, speed?: number): boolean | number {\n const { moveX, moveY } = this.dragData\n const absMoveX = abs(moveX), absMoveY = abs(moveY), minMove = speed ? 1 : 0.1\n const dragAnimate = this.canAnimate && this.moving && (absMoveX > minMove || absMoveY > minMove) && this.interaction.m.dragAnimate\n\n if (dragAnimate) {\n const inertia = data.pointerType === 'touch' ? 3 : 1, maxMove = 70\n speed = speed ? (isNumber(dragAnimate) ? dragAnimate : 0.95) : inertia\n if (absMoveX * speed > maxMove) speed = maxMove / absMoveX\n else if (absMoveY * speed > maxMove) speed = maxMove / absMoveY\n\n data = { ...data }\n PointHelper.move(data, moveX * speed, moveY * speed)\n\n this.drag(data)\n this.animate(() => { this.dragEnd(data, 1) })\n }\n\n return dragAnimate\n}\n\ndragger.animate = function (func?: IFunction, off?: 'off'): void { // dragEnd animation\n const animateWait = func || this.animateWait\n if (animateWait) this.interaction.target.nextRender(animateWait, null, off)\n this.animateWait = func\n}\n\ndragger.checkDragOut = function (data: IPointerEvent): void {\n const { interaction } = this\n this.autoMoveCancel()\n if (this.dragging && !interaction.shrinkCanvasBounds.hitPoint(data)) this.autoMoveOnDragOut(data)\n}\n\ndragger.autoMoveOnDragOut = function (data: IPointerEvent): void {\n const { interaction, downData, canDragOut } = this\n const { autoDistance, dragOut } = interaction.m\n if (!dragOut || !canDragOut || !autoDistance) return\n\n const bounds = interaction.shrinkCanvasBounds\n const { x, y } = bounds\n const right = BoundsHelper.maxX(bounds)\n const bottom = BoundsHelper.maxY(bounds)\n\n const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0)\n const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0)\n let totalX = 0, totalY = 0\n\n this.autoMoveTimer = setInterval(() => {\n totalX += moveX\n totalY += moveY\n\n PointHelper.move(downData, moveX, moveY)\n PointHelper.move(this.dragData, moveX, moveY)\n\n interaction.move({ ...data, moveX, moveY, totalX, totalY, moveType: 'drag' })\n interaction.pointerMoveReal(data)\n }, 10)\n}\n\ndragger.autoMoveCancel = function (): void {\n if (this.autoMoveTimer) {\n clearInterval(this.autoMoveTimer)\n this.autoMoveTimer = 0\n }\n}","export { LeaferTypeCreator } from './LeaferTypeCreator'\nexport { addViewport, addViewportConfig } from './type/viewport'\nexport { MultiTouchHelper } from './interaction/MultiTouchHelper'\nexport { WheelEventHelper } from './interaction/WheelEventHelper'\nexport { Transformer } from './interaction/Transformer'\n\nimport { Plugin } from '@leafer-ui/core'\n\nimport './Leafer'\nimport './interaction/Interaction'\nimport './interaction/Dragger'\n\nPlugin.add('viewport')"],"names":["addViewport","leafer","mergeConfig","custom","addViewportConfig","parentApp","isApp","__eventIds","push","on_","MoveEvent","BEFORE_MOVE","e","zoomLayer","move","getValidMove","moveX","moveY","END","LeafHelper","animateMove","ZoomEvent","BEFORE_ZOOM","changeScale","getValidScale","scale","scaleOfWorld","viewportConfig","wheel","preventDefault","touch","pointer","preventDefaultMenu","DataHelper","assign","config","userConfig","debug","Debug","get","LeaferTypeCreator","list","register","name","fn","repeat","run","zoom","min","max","holdSpaceKey","holdMiddleKey","scroll","MultiTouchHelper","state","type","typeCount","startTime","totalData","center","getData","a","b","lastCenter","PointHelper","getCenter","from","to","x","y","lastDistance","getDistance","rotation","getRotation","getType","data","moveScore","Math","hypot","scaleScore","abs","rotateScore","detect","M","Date","now","add","count","time","reset","sign","within","MathHelper","WheelEventHelper","getMove","event","moveSpeed","deltaX","deltaY","shiftKey","absX","absY","getScale","zoomMode","zoomSpeed","delta","Platform","intWheelDeltaY","ceil","metaKey","ctrlKey","absScale","totalX","totalY","totalScale","totalRotation","Transformer","transforming","this","moving","zooming","rotating","moveData","zoomData","rotateData","constructor","interaction","moveType","setPath","Object","emit","START","path","MOVE","transformEndWait","ZOOM","rotate","RotateEvent","BEFORE_ROTATE","ROTATE","selector","getByPoint","hitRadius","cancelHover","clearTimeout","transformTimer","setTimeout","transformEnd","p","transformTime","destroy","Leafer","prototype","bounds","Bounds","Point","getMoveEventData","getZoomEventData","initType","checkLimit","disabled","app","set","includes","__world","addPoint","DragBoundsHelper","canvas","scaleX","__","InteractionBase","createTransformer","transformer","posDeltaSpeed","negDeltaSpeed","snap","round","multiTouch","singleGesture","pointerWaitCancel","gestureData","isObject","dragger","Dragger","checkDragEndAnimate","speed","dragData","absMoveX","absMoveY","minMove","dragAnimate","canAnimate","m","inertia","pointerType","maxMove","isNumber","drag","animate","dragEnd","func","off","animateWait","target","nextRender","checkDragOut","autoMoveCancel","dragging","shrinkCanvasBounds","hitPoint","autoMoveOnDragOut","downData","canDragOut","autoDistance","dragOut","right","BoundsHelper","maxX","bottom","maxY","autoMoveTimer","setInterval","pointerMoveReal","clearInterval","Plugin"],"mappings":"oUAKgBA,EAAYC,EAAqBC,EAA6BC,GAC1EC,EAAkBH,EAAOI,UAAYJ,EAAOI,UAAYJ,EAAQC,GAC5DD,EAAOK,OAASH,GAEpBF,EAAOM,WAAWC,KACdP,EAAOQ,IAAIC,EAAUC,YAAcC,IAC/BX,EAAOY,UAAUC,KAAKb,EAAOc,aAAaH,EAAEI,MAAOJ,EAAEK,OAAO,MAEhEhB,EAAOQ,IAAIC,EAAUQ,IAAMN,IACvBO,EAAWC,YAAYnB,EAAOY,UAAWZ,EAAOc,aAAaH,EAAEI,MAAOJ,EAAEK,UAE5EhB,EAAOQ,IAAIY,EAAUC,YAAcV,IAC/B,MAAMC,UAAEA,GAAcZ,EAChBsB,EAActB,EAAOuB,cAAcZ,EAAEa,OACvB,IAAhBF,GAAmBV,EAAUa,aAAad,EAAGW,KAG7D,CAEM,SAAUnB,EAAkBH,EAAqBC,GACnD,MAAMyB,EAAgC,CAClCC,MAAO,CAAEC,gBAAgB,GACzBC,MAAO,CAAED,gBAAgB,GACzBE,QAAS,CAAEC,oBAAoB,IAE/B9B,GAAa+B,EAAWC,OAAOP,EAAgBzB,GACnD+B,EAAWC,OAAOjC,EAAOkC,OAAQR,EAAgB1B,EAAOmC,WAC5D,CCtBA,MAAMC,EAAQC,EAAMC,IAAI,qBAEXC,EAAoB,CAE7BC,KAAM,CAAA,EAEN,QAAAC,CAASC,EAAcC,GACnBH,EAAKE,IAASN,EAAMQ,OAAOF,GAC3BF,EAAKE,GAAQC,CACjB,EAEA,GAAAE,CAAIH,EAAc1C,GACd,MAAM2C,EAAKH,EAAKE,GAChBC,GAAMA,EAAG3C,EACb,IAIEwC,KAAEA,EAAIC,SAAEA,GAAaF,EAE3BE,EAAS,WAAY1C,GACrB0C,EAAS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