@leafer-in/viewport 1.6.2 → 1.6.3
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 +1 -0
- package/dist/viewport.esm.js +1 -0
- package/dist/viewport.esm.min.js +1 -1
- package/dist/viewport.esm.min.js.map +1 -1
- package/dist/viewport.js +1 -0
- package/dist/viewport.min.cjs +1 -1
- package/dist/viewport.min.cjs.map +1 -1
- package/dist/viewport.min.js +1 -1
- package/dist/viewport.min.js.map +1 -1
- package/package.json +4 -4
- package/src/interaction/Interaction.ts +4 -2
package/dist/viewport.cjs
CHANGED
|
@@ -294,6 +294,7 @@ interaction.multiTouch = function (data, list) {
|
|
|
294
294
|
return;
|
|
295
295
|
const { move, rotation, scale, center } = MultiTouchHelper.getData(list);
|
|
296
296
|
Object.assign(data, center);
|
|
297
|
+
data.multiTouch = true;
|
|
297
298
|
this.pointerWaitCancel();
|
|
298
299
|
this.rotate(getRotateEventData(rotation, data));
|
|
299
300
|
this.zoom(getZoomEventData(scale, data));
|
package/dist/viewport.esm.js
CHANGED
|
@@ -292,6 +292,7 @@ interaction.multiTouch = function (data, list) {
|
|
|
292
292
|
return;
|
|
293
293
|
const { move, rotation, scale, center } = MultiTouchHelper.getData(list);
|
|
294
294
|
Object.assign(data, center);
|
|
295
|
+
data.multiTouch = true;
|
|
295
296
|
this.pointerWaitCancel();
|
|
296
297
|
this.rotate(getRotateEventData(rotation, data));
|
|
297
298
|
this.zoom(getZoomEventData(scale, data));
|
package/dist/viewport.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{MoveEvent as t,ZoomEvent as e,DataHelper as o,Debug as a,PointHelper as i,Platform as n,MathHelper as s,RotateEvent as r,Leafer as c,Bounds as m,InteractionBase as h,Dragger as l,BoundsHelper as u,Plugin as d}from"@leafer-ui/core";function f(o,a,i){g(o.parentApp?o.parentApp:o,a),o.isApp||i||o.__eventIds.push(o.on_(t.BEFORE_MOVE,(t=>{o.zoomLayer.move(o.getValidMove(t.moveX,t.moveY))})),o.on_(e.BEFORE_ZOOM,(t=>{const{zoomLayer:e}=o,a=o.getValidScale(t.scale);1!==a&&e.scaleOfWorld(t,a)})))}function g(t,e){const a={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&o.assign(a,e),o.assign(t.config,a,t.userConfig)}const v=a.get("LeaferTypeCreator"),p={list:{},register(t,e){D[t]&&v.repeat(t),D[t]=e},run(t,e){const o=D[t];o&&o(e)}},{list:D,register:O}=p;O("viewport",f),O("custom",(function(t){f(t,null,!0)})),O("design",(function(t){f(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})})),O("document",(function(t){f(t,{zoom:{min:1},move:{scroll:"limit"}})}));const y={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}}},M={getMove(t,e){let{moveSpeed:o}=e,{deltaX:a,deltaY:i}=t;return t.shiftKey&&!a&&(a=i,i=0),a>50&&(a=Math.max(50,a/3)),i>50&&(i=Math.max(50,i/3)),{x:-a*o*2,y:-i*o*2}},getScale(t,e){let o,a=1,{zoomMode:i,zoomSpeed:r}=e;const c=t.deltaY||t.deltaX;if(i?(o="mouse"===i||!t.deltaX&&(n.intWheelDeltaY?Math.abs(c)>17:Math.ceil(c)!==c),(t.shiftKey||t.metaKey||t.ctrlKey)&&(o=!0)):o=!t.shiftKey&&(t.metaKey||t.ctrlKey),o){r=s.within(r,0,1);a=1-c/(4*(t.deltaY?e.delta.y:e.delta.x))*r,a<.5&&(a=.5),a>=1.5&&(a=1.5)}return a}};class
|
|
1
|
+
import{MoveEvent as t,ZoomEvent as e,DataHelper as o,Debug as a,PointHelper as i,Platform as n,MathHelper as s,RotateEvent as r,Leafer as c,Bounds as m,InteractionBase as h,Dragger as l,BoundsHelper as u,Plugin as d}from"@leafer-ui/core";function f(o,a,i){g(o.parentApp?o.parentApp:o,a),o.isApp||i||o.__eventIds.push(o.on_(t.BEFORE_MOVE,(t=>{o.zoomLayer.move(o.getValidMove(t.moveX,t.moveY))})),o.on_(e.BEFORE_ZOOM,(t=>{const{zoomLayer:e}=o,a=o.getValidScale(t.scale);1!==a&&e.scaleOfWorld(t,a)})))}function g(t,e){const a={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&o.assign(a,e),o.assign(t.config,a,t.userConfig)}const v=a.get("LeaferTypeCreator"),p={list:{},register(t,e){D[t]&&v.repeat(t),D[t]=e},run(t,e){const o=D[t];o&&o(e)}},{list:D,register:O}=p;O("viewport",f),O("custom",(function(t){f(t,null,!0)})),O("design",(function(t){f(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})})),O("document",(function(t){f(t,{zoom:{min:1},move:{scroll:"limit"}})}));const y={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}}},M={getMove(t,e){let{moveSpeed:o}=e,{deltaX:a,deltaY:i}=t;return t.shiftKey&&!a&&(a=i,i=0),a>50&&(a=Math.max(50,a/3)),i>50&&(i=Math.max(50,i/3)),{x:-a*o*2,y:-i*o*2}},getScale(t,e){let o,a=1,{zoomMode:i,zoomSpeed:r}=e;const c=t.deltaY||t.deltaX;if(i?(o="mouse"===i||!t.deltaX&&(n.intWheelDeltaY?Math.abs(c)>17:Math.ceil(c)!==c),(t.shiftKey||t.metaKey||t.ctrlKey)&&(o=!0)):o=!t.shiftKey&&(t.metaKey||t.ctrlKey),o){r=s.within(r,0,1);a=1-c/(4*(t.deltaY?e.delta.y:e.delta.x))*r,a<.5&&(a=.5),a>=1.5&&(a=1.5)}return a}};class T{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:o}=this;this.zoomData||(this.setPath(t),this.zoomData=Object.assign(Object.assign({},t),{scale:1}),o.emit(e.START,this.zoomData)),t.path=this.zoomData.path,o.emit(e.BEFORE_ZOOM,t),o.emit(e.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(r.START,this.rotateData)),t.path=this.rotateData.path,e.emit(r.BEFORE_ROTATE,t),e.emit(r.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:o,moveData:a,zoomData:i,rotateData:n}=this;a&&o.emit(t.END,a),i&&o.emit(e.END,i),n&&o.emit(r.END,n),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const E=c.prototype,b=new m;function z(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function x(t,e){return Object.assign(Object.assign({},e),{scale:t})}E.initType=function(t){p.run(t,this)},E.getValidMove=function(t,e){const{scroll:o,disabled:a}=this.app.config.move;if(o){const a=!0===o?"":o;if(a.includes("x")?(t=t||e,e=0):a.includes("y")?(e=e||t,t=0):Math.abs(t)>Math.abs(e)?e=0:t=0,a.includes("limit")){const{x:o,y:a,width:i,height:n}=b.set(this.__world).addPoint(this.zoomLayer),s=o+i-this.width,r=a+n-this.height;o>=0&&s<=0?t=0:t>0?o+t>0&&(t=-o):t<0&&s+t<0&&(t=-s),a>=0&&r<=0?e=0:e>0?a+e>0&&(e=-a):e<0&&r+e<0&&(e=-r)}}return{x:a?0:t,y:a?0:e}},E.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 j=h.prototype;j.createTransformer=function(){this.transformer=new T(this)},j.move=function(t){this.transformer.move(t)},j.zoom=function(t){this.transformer.zoom(t)},j.rotate=function(t){this.transformer.rotate(t)},j.transformEnd=function(){this.transformer.transformEnd()},j.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):M.getScale(t,e);if(1!==s)this.zoom(x(s,t));else{const a=e.getMove?e.getMove(t,e):M.getMove(t,e);o.snap&&i.round(a),this.move(z(a,t))}},j.multiTouch=function(t,e){if(this.config.multiTouch.disabled)return;const{move:o,rotation:a,scale:i,center:n}=y.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(x(i,t)),this.move(z(o,t))};const R=l.prototype,{abs:S}=Math;R.checkDragEndAnimate=function(t,e){const{moveX:o,moveY:a}=this.dragData,n=S(o),s=S(a),r=e?1:.1,c=this.interaction.m.dragAnimate&&this.canAnimate&&this.moving&&(n>r||s>r);if(c){const r="touch"===t.pointerType?3:1,c=70;n*(e=e?.95:r)>c?e=c/n:s*e>c&&(e=c/s),t=Object.assign({},t),i.move(t,o*e,a*e),this.drag(t),this.animate((()=>{this.dragEnd(t,1)}))}return c},R.animate=function(t,e){const o=t||this.animateWait;o&&this.interaction.target.nextRender(o,null,e),this.animateWait=t},R.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},R.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,h=u.maxX(r),l=u.maxY(r),d=t.x<c?n:h<t.x?-n:0,f=t.y<m?n:l<t.y?-n:0;let g=0,v=0;this.autoMoveTimer=setInterval((()=>{g+=d,v+=f,i.move(o,d,f),i.move(this.dragData,d,f),e.move(Object.assign(Object.assign({},t),{moveX:d,moveY:f,totalX:g,totalY:v,moveType:"drag"})),e.pointerMoveReal(t)}),10)},R.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},d.add("viewport");export{p as LeaferTypeCreator,y as MultiTouchHelper,T as Transformer,M as WheelEventHelper,f as addViewport,g 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 } 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))\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\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 if (deltaX > 50) deltaX = Math.max(50, deltaX / 3)\n if (deltaY > 50) deltaY = Math.max(50, deltaY / 3)\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 = MathHelper.within(zoomSpeed, 0, 1)\n const min = event.deltaY ? config.delta.y : config.delta.x\n scale = 1 - delta / (min * 4) * zoomSpeed // zoomSpeed\n if (scale < 0.5) scale = 0.5\n if (scale >= 1.5) scale = 1.5\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 } from '@leafer-ui/core'\n\nimport { LeaferTypeCreator } from './LeaferTypeCreator'\n\n\nconst leafer = Leafer.prototype\nconst bounds = new Bounds()\n\nleafer.initType = function (type: ILeaferType) {\n LeaferTypeCreator.run(type, this)\n}\n\nleafer.getValidMove = function (moveX: number, moveY: number): IPointData {\n const { scroll, disabled } = this.app.config.move\n\n if (scroll) {\n const type = scroll === true ? '' : scroll\n\n if (type.includes('x')) moveX = moveX || moveY, moveY = 0\n else if (type.includes('y')) moveY = moveY || moveX, moveX = 0\n else Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0\n\n if (type.includes('limit')) {\n const { x, y, width, height } = bounds.set(this.__world).addPoint(this.zoomLayer as IPointData)\n const right = x + width - this.width, bottom = y + height - this.height\n\n if (x >= 0 && right <= 0) moveX = 0 // includeX\n else if (moveX > 0) { if (x + moveX > 0) moveX = -x }\n else if (moveX < 0 && right + moveX < 0) moveX = -right\n\n if (y >= 0 && bottom <= 0) moveY = 0 // includeY\n else if (moveY > 0) { if (y + moveY > 0) moveY = -y }\n else if (moveY < 0 && bottom + moveY < 0) moveY = -bottom\n }\n }\n return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY }\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, IUIEvent, IKeepTouchData, IPointData, IEvent } 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: IUIEvent, list: IKeepTouchData[]): void {\n if (this.config.multiTouch.disabled) return\n const { move, rotation, scale, center } = MultiTouchHelper.getData(list)\n Object.assign(data, center)\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 } from '@leafer-ui/core'\n\n\nconst dragger = Dragger.prototype\nconst { abs } = Math\n\ndragger.checkDragEndAnimate = function (data: IPointerEvent, speed?: number): boolean {\n const { moveX, moveY } = this.dragData\n const absMoveX = abs(moveX), absMoveY = abs(moveY), minMove = speed ? 1 : 0.1\n const dragAnimate = this.interaction.m.dragAnimate && this.canAnimate && this.moving && (absMoveX > minMove || absMoveY > minMove)\n\n if (dragAnimate) {\n const inertia = data.pointerType === 'touch' ? 3 : 1, maxMove = 70\n speed = speed ? 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","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","WheelEventHelper","getMove","event","moveSpeed","deltaX","deltaY","shiftKey","Math","getScale","zoomMode","zoomSpeed","delta","Platform","intWheelDeltaY","abs","ceil","metaKey","ctrlKey","MathHelper","within","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","END","reset","destroy","Leafer","prototype","bounds","Bounds","getMoveEventData","getZoomEventData","initType","type","disabled","app","includes","width","height","set","__world","addPoint","right","bottom","scaleX","__","absScale","InteractionBase","createTransformer","transformer","posDeltaSpeed","negDeltaSpeed","snap","round","multiTouch","pointerWaitCancel","getRotateEventData","dragger","Dragger","checkDragEndAnimate","speed","dragData","absMoveX","absMoveY","minMove","dragAnimate","m","canAnimate","moving","inertia","pointerType","maxMove","drag","animate","dragEnd","func","off","animateWait","target","nextRender","checkDragOut","autoMoveCancel","dragging","shrinkCanvasBounds","hitPoint","autoMoveOnDragOut","downData","canDragOut","autoDistance","dragOut","BoundsHelper","maxX","maxY","totalX","totalY","autoMoveTimer","setInterval","pointerMoveReal","clearInterval","Plugin","add"],"mappings":"uPAKgBA,EAAYC,EAAqBC,EAA6BC,GAC1EC,EAAkBH,EAAOI,UAAYJ,EAAOI,UAAYJ,EAAQC,GAC5DD,EAAOK,OAASH,GAEpBF,EAAOM,W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EA,GAAgBL,KACxBA,KAAKwF,iBACDxF,KAAKyF,WAAapF,EAAYqF,mBAAmBC,SAASrF,IAAON,KAAK4F,kBAAkBtF,EAChG,EAEA0D,EAAQ4B,kBAAoB,SAAUtF,GAClC,MAAMD,YAAEA,EAAWwF,SAAEA,EAAQC,WAAEA,GAAe9F,MACxC+F,aAAEA,EAAYC,QAAEA,GAAY3F,EAAYoE,EAC9C,IAAKuB,IAAYF,IAAeC,EAAc,OAE9C,MAAM5D,EAAS9B,EAAYqF,oBACrBtH,EAAEA,EAACC,EAAEA,GAAM8D,EACXc,EAAQgD,EAAaC,KAAK/D,GAC1Be,EAAS+C,EAAaE,KAAKhE,GAE3B3G,EAAQ8E,EAAKlC,EAAIA,EAAI2H,EAAgB9C,EAAQ3C,EAAKlC,GAAK2H,EAAe,EACtEtK,EAAQ6E,EAAKjC,EAAIA,EAAI0H,EAAgB7C,EAAS5C,EAAKjC,GAAK0H,EAAe,EAC7E,IAAIK,EAAS,EAAGC,EAAS,EAEzBrG,KAAKsG,cAAgBC,aAAY,KAC7BH,GAAU5K,EACV6K,GAAU5K,EAEVsC,EAAYzC,KAAKuK,EAAUrK,EAAOC,GAClCsC,EAAYzC,KAAK0E,KAAKoE,SAAU5I,EAAOC,GAEvC4E,EAAY/E,KAAImF,OAAAlE,OAAAkE,OAAAlE,OAAA,GAAM+D,GAAI,CAAE9E,QAAOC,QAAO2K,SAAQC,SAAQ9F,SAAU,UACpEF,EAAYmG,gBAAgBlG,EAAK,GAClC,GACP,EAEA0D,EAAQwB,eAAiB,WACjBxF,KAAKsG,gBACLG,cAAczG,KAAKsG,eACnBtG,KAAKsG,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 } 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))\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\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 if (deltaX > 50) deltaX = Math.max(50, deltaX / 3)\n if (deltaY > 50) deltaY = Math.max(50, deltaY / 3)\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 = MathHelper.within(zoomSpeed, 0, 1)\n const min = event.deltaY ? config.delta.y : config.delta.x\n scale = 1 - delta / (min * 4) * zoomSpeed // zoomSpeed\n if (scale < 0.5) scale = 0.5\n if (scale >= 1.5) scale = 1.5\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 } from '@leafer-ui/core'\n\nimport { LeaferTypeCreator } from './LeaferTypeCreator'\n\n\nconst leafer = Leafer.prototype\nconst bounds = new Bounds()\n\nleafer.initType = function (type: ILeaferType) {\n LeaferTypeCreator.run(type, this)\n}\n\nleafer.getValidMove = function (moveX: number, moveY: number): IPointData {\n const { scroll, disabled } = this.app.config.move\n\n if (scroll) {\n const type = scroll === true ? '' : scroll\n\n if (type.includes('x')) moveX = moveX || moveY, moveY = 0\n else if (type.includes('y')) moveY = moveY || moveX, moveX = 0\n else Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0\n\n if (type.includes('limit')) {\n const { x, y, width, height } = bounds.set(this.__world).addPoint(this.zoomLayer as IPointData)\n const right = x + width - this.width, bottom = y + height - this.height\n\n if (x >= 0 && right <= 0) moveX = 0 // includeX\n else if (moveX > 0) { if (x + moveX > 0) moveX = -x }\n else if (moveX < 0 && right + moveX < 0) moveX = -right\n\n if (y >= 0 && bottom <= 0) moveY = 0 // includeY\n else if (moveY > 0) { if (y + moveY > 0) moveY = -y }\n else if (moveY < 0 && bottom + moveY < 0) moveY = -bottom\n }\n }\n return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY }\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 } from '@leafer-ui/core'\n\n\nconst dragger = Dragger.prototype\nconst { abs } = Math\n\ndragger.checkDragEndAnimate = function (data: IPointerEvent, speed?: number): boolean {\n const { moveX, moveY } = this.dragData\n const absMoveX = abs(moveX), absMoveY = abs(moveY), minMove = speed ? 1 : 0.1\n const dragAnimate = this.interaction.m.dragAnimate && this.canAnimate && this.moving && (absMoveX > minMove || absMoveY > minMove)\n\n if (dragAnimate) {\n const inertia = data.pointerType === 'touch' ? 3 : 1, maxMove = 70\n speed = speed ? 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","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","WheelEventHelper","getMove","event","moveSpeed","deltaX","deltaY","shiftKey","Math","getScale","zoomMode","zoomSpeed","delta","Platform","intWheelDeltaY","abs","ceil","metaKey","ctrlKey","MathHelper","within","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","END","reset","destroy","Leafer","prototype","bounds","Bounds","getMoveEventData","getZoomEventData","initType","type","disabled","app","includes","width","height","set","__world","addPoint","right","bottom","scaleX","__","absScale","InteractionBase","createTransformer","transformer","posDeltaSpeed","negDeltaSpeed","snap","round","multiTouch","pointerWaitCancel","getRotateEventData","dragger","Dragger","checkDragEndAnimate","speed","dragData","absMoveX","absMoveY","minMove","dragAnimate","m","canAnimate","moving","inertia","pointerType","maxMove","drag","animate","dragEnd","func","off","animateWait","target","nextRender","checkDragOut","autoMoveCancel","dragging","shrinkCanvasBounds","hitPoint","autoMoveOnDragOut","downData","canDragOut","autoDistance","dragOut","BoundsHelper","maxX","maxY","totalX","totalY","autoMoveTimer","setInterval","pointerMoveReal","clearInterval","Plugin","add"],"mappings":"uPAKgBA,EAAYC,EAAqBC,EAA6BC,GAC1EC,EAAkBH,EAAOI,UAAYJ,EAAOI,UAAYJ,EAAQC,GAC5DD,EAAOK,OAASH,GAEpBF,EAAOM,WAAWC,KACdP,EAAOQ,IAAIC,EAAUC,aAAcC,IAC/BX,EAAOY,UAAUC,KAAKb,EAAOc,aAAaH,EAAEI,MAAOJ,EAAEK,OAAO,IAEhEhB,EAAOQ,IAAIS,EAAUC,aAAcP,IAC/B,MAAMC,UAAEA,GAAcZ,EAChBmB,EAAcnB,EAAOoB,cAAcT,EAAEU,OACvB,IAAhBF,GAAmBP,EAAUU,aAAaX,EAAGQ,EAAY,IAGzE,CAEgB,SAAAhB,EAAkBH,EAAqBC,GACnD,MAAMsB,EAAgC,CAClCC,MAAO,CAAEC,gBAAgB,GACzBC,MAAO,CAAED,gBAAgB,GACzBE,QAAS,CAAEC,oBAAoB,IAE/B3B,GAAa4B,EAAWC,OAAOP,EAAgBtB,GACnD4B,EAAWC,OAAO9B,EAAO+B,OAAQR,EAAgBvB,EAAOgC,WAC5D,CCnBA,MAAMC,EAAQC,EAAMC,IAAI,qBAEXC,EAAoB,CAE7BC,KAAM,CAAqB,EAE3B,QAAAC,CAASC,EAAcC,GACnBH,EAAKE,IAASN,EAAMQ,OAAOF,GAC3BF,EAAKE,GAAQC,CAChB,EAED,GAAAE,CAAIH,EAAcvC,GACd,MAAMwC,EAAKH,EAAKE,GAChBC,GAAMA,EAAGxC,MAKXqC,KAAEA,EAAIC,SAAEA,GAAaF,EAE3BE,EAAS,WAAYvC,GACrBuC,EAAS,UC1BH,SAAiBtC,GACnBD,EAAYC,EAAQ,MAAM,EAC9B,IDyBAsC,EAAS,UE3BH,SAAiBtC,GACnBD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lG,EAAK,GAClC,GACP,EAEA0D,EAAQwB,eAAiB,WACjBxF,KAAKsG,gBACLG,cAAczG,KAAKsG,eACnBtG,KAAKsG,cAAgB,EAE7B,EC5DAI,EAAOC,IAAI"}
|
package/dist/viewport.js
CHANGED
|
@@ -294,6 +294,7 @@ this.LeaferIN.viewport = (function (exports, core) {
|
|
|
294
294
|
return;
|
|
295
295
|
const { move, rotation, scale, center } = MultiTouchHelper.getData(list);
|
|
296
296
|
Object.assign(data, center);
|
|
297
|
+
data.multiTouch = true;
|
|
297
298
|
this.pointerWaitCancel();
|
|
298
299
|
this.rotate(getRotateEventData(rotation, data));
|
|
299
300
|
this.zoom(getZoomEventData(scale, data));
|
package/dist/viewport.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer-ui/core");function e(e,a,i){o(e.parentApp?e.parentApp:e,a),e.isApp||i||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,(t=>{e.zoomLayer.move(e.getValidMove(t.moveX,t.moveY))})),e.on_(t.ZoomEvent.BEFORE_ZOOM,(t=>{const{zoomLayer:o}=e,a=e.getValidScale(t.scale);1!==a&&o.scaleOfWorld(t,a)})))}function o(e,o){const a={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};o&&t.DataHelper.assign(a,o),t.DataHelper.assign(e.config,a,e.userConfig)}const a=t.Debug.get("LeaferTypeCreator"),i={list:{},register(t,e){n[t]&&a.repeat(t),n[t]=e},run(t,e){const o=n[t];o&&o(e)}},{list:n,register:s}=i;s("viewport",e),s("custom",(function(t){e(t,null,!0)})),s("design",(function(t){e(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})})),s("document",(function(t){e(t,{zoom:{min:1},move:{scroll:"limit"}})}));const r={getData(e){const o=e[0],a=e[1],i=t.PointHelper.getCenter(o.from,a.from),n=t.PointHelper.getCenter(o.to,a.to),s={x:n.x-i.x,y:n.y-i.y},r=t.PointHelper.getDistance(o.from,a.from);return{move:s,scale:t.PointHelper.getDistance(o.to,a.to)/r,rotation:t.PointHelper.getRotation(o.from,a.from,o.to,a.to),center:n}}},c={getMove(t,e){let{moveSpeed:o}=e,{deltaX:a,deltaY:i}=t;return t.shiftKey&&!a&&(a=i,i=0),a>50&&(a=Math.max(50,a/3)),i>50&&(i=Math.max(50,i/3)),{x:-a*o*2,y:-i*o*2}},getScale(e,o){let a,i=1,{zoomMode:n,zoomSpeed:s}=o;const r=e.deltaY||e.deltaX;if(n?(a="mouse"===n||!e.deltaX&&(t.Platform.intWheelDeltaY?Math.abs(r)>17:Math.ceil(r)!==r),(e.shiftKey||e.metaKey||e.ctrlKey)&&(a=!0)):a=!e.shiftKey&&(e.metaKey||e.ctrlKey),a){s=t.MathHelper.within(s,0,1);i=1-r/(4*(e.deltaY?o.delta.y:o.delta.x))*s,i<.5&&(i=.5),i>=1.5&&(i=1.5)}return i}};class m{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.MoveEvent.START,this.moveData)),e.path=this.moveData.path,o.emit(t.MoveEvent.BEFORE_MOVE,e),o.emit(t.MoveEvent.MOVE,e),this.transformEndWait()}zoom(e){const{interaction:o}=this;this.zoomData||(this.setPath(e),this.zoomData=Object.assign(Object.assign({},e),{scale:1}),o.emit(t.ZoomEvent.START,this.zoomData)),e.path=this.zoomData.path,o.emit(t.ZoomEvent.BEFORE_ZOOM,e),o.emit(t.ZoomEvent.ZOOM,e),this.transformEndWait()}rotate(e){const{interaction:o}=this;this.rotateData||(this.setPath(e),this.rotateData=Object.assign(Object.assign({},e),{rotation:0}),o.emit(t.RotateEvent.START,this.rotateData)),e.path=this.rotateData.path,o.emit(t.RotateEvent.BEFORE_ROTATE,e),o.emit(t.RotateEvent.ROTATE,e),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:o,zoomData:a,rotateData:i}=this;o&&e.emit(t.MoveEvent.END,o),a&&e.emit(t.ZoomEvent.END,a),i&&e.emit(t.RotateEvent.END,i),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const h=t.Leafer.prototype,l=new t.Bounds;function u(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function v(t,e){return Object.assign(Object.assign({},e),{scale:t})}h.initType=function(t){i.run(t,this)},h.getValidMove=function(t,e){const{scroll:o,disabled:a}=this.app.config.move;if(o){const a=!0===o?"":o;if(a.includes("x")?(t=t||e,e=0):a.includes("y")?(e=e||t,t=0):Math.abs(t)>Math.abs(e)?e=0:t=0,a.includes("limit")){const{x:o,y:a,width:i,height:n}=l.set(this.__world).addPoint(this.zoomLayer),s=o+i-this.width,r=a+n-this.height;o>=0&&s<=0?t=0:t>0?o+t>0&&(t=-o):t<0&&s+t<0&&(t=-s),a>=0&&r<=0?e=0:e>0?a+e>0&&(e=-a):e<0&&r+e<0&&(e=-r)}}return{x:a?0:t,y:a?0:e}},h.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 d=t.InteractionBase.prototype;d.createTransformer=function(){this.transformer=new m(this)},d.move=function(t){this.transformer.move(t)},d.zoom=function(t){this.transformer.zoom(t)},d.rotate=function(t){this.transformer.rotate(t)},d.transformEnd=function(){this.transformer.transformEnd()},d.wheel=function(e){const{wheel:o,pointer:a}=this.config,{posDeltaSpeed:i,negDeltaSpeed:n}=o;if(o.disabled)return;e.deltaX>0?i&&(e.deltaX*=i):n&&(e.deltaX*=n),e.deltaY>0?i&&(e.deltaY*=i):n&&(e.deltaY*=n);const s=o.getScale?o.getScale(e,o):c.getScale(e,o);if(1!==s)this.zoom(v(s,e));else{const i=o.getMove?o.getMove(e,o):c.getMove(e,o);a.snap&&t.PointHelper.round(i),this.move(u(i,e))}},d.multiTouch=function(t,e){if(this.config.multiTouch.disabled)return;const{move:o,rotation:a,scale:i,center:n}=r.getData(e);Object.assign(t,n),this.pointerWaitCancel(),this.rotate(function(t,e){return Object.assign(Object.assign({},e),{rotation:t})}(a,t)),this.zoom(v(i,t)),this.move(u(o,t))};const p=t.Dragger.prototype,{abs:f}=Math;p.checkDragEndAnimate=function(e,o){const{moveX:a,moveY:i}=this.dragData,n=f(a),s=f(i),r=o?1:.1,c=this.interaction.m.dragAnimate&&this.canAnimate&&this.moving&&(n>r||s>r);if(c){const r="touch"===e.pointerType?3:1,c=70;n*(o=o?.95:r)>c?o=c/n:s*o>c&&(o=c/s),e=Object.assign({},e),t.PointHelper.move(e,a*o,i*o),this.drag(e),this.animate((()=>{this.dragEnd(e,1)}))}return c},p.animate=function(t,e){const o=t||this.animateWait;o&&this.interaction.target.nextRender(o,null,e),this.animateWait=t},p.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},p.autoMoveOnDragOut=function(e){const{interaction:o,downData:a,canDragOut:i}=this,{autoDistance:n,dragOut:s}=o.m;if(!s||!i||!n)return;const r=o.shrinkCanvasBounds,{x:c,y:m}=r,h=t.BoundsHelper.maxX(r),l=t.BoundsHelper.maxY(r),u=e.x<c?n:h<e.x?-n:0,v=e.y<m?n:l<e.y?-n:0;let d=0,p=0;this.autoMoveTimer=setInterval((()=>{d+=u,p+=v,t.PointHelper.move(a,u,v),t.PointHelper.move(this.dragData,u,v),o.move(Object.assign(Object.assign({},e),{moveX:u,moveY:v,totalX:d,totalY:p,moveType:"drag"})),o.pointerMoveReal(e)}),10)},p.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},t.Plugin.add("viewport"),exports.LeaferTypeCreator=i,exports.MultiTouchHelper=r,exports.Transformer=m,exports.WheelEventHelper=c,exports.addViewport=e,exports.addViewportConfig=o;
|
|
1
|
+
"use strict";var t=require("@leafer-ui/core");function e(e,a,i){o(e.parentApp?e.parentApp:e,a),e.isApp||i||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,(t=>{e.zoomLayer.move(e.getValidMove(t.moveX,t.moveY))})),e.on_(t.ZoomEvent.BEFORE_ZOOM,(t=>{const{zoomLayer:o}=e,a=e.getValidScale(t.scale);1!==a&&o.scaleOfWorld(t,a)})))}function o(e,o){const a={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};o&&t.DataHelper.assign(a,o),t.DataHelper.assign(e.config,a,e.userConfig)}const a=t.Debug.get("LeaferTypeCreator"),i={list:{},register(t,e){n[t]&&a.repeat(t),n[t]=e},run(t,e){const o=n[t];o&&o(e)}},{list:n,register:s}=i;s("viewport",e),s("custom",(function(t){e(t,null,!0)})),s("design",(function(t){e(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})})),s("document",(function(t){e(t,{zoom:{min:1},move:{scroll:"limit"}})}));const r={getData(e){const o=e[0],a=e[1],i=t.PointHelper.getCenter(o.from,a.from),n=t.PointHelper.getCenter(o.to,a.to),s={x:n.x-i.x,y:n.y-i.y},r=t.PointHelper.getDistance(o.from,a.from);return{move:s,scale:t.PointHelper.getDistance(o.to,a.to)/r,rotation:t.PointHelper.getRotation(o.from,a.from,o.to,a.to),center:n}}},c={getMove(t,e){let{moveSpeed:o}=e,{deltaX:a,deltaY:i}=t;return t.shiftKey&&!a&&(a=i,i=0),a>50&&(a=Math.max(50,a/3)),i>50&&(i=Math.max(50,i/3)),{x:-a*o*2,y:-i*o*2}},getScale(e,o){let a,i=1,{zoomMode:n,zoomSpeed:s}=o;const r=e.deltaY||e.deltaX;if(n?(a="mouse"===n||!e.deltaX&&(t.Platform.intWheelDeltaY?Math.abs(r)>17:Math.ceil(r)!==r),(e.shiftKey||e.metaKey||e.ctrlKey)&&(a=!0)):a=!e.shiftKey&&(e.metaKey||e.ctrlKey),a){s=t.MathHelper.within(s,0,1);i=1-r/(4*(e.deltaY?o.delta.y:o.delta.x))*s,i<.5&&(i=.5),i>=1.5&&(i=1.5)}return i}};class m{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.MoveEvent.START,this.moveData)),e.path=this.moveData.path,o.emit(t.MoveEvent.BEFORE_MOVE,e),o.emit(t.MoveEvent.MOVE,e),this.transformEndWait()}zoom(e){const{interaction:o}=this;this.zoomData||(this.setPath(e),this.zoomData=Object.assign(Object.assign({},e),{scale:1}),o.emit(t.ZoomEvent.START,this.zoomData)),e.path=this.zoomData.path,o.emit(t.ZoomEvent.BEFORE_ZOOM,e),o.emit(t.ZoomEvent.ZOOM,e),this.transformEndWait()}rotate(e){const{interaction:o}=this;this.rotateData||(this.setPath(e),this.rotateData=Object.assign(Object.assign({},e),{rotation:0}),o.emit(t.RotateEvent.START,this.rotateData)),e.path=this.rotateData.path,o.emit(t.RotateEvent.BEFORE_ROTATE,e),o.emit(t.RotateEvent.ROTATE,e),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:o,zoomData:a,rotateData:i}=this;o&&e.emit(t.MoveEvent.END,o),a&&e.emit(t.ZoomEvent.END,a),i&&e.emit(t.RotateEvent.END,i),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const h=t.Leafer.prototype,l=new t.Bounds;function u(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function v(t,e){return Object.assign(Object.assign({},e),{scale:t})}h.initType=function(t){i.run(t,this)},h.getValidMove=function(t,e){const{scroll:o,disabled:a}=this.app.config.move;if(o){const a=!0===o?"":o;if(a.includes("x")?(t=t||e,e=0):a.includes("y")?(e=e||t,t=0):Math.abs(t)>Math.abs(e)?e=0:t=0,a.includes("limit")){const{x:o,y:a,width:i,height:n}=l.set(this.__world).addPoint(this.zoomLayer),s=o+i-this.width,r=a+n-this.height;o>=0&&s<=0?t=0:t>0?o+t>0&&(t=-o):t<0&&s+t<0&&(t=-s),a>=0&&r<=0?e=0:e>0?a+e>0&&(e=-a):e<0&&r+e<0&&(e=-r)}}return{x:a?0:t,y:a?0:e}},h.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 d=t.InteractionBase.prototype;d.createTransformer=function(){this.transformer=new m(this)},d.move=function(t){this.transformer.move(t)},d.zoom=function(t){this.transformer.zoom(t)},d.rotate=function(t){this.transformer.rotate(t)},d.transformEnd=function(){this.transformer.transformEnd()},d.wheel=function(e){const{wheel:o,pointer:a}=this.config,{posDeltaSpeed:i,negDeltaSpeed:n}=o;if(o.disabled)return;e.deltaX>0?i&&(e.deltaX*=i):n&&(e.deltaX*=n),e.deltaY>0?i&&(e.deltaY*=i):n&&(e.deltaY*=n);const s=o.getScale?o.getScale(e,o):c.getScale(e,o);if(1!==s)this.zoom(v(s,e));else{const i=o.getMove?o.getMove(e,o):c.getMove(e,o);a.snap&&t.PointHelper.round(i),this.move(u(i,e))}},d.multiTouch=function(t,e){if(this.config.multiTouch.disabled)return;const{move:o,rotation:a,scale:i,center:n}=r.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(v(i,t)),this.move(u(o,t))};const p=t.Dragger.prototype,{abs:f}=Math;p.checkDragEndAnimate=function(e,o){const{moveX:a,moveY:i}=this.dragData,n=f(a),s=f(i),r=o?1:.1,c=this.interaction.m.dragAnimate&&this.canAnimate&&this.moving&&(n>r||s>r);if(c){const r="touch"===e.pointerType?3:1,c=70;n*(o=o?.95:r)>c?o=c/n:s*o>c&&(o=c/s),e=Object.assign({},e),t.PointHelper.move(e,a*o,i*o),this.drag(e),this.animate((()=>{this.dragEnd(e,1)}))}return c},p.animate=function(t,e){const o=t||this.animateWait;o&&this.interaction.target.nextRender(o,null,e),this.animateWait=t},p.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},p.autoMoveOnDragOut=function(e){const{interaction:o,downData:a,canDragOut:i}=this,{autoDistance:n,dragOut:s}=o.m;if(!s||!i||!n)return;const r=o.shrinkCanvasBounds,{x:c,y:m}=r,h=t.BoundsHelper.maxX(r),l=t.BoundsHelper.maxY(r),u=e.x<c?n:h<e.x?-n:0,v=e.y<m?n:l<e.y?-n:0;let d=0,p=0;this.autoMoveTimer=setInterval((()=>{d+=u,p+=v,t.PointHelper.move(a,u,v),t.PointHelper.move(this.dragData,u,v),o.move(Object.assign(Object.assign({},e),{moveX:u,moveY:v,totalX:d,totalY:p,moveType:"drag"})),o.pointerMoveReal(e)}),10)},p.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},t.Plugin.add("viewport"),exports.LeaferTypeCreator=i,exports.MultiTouchHelper=r,exports.Transformer=m,exports.WheelEventHelper=c,exports.addViewport=e,exports.addViewportConfig=o;
|
|
2
2
|
//# sourceMappingURL=viewport.min.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport.min.cjs","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 } 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))\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\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 if (deltaX > 50) deltaX = Math.max(50, deltaX / 3)\n if (deltaY > 50) deltaY = Math.max(50, deltaY / 3)\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 = MathHelper.within(zoomSpeed, 0, 1)\n const min = event.deltaY ? config.delta.y : config.delta.x\n scale = 1 - delta / (min * 4) * zoomSpeed // zoomSpeed\n if (scale < 0.5) scale = 0.5\n if (scale >= 1.5) scale = 1.5\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 } from '@leafer-ui/core'\n\nimport { LeaferTypeCreator } from './LeaferTypeCreator'\n\n\nconst leafer = Leafer.prototype\nconst bounds = new Bounds()\n\nleafer.initType = function (type: ILeaferType) {\n LeaferTypeCreator.run(type, this)\n}\n\nleafer.getValidMove = function (moveX: number, moveY: number): IPointData {\n const { scroll, disabled } = this.app.config.move\n\n if (scroll) {\n const type = scroll === true ? '' : scroll\n\n if (type.includes('x')) moveX = moveX || moveY, moveY = 0\n else if (type.includes('y')) moveY = moveY || moveX, moveX = 0\n else Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0\n\n if (type.includes('limit')) {\n const { x, y, width, height } = bounds.set(this.__world).addPoint(this.zoomLayer as IPointData)\n const right = x + width - this.width, bottom = y + height - this.height\n\n if (x >= 0 && right <= 0) moveX = 0 // includeX\n else if (moveX > 0) { if (x + moveX > 0) moveX = -x }\n else if (moveX < 0 && right + moveX < 0) moveX = -right\n\n if (y >= 0 && bottom <= 0) moveY = 0 // includeY\n else if (moveY > 0) { if (y + moveY > 0) moveY = -y }\n else if (moveY < 0 && bottom + moveY < 0) moveY = -bottom\n }\n }\n return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY }\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, IUIEvent, IKeepTouchData, IPointData, IEvent } 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: IUIEvent, list: IKeepTouchData[]): void {\n if (this.config.multiTouch.disabled) return\n const { move, rotation, scale, center } = MultiTouchHelper.getData(list)\n Object.assign(data, center)\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 } from '@leafer-ui/core'\n\n\nconst dragger = Dragger.prototype\nconst { abs } = Math\n\ndragger.checkDragEndAnimate = function (data: IPointerEvent, speed?: number): boolean {\n const { moveX, moveY } = this.dragData\n const absMoveX = abs(moveX), absMoveY = abs(moveY), minMove = speed ? 1 : 0.1\n const dragAnimate = this.interaction.m.dragAnimate && this.canAnimate && this.moving && (absMoveX > minMove || absMoveY > minMove)\n\n if (dragAnimate) {\n const inertia = data.pointerType === 'touch' ? 3 : 1, maxMove = 70\n speed = speed ? 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","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","WheelEventHelper","getMove","event","moveSpeed","deltaX","deltaY","shiftKey","Math","getScale","zoomMode","zoomSpeed","delta","Platform","intWheelDeltaY","abs","ceil","metaKey","ctrlKey","MathHelper","within","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","END","reset","destroy","Leafer","prototype","bounds","Bounds","getMoveEventData","getZoomEventData","initType","type","disabled","app","includes","width","height","set","__world","addPoint","right","bottom","scaleX","__","absScale","InteractionBase","createTransformer","transformer","posDeltaSpeed","negDeltaSpeed","snap","round","multiTouch","pointerWaitCancel","getRotateEventData","dragger","Dragger","checkDragEndAnimate","speed","dragData","absMoveX","absMoveY","minMove","dragAnimate","m","canAnimate","moving","inertia","pointerType","maxMove","drag","animate","dragEnd","func","off","animateWait","target","nextRender","checkDragOut","autoMoveCancel","dragging","shrinkCanvasBounds","hitPoint","autoMoveOnDragOut","downData","canDragOut","autoDistance","dragOut","BoundsHelper","maxX","maxY","totalX","totalY","autoMoveTimer","setInterval","pointerMoveReal","clearInterval","Plugin","add"],"mappings":"uDAKgBA,EAAYC,EAAqBC,EAA6BC,GAC1EC,EAAkBH,EAAOI,UAAYJ,EAAOI,UAAYJ,EAAQC,GAC5DD,EAAOK,OAASH,GAEpBF,EAAOM,WAAWC,KACdP,EAAOQ,IAAIC,YAAUC,aAAcC,IAC/BX,EAAOY,UAAUC,KAAKb,EAAOc,aAAaH,EAAEI,MAAOJ,EAAEK,OAAO,IAEhEhB,EAAOQ,IAAIS,EAASA,UAACC,aAAcP,IAC/B,MAAMC,UAAEA,GAAcZ,EAChBmB,EAAcnB,EAAOoB,cAAcT,EAAEU,OACvB,IAAhBF,GAAmBP,EAAUU,aAAaX,EAAGQ,EAAY,IAGzE,CAEgB,SAAAhB,EAAkBH,EAAqBC,GACnD,MAAMsB,EAAgC,CAClCC,MAAO,CAAEC,gBAAgB,GACzBC,MAAO,CAAED,gBAAgB,GACzBE,QAAS,CAAEC,oBAAoB,IAE/B3B,GAAa4B,aAAWC,OAAOP,EAAgBtB,GACnD4B,EAAUA,WAACC,OAAO9B,EAAO+B,OAAQR,EAAgBvB,EAAOgC,WAC5D,CCnBA,MAAMC,EAAQC,EAAAA,MAAMC,IAAI,qBAEXC,EAAoB,CAE7BC,KAAM,CAAqB,EAE3B,QAAAC,CAASC,EAAcC,GACnBH,EAAKE,IAASN,EAAMQ,OAAOF,GAC3BF,EAAKE,GAAQC,CAChB,EAED,GAAAE,CAAIH,EAAcvC,GACd,MAAMwC,EAAKH,EAAKE,GAChBC,GAAMA,EAAGxC,MA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Y,KAC7BH,GAAU5K,EACV6K,GAAU5K,EAEVsC,EAAAA,YAAYzC,KAAKuK,EAAUrK,EAAOC,GAClCsC,EAAAA,YAAYzC,KAAK0E,KAAKoE,SAAU5I,EAAOC,GAEvC4E,EAAY/E,KAAImF,OAAAlE,OAAAkE,OAAAlE,OAAA,GAAM+D,GAAI,CAAE9E,QAAOC,QAAO2K,SAAQC,SAAQ9F,SAAU,UACpEF,EAAYmG,gBAAgBlG,EAAK,GAClC,GACP,EAEA0D,EAAQwB,eAAiB,WACjBxF,KAAKsG,gBACLG,cAAczG,KAAKsG,eACnBtG,KAAKsG,cAAgB,EAE7B,EC5DAI,EAAAA,OAAOC,IAAI"}
|
|
1
|
+
{"version":3,"file":"viewport.min.cjs","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 } 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))\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\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 if (deltaX > 50) deltaX = Math.max(50, deltaX / 3)\n if (deltaY > 50) deltaY = Math.max(50, deltaY / 3)\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 = MathHelper.within(zoomSpeed, 0, 1)\n const min = event.deltaY ? config.delta.y : config.delta.x\n scale = 1 - delta / (min * 4) * zoomSpeed // zoomSpeed\n if (scale < 0.5) scale = 0.5\n if (scale >= 1.5) scale = 1.5\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 } from '@leafer-ui/core'\n\nimport { LeaferTypeCreator } from './LeaferTypeCreator'\n\n\nconst leafer = Leafer.prototype\nconst bounds = new Bounds()\n\nleafer.initType = function (type: ILeaferType) {\n LeaferTypeCreator.run(type, this)\n}\n\nleafer.getValidMove = function (moveX: number, moveY: number): IPointData {\n const { scroll, disabled } = this.app.config.move\n\n if (scroll) {\n const type = scroll === true ? '' : scroll\n\n if (type.includes('x')) moveX = moveX || moveY, moveY = 0\n else if (type.includes('y')) moveY = moveY || moveX, moveX = 0\n else Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0\n\n if (type.includes('limit')) {\n const { x, y, width, height } = bounds.set(this.__world).addPoint(this.zoomLayer as IPointData)\n const right = x + width - this.width, bottom = y + height - this.height\n\n if (x >= 0 && right <= 0) moveX = 0 // includeX\n else if (moveX > 0) { if (x + moveX > 0) moveX = -x }\n else if (moveX < 0 && right + moveX < 0) moveX = -right\n\n if (y >= 0 && bottom <= 0) moveY = 0 // includeY\n else if (moveY > 0) { if (y + moveY > 0) moveY = -y }\n else if (moveY < 0 && bottom + moveY < 0) moveY = -bottom\n }\n }\n return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY }\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 } from '@leafer-ui/core'\n\n\nconst dragger = Dragger.prototype\nconst { abs } = Math\n\ndragger.checkDragEndAnimate = function (data: IPointerEvent, speed?: number): boolean {\n const { moveX, moveY } = this.dragData\n const absMoveX = abs(moveX), absMoveY = abs(moveY), minMove = speed ? 1 : 0.1\n const dragAnimate = this.interaction.m.dragAnimate && this.canAnimate && this.moving && (absMoveX > minMove || absMoveY > minMove)\n\n if (dragAnimate) {\n const inertia = data.pointerType === 'touch' ? 3 : 1, maxMove = 70\n speed = speed ? 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","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","WheelEventHelper","getMove","event","moveSpeed","deltaX","deltaY","shiftKey","Math","getScale","zoomMode","zoomSpeed","delta","Platform","intWheelDeltaY","abs","ceil","metaKey","ctrlKey","MathHelper","within","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","END","reset","destroy","Leafer","prototype","bounds","Bounds","getMoveEventData","getZoomEventData","initType","type","disabled","app","includes","width","height","set","__world","addPoint","right","bottom","scaleX","__","absScale","InteractionBase","createTransformer","transformer","posDeltaSpeed","negDeltaSpeed","snap","round","multiTouch","pointerWaitCancel","getRotateEventData","dragger","Dragger","checkDragEndAnimate","speed","dragData","absMoveX","absMoveY","minMove","dragAnimate","m","canAnimate","moving","inertia","pointerType","maxMove","drag","animate","dragEnd","func","off","animateWait","target","nextRender","checkDragOut","autoMoveCancel","dragging","shrinkCanvasBounds","hitPoint","autoMoveOnDragOut","downData","canDragOut","autoDistance","dragOut","BoundsHelper","maxX","maxY","totalX","totalY","autoMoveTimer","setInterval","pointerMoveReal","clearInterval","Plugin","add"],"mappings":"uDAKgBA,EAAYC,EAAqBC,EAA6BC,GAC1EC,EAAkBH,EAAOI,UAAYJ,EAAOI,UAAYJ,EAAQC,GAC5DD,EAAOK,OAASH,GAEpBF,EAAOM,WAAWC,KACdP,EAAOQ,IAAIC,YAAUC,aAAcC,IAC/BX,EAAOY,UAAUC,KAAKb,EAAOc,aAAaH,EAAEI,MAAOJ,EAAEK,OAAO,IAEhEhB,EAAOQ,IAAIS,EAASA,UAACC,aAAcP,IAC/B,MAAMC,UAAEA,GAAcZ,EAChBmB,EAAcnB,EAAOoB,cAAcT,EAAEU,OACvB,IAAhBF,GAAmBP,EAAUU,aAAaX,EAAGQ,EAAY,IAGzE,CAEgB,SAAAhB,EAAkBH,EAAqBC,GACnD,MAAMsB,E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WAAEA,GAAe9F,MACxC+F,aAAEA,EAAYC,QAAEA,GAAY3F,EAAYoE,EAC9C,IAAKuB,IAAYF,IAAeC,EAAc,OAE9C,MAAM5D,EAAS9B,EAAYqF,oBACrBtH,EAAEA,EAACC,EAAEA,GAAM8D,EACXc,EAAQgD,EAAAA,aAAaC,KAAK/D,GAC1Be,EAAS+C,EAAAA,aAAaE,KAAKhE,GAE3B3G,EAAQ8E,EAAKlC,EAAIA,EAAI2H,EAAgB9C,EAAQ3C,EAAKlC,GAAK2H,EAAe,EACtEtK,EAAQ6E,EAAKjC,EAAIA,EAAI0H,EAAgB7C,EAAS5C,EAAKjC,GAAK0H,EAAe,EAC7E,IAAIK,EAAS,EAAGC,EAAS,EAEzBrG,KAAKsG,cAAgBC,aAAY,KAC7BH,GAAU5K,EACV6K,GAAU5K,EAEVsC,EAAAA,YAAYzC,KAAKuK,EAAUrK,EAAOC,GAClCsC,EAAAA,YAAYzC,KAAK0E,KAAKoE,SAAU5I,EAAOC,GAEvC4E,EAAY/E,KAAImF,OAAAlE,OAAAkE,OAAAlE,OAAA,GAAM+D,GAAI,CAAE9E,QAAOC,QAAO2K,SAAQC,SAAQ9F,SAAU,UACpEF,EAAYmG,gBAAgBlG,EAAK,GAClC,GACP,EAEA0D,EAAQwB,eAAiB,WACjBxF,KAAKsG,gBACLG,cAAczG,KAAKsG,eACnBtG,KAAKsG,cAAgB,EAE7B,EC5DAI,EAAAA,OAAOC,IAAI"}
|
package/dist/viewport.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.viewport=function(t,e){"use strict";function o(t,o,i){a(t.parentApp?t.parentApp:t,o),t.isApp||i||t.__eventIds.push(t.on_(e.MoveEvent.BEFORE_MOVE,(e=>{t.zoomLayer.move(t.getValidMove(e.moveX,e.moveY))})),t.on_(e.ZoomEvent.BEFORE_ZOOM,(e=>{const{zoomLayer:o}=t,a=t.getValidScale(e.scale);1!==a&&o.scaleOfWorld(e,a)})))}function a(t,o){const a={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};o&&e.DataHelper.assign(a,o),e.DataHelper.assign(t.config,a,t.userConfig)}const i=e.Debug.get("LeaferTypeCreator"),n={list:{},register(t,e){s[t]&&i.repeat(t),s[t]=e},run(t,e){const o=s[t];o&&o(e)}},{list:s,register:r}=n;r("viewport",o),r("custom",(function(t){o(t,null,!0)})),r("design",(function(t){o(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})})),r("document",(function(t){o(t,{zoom:{min:1},move:{scroll:"limit"}})}));const c={getData(t){const o=t[0],a=t[1],i=e.PointHelper.getCenter(o.from,a.from),n=e.PointHelper.getCenter(o.to,a.to),s={x:n.x-i.x,y:n.y-i.y},r=e.PointHelper.getDistance(o.from,a.from);return{move:s,scale:e.PointHelper.getDistance(o.to,a.to)/r,rotation:e.PointHelper.getRotation(o.from,a.from,o.to,a.to),center:n}}},m={getMove(t,e){let{moveSpeed:o}=e,{deltaX:a,deltaY:i}=t;return t.shiftKey&&!a&&(a=i,i=0),a>50&&(a=Math.max(50,a/3)),i>50&&(i=Math.max(50,i/3)),{x:-a*o*2,y:-i*o*2}},getScale(t,o){let a,i=1,{zoomMode:n,zoomSpeed:s}=o;const r=t.deltaY||t.deltaX;if(n?(a="mouse"===n||!t.deltaX&&(e.Platform.intWheelDeltaY?Math.abs(r)>17:Math.ceil(r)!==r),(t.shiftKey||t.metaKey||t.ctrlKey)&&(a=!0)):a=!t.shiftKey&&(t.metaKey||t.ctrlKey),a){s=e.MathHelper.within(s,0,1);i=1-r/(4*(t.deltaY?o.delta.y:o.delta.x))*s,i<.5&&(i=.5),i>=1.5&&(i=1.5)}return i}};class h{get transforming(){return!!(this.moveData||this.zoomData||this.rotateData)}constructor(t){this.interaction=t}move(t){const{interaction:o}=this;t.moveType||(t.moveType="move"),this.moveData||(this.setPath(t),this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0}),o.emit(e.MoveEvent.START,this.moveData)),t.path=this.moveData.path,o.emit(e.MoveEvent.BEFORE_MOVE,t),o.emit(e.MoveEvent.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:o}=this;this.zoomData||(this.setPath(t),this.zoomData=Object.assign(Object.assign({},t),{scale:1}),o.emit(e.ZoomEvent.START,this.zoomData)),t.path=this.zoomData.path,o.emit(e.ZoomEvent.BEFORE_ZOOM,t),o.emit(e.ZoomEvent.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:o}=this;this.rotateData||(this.setPath(t),this.rotateData=Object.assign(Object.assign({},t),{rotation:0}),o.emit(e.RotateEvent.START,this.rotateData)),t.path=this.rotateData.path,o.emit(e.RotateEvent.BEFORE_ROTATE,t),o.emit(e.RotateEvent.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:t,moveData:o,zoomData:a,rotateData:i}=this;o&&t.emit(e.MoveEvent.END,o),a&&t.emit(e.ZoomEvent.END,a),i&&t.emit(e.RotateEvent.END,i),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const l=e.Leafer.prototype,u=new e.Bounds;function v(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function d(t,e){return Object.assign(Object.assign({},e),{scale:t})}l.initType=function(t){n.run(t,this)},l.getValidMove=function(t,e){const{scroll:o,disabled:a}=this.app.config.move;if(o){const a=!0===o?"":o;if(a.includes("x")?(t=t||e,e=0):a.includes("y")?(e=e||t,t=0):Math.abs(t)>Math.abs(e)?e=0:t=0,a.includes("limit")){const{x:o,y:a,width:i,height:n}=u.set(this.__world).addPoint(this.zoomLayer),s=o+i-this.width,r=a+n-this.height;o>=0&&s<=0?t=0:t>0?o+t>0&&(t=-o):t<0&&s+t<0&&(t=-s),a>=0&&r<=0?e=0:e>0?a+e>0&&(e=-a):e<0&&r+e<0&&(e=-r)}}return{x:a?0:t,y:a?0:e}},l.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 f=e.InteractionBase.prototype;f.createTransformer=function(){this.transformer=new h(this)},f.move=function(t){this.transformer.move(t)},f.zoom=function(t){this.transformer.zoom(t)},f.rotate=function(t){this.transformer.rotate(t)},f.transformEnd=function(){this.transformer.transformEnd()},f.wheel=function(t){const{wheel:o,pointer:a}=this.config,{posDeltaSpeed:i,negDeltaSpeed:n}=o;if(o.disabled)return;t.deltaX>0?i&&(t.deltaX*=i):n&&(t.deltaX*=n),t.deltaY>0?i&&(t.deltaY*=i):n&&(t.deltaY*=n);const s=o.getScale?o.getScale(t,o):m.getScale(t,o);if(1!==s)this.zoom(d(s,t));else{const i=o.getMove?o.getMove(t,o):m.getMove(t,o);a.snap&&e.PointHelper.round(i),this.move(v(i,t))}},f.multiTouch=function(t,e){if(this.config.multiTouch.disabled)return;const{move:o,rotation:a,scale:i,center:n}=c.getData(e);Object.assign(t,n),this.pointerWaitCancel(),this.rotate(function(t,e){return Object.assign(Object.assign({},e),{rotation:t})}(a,t)),this.zoom(d(i,t)),this.move(v(o,t))};const g=e.Dragger.prototype,{abs:p}=Math;return g.checkDragEndAnimate=function(t,o){const{moveX:a,moveY:i}=this.dragData,n=p(a),s=p(i),r=o?1:.1,c=this.interaction.m.dragAnimate&&this.canAnimate&&this.moving&&(n>r||s>r);if(c){const r="touch"===t.pointerType?3:1,c=70;n*(o=o?.95:r)>c?o=c/n:s*o>c&&(o=c/s),t=Object.assign({},t),e.PointHelper.move(t,a*o,i*o),this.drag(t),this.animate((()=>{this.dragEnd(t,1)}))}return c},g.animate=function(t,e){const o=t||this.animateWait;o&&this.interaction.target.nextRender(o,null,e),this.animateWait=t},g.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},g.autoMoveOnDragOut=function(t){const{interaction:o,downData:a,canDragOut:i}=this,{autoDistance:n,dragOut:s}=o.m;if(!s||!i||!n)return;const r=o.shrinkCanvasBounds,{x:c,y:m}=r,h=e.BoundsHelper.maxX(r),l=e.BoundsHelper.maxY(r),u=t.x<c?n:h<t.x?-n:0,v=t.y<m?n:l<t.y?-n:0;let d=0,f=0;this.autoMoveTimer=setInterval((()=>{d+=u,f+=v,e.PointHelper.move(a,u,v),e.PointHelper.move(this.dragData,u,v),o.move(Object.assign(Object.assign({},t),{moveX:u,moveY:v,totalX:d,totalY:f,moveType:"drag"})),o.pointerMoveReal(t)}),10)},g.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},e.Plugin.add("viewport"),t.LeaferTypeCreator=n,t.MultiTouchHelper=c,t.Transformer=h,t.WheelEventHelper=m,t.addViewport=o,t.addViewportConfig=a,t}({},LeaferUI);
|
|
1
|
+
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.viewport=function(t,e){"use strict";function o(t,o,i){a(t.parentApp?t.parentApp:t,o),t.isApp||i||t.__eventIds.push(t.on_(e.MoveEvent.BEFORE_MOVE,(e=>{t.zoomLayer.move(t.getValidMove(e.moveX,e.moveY))})),t.on_(e.ZoomEvent.BEFORE_ZOOM,(e=>{const{zoomLayer:o}=t,a=t.getValidScale(e.scale);1!==a&&o.scaleOfWorld(e,a)})))}function a(t,o){const a={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};o&&e.DataHelper.assign(a,o),e.DataHelper.assign(t.config,a,t.userConfig)}const i=e.Debug.get("LeaferTypeCreator"),n={list:{},register(t,e){s[t]&&i.repeat(t),s[t]=e},run(t,e){const o=s[t];o&&o(e)}},{list:s,register:r}=n;r("viewport",o),r("custom",(function(t){o(t,null,!0)})),r("design",(function(t){o(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})})),r("document",(function(t){o(t,{zoom:{min:1},move:{scroll:"limit"}})}));const c={getData(t){const o=t[0],a=t[1],i=e.PointHelper.getCenter(o.from,a.from),n=e.PointHelper.getCenter(o.to,a.to),s={x:n.x-i.x,y:n.y-i.y},r=e.PointHelper.getDistance(o.from,a.from);return{move:s,scale:e.PointHelper.getDistance(o.to,a.to)/r,rotation:e.PointHelper.getRotation(o.from,a.from,o.to,a.to),center:n}}},m={getMove(t,e){let{moveSpeed:o}=e,{deltaX:a,deltaY:i}=t;return t.shiftKey&&!a&&(a=i,i=0),a>50&&(a=Math.max(50,a/3)),i>50&&(i=Math.max(50,i/3)),{x:-a*o*2,y:-i*o*2}},getScale(t,o){let a,i=1,{zoomMode:n,zoomSpeed:s}=o;const r=t.deltaY||t.deltaX;if(n?(a="mouse"===n||!t.deltaX&&(e.Platform.intWheelDeltaY?Math.abs(r)>17:Math.ceil(r)!==r),(t.shiftKey||t.metaKey||t.ctrlKey)&&(a=!0)):a=!t.shiftKey&&(t.metaKey||t.ctrlKey),a){s=e.MathHelper.within(s,0,1);i=1-r/(4*(t.deltaY?o.delta.y:o.delta.x))*s,i<.5&&(i=.5),i>=1.5&&(i=1.5)}return i}};class h{get transforming(){return!!(this.moveData||this.zoomData||this.rotateData)}constructor(t){this.interaction=t}move(t){const{interaction:o}=this;t.moveType||(t.moveType="move"),this.moveData||(this.setPath(t),this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0}),o.emit(e.MoveEvent.START,this.moveData)),t.path=this.moveData.path,o.emit(e.MoveEvent.BEFORE_MOVE,t),o.emit(e.MoveEvent.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:o}=this;this.zoomData||(this.setPath(t),this.zoomData=Object.assign(Object.assign({},t),{scale:1}),o.emit(e.ZoomEvent.START,this.zoomData)),t.path=this.zoomData.path,o.emit(e.ZoomEvent.BEFORE_ZOOM,t),o.emit(e.ZoomEvent.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:o}=this;this.rotateData||(this.setPath(t),this.rotateData=Object.assign(Object.assign({},t),{rotation:0}),o.emit(e.RotateEvent.START,this.rotateData)),t.path=this.rotateData.path,o.emit(e.RotateEvent.BEFORE_ROTATE,t),o.emit(e.RotateEvent.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:t,moveData:o,zoomData:a,rotateData:i}=this;o&&t.emit(e.MoveEvent.END,o),a&&t.emit(e.ZoomEvent.END,a),i&&t.emit(e.RotateEvent.END,i),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const l=e.Leafer.prototype,u=new e.Bounds;function v(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function d(t,e){return Object.assign(Object.assign({},e),{scale:t})}l.initType=function(t){n.run(t,this)},l.getValidMove=function(t,e){const{scroll:o,disabled:a}=this.app.config.move;if(o){const a=!0===o?"":o;if(a.includes("x")?(t=t||e,e=0):a.includes("y")?(e=e||t,t=0):Math.abs(t)>Math.abs(e)?e=0:t=0,a.includes("limit")){const{x:o,y:a,width:i,height:n}=u.set(this.__world).addPoint(this.zoomLayer),s=o+i-this.width,r=a+n-this.height;o>=0&&s<=0?t=0:t>0?o+t>0&&(t=-o):t<0&&s+t<0&&(t=-s),a>=0&&r<=0?e=0:e>0?a+e>0&&(e=-a):e<0&&r+e<0&&(e=-r)}}return{x:a?0:t,y:a?0:e}},l.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 f=e.InteractionBase.prototype;f.createTransformer=function(){this.transformer=new h(this)},f.move=function(t){this.transformer.move(t)},f.zoom=function(t){this.transformer.zoom(t)},f.rotate=function(t){this.transformer.rotate(t)},f.transformEnd=function(){this.transformer.transformEnd()},f.wheel=function(t){const{wheel:o,pointer:a}=this.config,{posDeltaSpeed:i,negDeltaSpeed:n}=o;if(o.disabled)return;t.deltaX>0?i&&(t.deltaX*=i):n&&(t.deltaX*=n),t.deltaY>0?i&&(t.deltaY*=i):n&&(t.deltaY*=n);const s=o.getScale?o.getScale(t,o):m.getScale(t,o);if(1!==s)this.zoom(d(s,t));else{const i=o.getMove?o.getMove(t,o):m.getMove(t,o);a.snap&&e.PointHelper.round(i),this.move(v(i,t))}},f.multiTouch=function(t,e){if(this.config.multiTouch.disabled)return;const{move:o,rotation:a,scale:i,center:n}=c.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(d(i,t)),this.move(v(o,t))};const g=e.Dragger.prototype,{abs:p}=Math;return g.checkDragEndAnimate=function(t,o){const{moveX:a,moveY:i}=this.dragData,n=p(a),s=p(i),r=o?1:.1,c=this.interaction.m.dragAnimate&&this.canAnimate&&this.moving&&(n>r||s>r);if(c){const r="touch"===t.pointerType?3:1,c=70;n*(o=o?.95:r)>c?o=c/n:s*o>c&&(o=c/s),t=Object.assign({},t),e.PointHelper.move(t,a*o,i*o),this.drag(t),this.animate((()=>{this.dragEnd(t,1)}))}return c},g.animate=function(t,e){const o=t||this.animateWait;o&&this.interaction.target.nextRender(o,null,e),this.animateWait=t},g.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},g.autoMoveOnDragOut=function(t){const{interaction:o,downData:a,canDragOut:i}=this,{autoDistance:n,dragOut:s}=o.m;if(!s||!i||!n)return;const r=o.shrinkCanvasBounds,{x:c,y:m}=r,h=e.BoundsHelper.maxX(r),l=e.BoundsHelper.maxY(r),u=t.x<c?n:h<t.x?-n:0,v=t.y<m?n:l<t.y?-n:0;let d=0,f=0;this.autoMoveTimer=setInterval((()=>{d+=u,f+=v,e.PointHelper.move(a,u,v),e.PointHelper.move(this.dragData,u,v),o.move(Object.assign(Object.assign({},t),{moveX:u,moveY:v,totalX:d,totalY:f,moveType:"drag"})),o.pointerMoveReal(t)}),10)},g.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},e.Plugin.add("viewport"),t.LeaferTypeCreator=n,t.MultiTouchHelper=c,t.Transformer=h,t.WheelEventHelper=m,t.addViewport=o,t.addViewportConfig=a,t}({},LeaferUI);
|
|
2
2
|
//# sourceMappingURL=viewport.min.js.map
|
package/dist/viewport.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport.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 } 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))\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\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 if (deltaX > 50) deltaX = Math.max(50, deltaX / 3)\n if (deltaY > 50) deltaY = Math.max(50, deltaY / 3)\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 = MathHelper.within(zoomSpeed, 0, 1)\n const min = event.deltaY ? config.delta.y : config.delta.x\n scale = 1 - delta / (min * 4) * zoomSpeed // zoomSpeed\n if (scale < 0.5) scale = 0.5\n if (scale >= 1.5) scale = 1.5\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 } from '@leafer-ui/core'\n\nimport { LeaferTypeCreator } from './LeaferTypeCreator'\n\n\nconst leafer = Leafer.prototype\nconst bounds = new Bounds()\n\nleafer.initType = function (type: ILeaferType) {\n LeaferTypeCreator.run(type, this)\n}\n\nleafer.getValidMove = function (moveX: number, moveY: number): IPointData {\n const { scroll, disabled } = this.app.config.move\n\n if (scroll) {\n const type = scroll === true ? '' : scroll\n\n if (type.includes('x')) moveX = moveX || moveY, moveY = 0\n else if (type.includes('y')) moveY = moveY || moveX, moveX = 0\n else Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0\n\n if (type.includes('limit')) {\n const { x, y, width, height } = bounds.set(this.__world).addPoint(this.zoomLayer as IPointData)\n const right = x + width - this.width, bottom = y + height - this.height\n\n if (x >= 0 && right <= 0) moveX = 0 // includeX\n else if (moveX > 0) { if (x + moveX > 0) moveX = -x }\n else if (moveX < 0 && right + moveX < 0) moveX = -right\n\n if (y >= 0 && bottom <= 0) moveY = 0 // includeY\n else if (moveY > 0) { if (y + moveY > 0) moveY = -y }\n else if (moveY < 0 && bottom + moveY < 0) moveY = -bottom\n }\n }\n return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY }\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, IUIEvent, IKeepTouchData, IPointData, IEvent } 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: IUIEvent, list: IKeepTouchData[]): void {\n if (this.config.multiTouch.disabled) return\n const { move, rotation, scale, center } = MultiTouchHelper.getData(list)\n Object.assign(data, center)\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 } from '@leafer-ui/core'\n\n\nconst dragger = Dragger.prototype\nconst { abs } = Math\n\ndragger.checkDragEndAnimate = function (data: IPointerEvent, speed?: number): boolean {\n const { moveX, moveY } = this.dragData\n const absMoveX = abs(moveX), absMoveY = abs(moveY), minMove = speed ? 1 : 0.1\n const dragAnimate = this.interaction.m.dragAnimate && this.canAnimate && this.moving && (absMoveX > minMove || absMoveY > minMove)\n\n if (dragAnimate) {\n const inertia = data.pointerType === 'touch' ? 3 : 1, maxMove = 70\n speed = speed ? 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","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","WheelEventHelper","getMove","event","moveSpeed","deltaX","deltaY","shiftKey","Math","getScale","zoomMode","zoomSpeed","delta","Platform","intWheelDeltaY","abs","ceil","metaKey","ctrlKey","MathHelper","within","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","END","reset","destroy","Leafer","prototype","bounds","Bounds","getMoveEventData","getZoomEventData","initType","type","disabled","app","includes","width","height","set","__world","addPoint","right","bottom","scaleX","__","absScale","InteractionBase","createTransformer","transformer","posDeltaSpeed","negDeltaSpeed","snap","round","multiTouch","pointerWaitCancel","getRotateEventData","dragger","Dragger","checkDragEndAnimate","speed","dragData","absMoveX","absMoveY","minMove","dragAnimate","m","canAnimate","moving","inertia","pointerType","maxMove","drag","animate","dragEnd","func","off","animateWait","target","nextRender","checkDragOut","autoMoveCancel","dragging","shrinkCanvasBounds","hitPoint","autoMoveOnDragOut","downData","canDragOut","autoDistance","dragOut","BoundsHelper","maxX","maxY","totalX","totalY","autoMoveTimer","setInterval","pointerMoveReal","clearInterval","Plugin","add"],"mappings":"2FAKgBA,EAAYC,EAAqBC,EAA6BC,GAC1EC,EAAkBH,EAAOI,UAAYJ,EAAOI,UAAYJ,EAAQC,GAC5DD,EAAOK,OAASH,GAEpBF,EAAOM,WAAWC,KACdP,EAAOQ,IAAIC,YAAUC,aAAcC,IAC/BX,EAAOY,UAAUC,KAAKb,EAAOc,aAAaH,EAAEI,MAAOJ,EAAEK,OAAO,IAEhEhB,EAAOQ,IAAIS,EAASA,UAACC,aAAcP,IAC/B,MAAMC,UAAEA,GAAcZ,EAChBmB,EAAcnB,EAAOoB,cAAcT,EAAE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tF,EAChG,EAEA0D,EAAQ4B,kBAAoB,SAAUtF,GAClC,MAAMD,YAAEA,EAAWwF,SAAEA,EAAQC,WAAEA,GAAe9F,MACxC+F,aAAEA,EAAYC,QAAEA,GAAY3F,EAAYoE,EAC9C,IAAKuB,IAAYF,IAAeC,EAAc,OAE9C,MAAM5D,EAAS9B,EAAYqF,oBACrBtH,EAAEA,EAACC,EAAEA,GAAM8D,EACXc,EAAQgD,EAAAA,aAAaC,KAAK/D,GAC1Be,EAAS+C,EAAAA,aAAaE,KAAKhE,GAE3B3G,EAAQ8E,EAAKlC,EAAIA,EAAI2H,EAAgB9C,EAAQ3C,EAAKlC,GAAK2H,EAAe,EACtEtK,EAAQ6E,EAAKjC,EAAIA,EAAI0H,EAAgB7C,EAAS5C,EAAKjC,GAAK0H,EAAe,EAC7E,IAAIK,EAAS,EAAGC,EAAS,EAEzBrG,KAAKsG,cAAgBC,aAAY,KAC7BH,GAAU5K,EACV6K,GAAU5K,EAEVsC,EAAAA,YAAYzC,KAAKuK,EAAUrK,EAAOC,GAClCsC,EAAAA,YAAYzC,KAAK0E,KAAKoE,SAAU5I,EAAOC,GAEvC4E,EAAY/E,KAAImF,OAAAlE,OAAAkE,OAAAlE,OAAA,GAAM+D,GAAI,CAAE9E,QAAOC,QAAO2K,SAAQC,SAAQ9F,SAAU,UACpEF,EAAYmG,gBAAgBlG,EAAK,GAClC,GACP,EAEA0D,EAAQwB,eAAiB,WACjBxF,KAAKsG,gBACLG,cAAczG,KAAKsG,eACnBtG,KAAKsG,cAAgB,EAE7B,EC5DAI,EAAAA,OAAOC,IAAI"}
|
|
1
|
+
{"version":3,"file":"viewport.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 } 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))\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\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 if (deltaX > 50) deltaX = Math.max(50, deltaX / 3)\n if (deltaY > 50) deltaY = Math.max(50, deltaY / 3)\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 = MathHelper.within(zoomSpeed, 0, 1)\n const min = event.deltaY ? config.delta.y : config.delta.x\n scale = 1 - delta / (min * 4) * zoomSpeed // zoomSpeed\n if (scale < 0.5) scale = 0.5\n if (scale >= 1.5) scale = 1.5\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 } from '@leafer-ui/core'\n\nimport { LeaferTypeCreator } from './LeaferTypeCreator'\n\n\nconst leafer = Leafer.prototype\nconst bounds = new Bounds()\n\nleafer.initType = function (type: ILeaferType) {\n LeaferTypeCreator.run(type, this)\n}\n\nleafer.getValidMove = function (moveX: number, moveY: number): IPointData {\n const { scroll, disabled } = this.app.config.move\n\n if (scroll) {\n const type = scroll === true ? '' : scroll\n\n if (type.includes('x')) moveX = moveX || moveY, moveY = 0\n else if (type.includes('y')) moveY = moveY || moveX, moveX = 0\n else Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0\n\n if (type.includes('limit')) {\n const { x, y, width, height } = bounds.set(this.__world).addPoint(this.zoomLayer as IPointData)\n const right = x + width - this.width, bottom = y + height - this.height\n\n if (x >= 0 && right <= 0) moveX = 0 // includeX\n else if (moveX > 0) { if (x + moveX > 0) moveX = -x }\n else if (moveX < 0 && right + moveX < 0) moveX = -right\n\n if (y >= 0 && bottom <= 0) moveY = 0 // includeY\n else if (moveY > 0) { if (y + moveY > 0) moveY = -y }\n else if (moveY < 0 && bottom + moveY < 0) moveY = -bottom\n }\n }\n return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY }\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 } from '@leafer-ui/core'\n\n\nconst dragger = Dragger.prototype\nconst { abs } = Math\n\ndragger.checkDragEndAnimate = function (data: IPointerEvent, speed?: number): boolean {\n const { moveX, moveY } = this.dragData\n const absMoveX = abs(moveX), absMoveY = abs(moveY), minMove = speed ? 1 : 0.1\n const dragAnimate = this.interaction.m.dragAnimate && this.canAnimate && this.moving && (absMoveX > minMove || absMoveY > minMove)\n\n if (dragAnimate) {\n const inertia = data.pointerType === 'touch' ? 3 : 1, maxMove = 70\n speed = speed ? 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","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","WheelEventHelper","getMove","event","moveSpeed","deltaX","deltaY","shiftKey","Math","getScale","zoomMode","zoomSpeed","delta","Platform","intWheelDeltaY","abs","ceil","metaKey","ctrlKey","MathHelper","within","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","END","reset","destroy","Leafer","prototype","bounds","Bounds","getMoveEventData","getZoomEventData","initType","type","disabled","app","includes","width","height","set","__world","addPoint","right","bottom","scaleX","__","absScale","InteractionBase","createTransformer","transformer","posDeltaSpeed","negDeltaSpeed","snap","round","multiTouch","pointerWaitCancel","getRotateEventData","dragger","Dragger","checkDragEndAnimate","speed","dragData","absMoveX","absMoveY","minMove","dragAnimate","m","canAnimate","moving","inertia","pointerType","maxMove","drag","animate","dragEnd","func","off","animateWait","target","nextRender","checkDragOut","autoMoveCancel","dragging","shrinkCanvasBounds","hitPoint","autoMoveOnDragOut","downData","canDragOut","autoDistance","dragOut","BoundsHelper","maxX","maxY","totalX","totalY","autoMoveTimer","setInterval","pointerMoveReal","clearInterval","Plugin","add"],"mappings":"2FAKgBA,EAAYC,EAAqBC,EAA6BC,GAC1EC,EAAkBH,EAAOI,UAAYJ,EAAOI,UAAYJ,EAAQC,GAC5DD,EAAOK,OAASH,GAEpBF,EAAOM,WAAWC,KACdP,EAAOQ,IAAIC,YAAUC,aAAcC,IAC/BX,EAAOY,UAAUC,KAAKb,EAAOc,aAAaH,EAAEI,MAAOJ,EAAEK,OAAO,IAEhEhB,EAAOQ,IAAIS,EAASA,UAACC,aAAcP,IAC/B,MAAMC,UAAEA,GAAcZ,EAChBmB,EAAcnB,EAAOoB,cAAcT,EAAEU,OACvB,IAAhBF,GAAmBP,EAAUU,aAAaX,EAAGQ,EAAY,IAGzE,CAEgB,SAAAhB,EAAkBH,EAAqBC,GACnD,MAAMsB,EAAgC,CAClCC,MAAO,CAAEC,gBAAgB,GACzBC,MAAO,CAAED,gBAAgB,GACzBE,QAAS,CAAEC,oBAAoB,IAE/B3B,GAAa4B,aAAWC,OAAOP,EAAgBtB,GACnD4B,EAAUA,WAACC,OAAO9B,EAAO+B,OAAQR,EAAgBvB,EAAOgC,WAC5D,CCnBA,MAAMC,EAAQC,EAAAA,MAAMC,IAAI,qBAEXC,EAAoB,CAE7BC,KAAM,CAAqB,EAE3B,QAAAC,CAASC,EAAcC,GACnBH,EAAKE,IAASN,EAAMQ,OAAOF,GAC3BF,EAAKE,GAAQC,CAChB,EAED,GAAAE,CAAIH,EAAcvC,GACd,MAAMwC,EAAKH,EAAKE,GAChBC,GAAMA,EAAGxC,MAKXqC,KAAEA,EAAIC,SAAEA,GAAaF,EAE3BE,EAAS,WAAYvC,GACrBuC,EAAS,UC1BH,SAAiBtC,GACnBD,EAAYC,EAAQ,MAAM,EAC9B,IDyBAsC,EAAS,UE3BH,SAAiBtC,GACnBD,EAAYC,EAAQ,CAChB2C,KAAM,CACFC,IAAK,IACLC,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,OAAA,GAAM+D,GAAI,CAAE9E,QAAOC,QAAO2K,SAAQC,SAAQ9F,SAAU,UACpEF,EAAYmG,gBAAgBlG,EAAK,GAClC,GACP,EAEA0D,EAAQwB,eAAiB,WACjBxF,KAAKsG,gBACLG,cAAczG,KAAKsG,eACnBtG,KAAKsG,cAAgB,EAE7B,EC5DAI,EAAAA,OAAOC,IAAI"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/viewport",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "@leafer-in/viewport",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"leaferjs"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@leafer-ui/core": "^1.6.
|
|
38
|
-
"@leafer-ui/interface": "^1.6.
|
|
39
|
-
"@leafer-in/interface": "^1.6.
|
|
37
|
+
"@leafer-ui/core": "^1.6.3",
|
|
38
|
+
"@leafer-ui/interface": "^1.6.3",
|
|
39
|
+
"@leafer-in/interface": "^1.6.3"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMoveEvent, IZoomEvent, IRotateEvent, IWheelEvent,
|
|
1
|
+
import { IMoveEvent, IZoomEvent, IRotateEvent, IWheelEvent, IKeepTouchData, IPointData, IEvent, IPointerEvent } from '@leafer-ui/interface'
|
|
2
2
|
|
|
3
3
|
import { InteractionBase, PointHelper } from '@leafer-ui/core'
|
|
4
4
|
|
|
@@ -63,10 +63,12 @@ interaction.wheel = function (data: IWheelEvent): void {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
interaction.multiTouch = function (data:
|
|
66
|
+
interaction.multiTouch = function (data: IPointerEvent, list: IKeepTouchData[]): void {
|
|
67
67
|
if (this.config.multiTouch.disabled) return
|
|
68
68
|
const { move, rotation, scale, center } = MultiTouchHelper.getData(list)
|
|
69
|
+
|
|
69
70
|
Object.assign(data, center)
|
|
71
|
+
data.multiTouch = true
|
|
70
72
|
|
|
71
73
|
this.pointerWaitCancel()
|
|
72
74
|
|