@leafer-in/view 1.6.1 → 1.6.2

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/view.cjs CHANGED
@@ -98,4 +98,3 @@ draw.Leafer.prototype.zoom = function (zoomType, padding, fixed, transition) {
98
98
  }
99
99
  return zoomLayer.worldBoxBounds;
100
100
  };
101
- //# sourceMappingURL=view.cjs.map
package/dist/view.esm.js CHANGED
@@ -96,4 +96,3 @@ Leafer.prototype.zoom = function (zoomType, padding, fixed, transition) {
96
96
  }
97
97
  return zoomLayer.worldBoxBounds;
98
98
  };
99
- //# sourceMappingURL=view.esm.js.map
package/dist/view.js CHANGED
@@ -99,4 +99,3 @@
99
99
  };
100
100
 
101
101
  })(LeaferUI);
102
- //# sourceMappingURL=view.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/view",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "@leafer-in/view",
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/draw": "^1.6.1",
38
- "@leafer-ui/interface": "^1.6.1",
39
- "@leafer-in/interface": "^1.6.1"
37
+ "@leafer-ui/draw": "^1.6.2",
38
+ "@leafer-ui/interface": "^1.6.2",
39
+ "@leafer-in/interface": "^1.6.2"
40
40
  }
41
41
  }
package/dist/view.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"view.cjs","sources":["../../../../../../src/in/packages/view/src/helper.ts","../../../../../../src/in/packages/view/src/index.ts"],"sourcesContent":["import { IBoundsData } from '@leafer-ui/interface'\n\n\nexport function getZoomScale(scaleX: number, type: 'in' | 'out'): number {\n let scale = 1\n const out = type === 'out', absScale = Math.abs(scaleX)\n if (absScale > 1) {\n while (out ? scale < absScale : scale <= absScale) scale *= 2\n if (out) scale /= 2\n } else {\n while (out ? scale >= absScale : scale > absScale) scale /= 2\n if (!out) scale *= 2\n }\n return scale / scaleX\n}\n\nexport function getFixBounds(bounds: IBoundsData, scaleBounds: IBoundsData): IBoundsData {\n let { x, y, width, height } = bounds\n let fix: boolean\n if (!height) height = width * (scaleBounds.height / scaleBounds.width), fix = true\n if (!width) width = height * (scaleBounds.width / scaleBounds.height), fix = true\n return fix ? { x, y, width, height } : bounds\n}","import { ILeaf, IBoundsData, IZoomType, IFourNumber, IPointData, ITransition } from '@leafer-ui/interface'\nimport { Leafer, Bounds, LeafBoundsHelper, Plugin, PointHelper } from '@leafer-ui/draw'\n\nimport { getFixBounds, getZoomScale } from './helper'\n\n\nPlugin.add('view')\n\n\nLeafer.prototype.zoom = function (zoomType: IZoomType, padding?: IFourNumber, fixed?: boolean, transition?: ITransition): IBoundsData {\n\n this.killAnimate()\n\n const { zoomLayer } = this\n const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds()\n const center: IPointData = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 }\n\n let changeScale: number\n const { x, y, scaleX, scaleY } = zoomLayer.__\n\n if (typeof zoomType === 'string') {\n\n switch (zoomType) {\n case 'in':\n changeScale = getZoomScale(scaleX, 'in')\n break\n case 'out':\n changeScale = getZoomScale(scaleX, 'out')\n break\n case 'fit':\n zoomType = this.boxBounds\n break\n case 'fit-width':\n zoomType = new Bounds(this.boxBounds)\n zoomType.height = 0\n break\n case 'fit-height':\n zoomType = new Bounds(this.boxBounds)\n zoomType.width = 0\n break\n }\n\n } else if (typeof zoomType === 'number') {\n changeScale = zoomType / scaleX\n }\n\n\n if (changeScale) {\n\n changeScale = this.getValidScale(changeScale)\n zoomLayer.scaleOfWorld(center, changeScale, changeScale, false, transition)\n\n } else if (typeof zoomType === 'object') {\n\n const data = { x, y, scaleX, scaleY }\n const isArray = zoomType instanceof Array\n\n if (isArray || (zoomType as ILeaf).tag) {\n const list: ILeaf[] = isArray ? zoomType as ILeaf[] : [zoomType as ILeaf]\n bounds.setListWithFn(list, LeafBoundsHelper.worldBounds)\n } else {\n const innerBounds = getFixBounds(zoomType as IBoundsData, limitBounds)\n bounds.set(zoomLayer.getWorldBounds(innerBounds))\n }\n\n const { width, height } = bounds\n let moveX = limitBounds.x - bounds.x, moveY = limitBounds.y - bounds.y\n\n if (fixed) {\n\n moveX += Math.max((limitBounds.width - width) / 2, 0)\n moveY += Math.max((limitBounds.height - height) / 2, 0)\n\n } else {\n\n changeScale = this.getValidScale(Math.min(limitBounds.width / width, limitBounds.height / height))\n moveX += (limitBounds.width - width * changeScale) / 2\n moveY += (limitBounds.height - height * changeScale) / 2\n\n PointHelper.scaleOf(data, bounds, changeScale)\n bounds.scaleOf(bounds, changeScale)\n\n data.scaleX *= changeScale\n data.scaleY *= changeScale\n }\n\n PointHelper.move(data, moveX, moveY)\n bounds.move(moveX, moveY)\n\n zoomLayer.set(data, transition)\n\n return bounds\n\n }\n\n return zoomLayer.worldBoxBounds\n\n}"],"names":["Plugin","Leafer","Bounds","LeafBoundsHelper","PointHelper"],"mappings":";;;;AAGgB,SAAA,YAAY,CAAC,MAAc,EAAE,IAAkB,EAAA;IAC3D,IAAI,KAAK,GAAG,CAAC;AACb,IAAA,MAAM,GAAG,GAAG,IAAI,KAAK,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;AACvD,IAAA,IAAI,QAAQ,GAAG,CAAC,EAAE;AACd,QAAA,OAAO,GAAG,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,IAAI,QAAQ;YAAE,KAAK,IAAI,CAAC;AAC7D,QAAA,IAAI,GAAG;YAAE,KAAK,IAAI,CAAC;;SAChB;AACH,QAAA,OAAO,GAAG,GAAG,KAAK,IAAI,QAAQ,GAAG,KAAK,GAAG,QAAQ;YAAE,KAAK,IAAI,CAAC;AAC7D,QAAA,IAAI,CAAC,GAAG;YAAE,KAAK,IAAI,CA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IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC;AACpC,QAAA,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC;AAEzB,QAAA,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC;AAE/B,QAAA,OAAO,MAAM;;IAIjB,OAAO,SAAS,CAAC,cAAc;AAEnC,CAAC;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"view.esm.js","sources":["../../../../../../src/in/packages/view/src/helper.ts","../../../../../../src/in/packages/view/src/index.ts"],"sourcesContent":["import { IBoundsData } from '@leafer-ui/interface'\n\n\nexport function getZoomScale(scaleX: number, type: 'in' | 'out'): number {\n let scale = 1\n const out = type === 'out', absScale = Math.abs(scaleX)\n if (absScale > 1) {\n while (out ? scale < absScale : scale <= absScale) scale *= 2\n if (out) scale /= 2\n } else {\n while (out ? scale >= absScale : scale > absScale) scale /= 2\n if (!out) scale *= 2\n }\n return scale / scaleX\n}\n\nexport function getFixBounds(bounds: IBoundsData, scaleBounds: IBoundsData): IBoundsData {\n let { x, y, width, height } = bounds\n let fix: boolean\n if (!height) height = width * (scaleBounds.height / scaleBounds.width), fix = true\n if (!width) width = height * (scaleBounds.width / scaleBounds.height), fix = true\n return fix ? { x, y, width, height } : bounds\n}","import { ILeaf, IBoundsData, IZoomType, IFourNumber, IPointData, ITransition } from '@leafer-ui/interface'\nimport { Leafer, Bounds, LeafBoundsHelper, Plugin, PointHelper } from '@leafer-ui/draw'\n\nimport { getFixBounds, getZoomScale } from './helper'\n\n\nPlugin.add('view')\n\n\nLeafer.prototype.zoom = function (zoomType: IZoomType, padding?: IFourNumber, fixed?: boolean, transition?: ITransition): IBoundsData {\n\n this.killAnimate()\n\n const { zoomLayer } = this\n const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds()\n const center: IPointData = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 }\n\n let changeScale: number\n const { x, y, scaleX, scaleY } = zoomLayer.__\n\n if (typeof zoomType === 'string') {\n\n switch (zoomType) {\n case 'in':\n changeScale = getZoomScale(scaleX, 'in')\n break\n case 'out':\n changeScale = getZoomScale(scaleX, 'out')\n break\n case 'fit':\n zoomType = this.boxBounds\n break\n case 'fit-width':\n zoomType = new Bounds(this.boxBounds)\n zoomType.height = 0\n break\n case 'fit-height':\n zoomType = new Bounds(this.boxBounds)\n zoomType.width = 0\n break\n }\n\n } else if (typeof zoomType === 'number') {\n changeScale = zoomType / scaleX\n }\n\n\n if (changeScale) {\n\n changeScale = this.getValidScale(changeScale)\n zoomLayer.scaleOfWorld(center, changeScale, changeScale, false, transition)\n\n } else if (typeof zoomType === 'object') {\n\n const data = { x, y, scaleX, scaleY }\n const isArray = zoomType instanceof Array\n\n if (isArray || (zoomType as ILeaf).tag) {\n const list: ILeaf[] = isArray ? zoomType as ILeaf[] : [zoomType as ILeaf]\n bounds.setListWithFn(list, LeafBoundsHelper.worldBounds)\n } else {\n const innerBounds = getFixBounds(zoomType as IBoundsData, limitBounds)\n bounds.set(zoomLayer.getWorldBounds(innerBounds))\n }\n\n const { width, height } = bounds\n let moveX = limitBounds.x - bounds.x, moveY = limitBounds.y - bounds.y\n\n if (fixed) {\n\n moveX += Math.max((limitBounds.width - width) / 2, 0)\n moveY += Math.max((limitBounds.height - height) / 2, 0)\n\n } else {\n\n changeScale = this.getValidScale(Math.min(limitBounds.width / width, limitBounds.height / height))\n moveX += (limitBounds.width - width * changeScale) / 2\n moveY += (limitBounds.height - height * changeScale) / 2\n\n PointHelper.scaleOf(data, bounds, changeScale)\n bounds.scaleOf(bounds, changeScale)\n\n data.scaleX *= changeScale\n data.scaleY *= changeScale\n }\n\n PointHelper.move(data, moveX, moveY)\n bounds.move(moveX, moveY)\n\n zoomLayer.set(data, transition)\n\n return bounds\n\n }\n\n return zoomLayer.worldBoxBounds\n\n}"],"names":[],"mappings":";;AAGgB,SAAA,YAAY,CAAC,MAAc,EAAE,IA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AW,CAAC,KAAK,GAAG,KAAK,EAAE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AAClG,YAAA,KAAK,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG,KAAK,GAAG,WAAW,IAAI,CAAC;AACtD,YAAA,KAAK,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,MAAM,GAAG,WAAW,IAAI,CAAC;YAExD,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC;AAC9C,YAAA,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC;AAEnC,YAAA,IAAI,CAAC,MAAM,IAAI,WAAW;AAC1B,YAAA,IAAI,CAAC,MAAM,IAAI,WAAW;;QAG9B,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC;AACpC,QAAA,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC;AAEzB,QAAA,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC;AAE/B,QAAA,OAAO,MAAM;;IAIjB,OAAO,SAAS,CAAC,cAAc;AAEnC,CAAC"}
package/dist/view.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"view.js","sources":["../../../../../../src/in/packages/view/src/helper.ts","../../../../../../src/in/packages/view/src/index.ts"],"sourcesContent":["import { IBoundsData } from '@leafer-ui/interface'\n\n\nexport function getZoomScale(scaleX: number, type: 'in' | 'out'): number {\n let scale = 1\n const out = type === 'out', absScale = Math.abs(scaleX)\n if (absScale > 1) {\n while (out ? scale < absScale : scale <= absScale) scale *= 2\n if (out) scale /= 2\n } else {\n while (out ? scale >= absScale : scale > absScale) scale /= 2\n if (!out) scale *= 2\n }\n return scale / scaleX\n}\n\nexport function getFixBounds(bounds: IBoundsData, scaleBounds: IBoundsData): IBoundsData {\n let { x, y, width, height } = bounds\n let fix: boolean\n if (!height) height = width * (scaleBounds.height / scaleBounds.width), fix = true\n if (!width) width = height * (scaleBounds.width / scaleBounds.height), fix = true\n return fix ? { x, y, width, height } : bounds\n}","import { ILeaf, IBoundsData, IZoomType, IFourNumber, IPointData, ITransition } from '@leafer-ui/interface'\nimport { Leafer, Bounds, LeafBoundsHelper, Plugin, PointHelper } from '@leafer-ui/draw'\n\nimport { getFixBounds, getZoomScale } from './helper'\n\n\nPlugin.add('view')\n\n\nLeafer.prototype.zoom = function (zoomType: IZoomType, padding?: IFourNumber, fixed?: boolean, transition?: ITransition): IBoundsData {\n\n this.killAnimate()\n\n const { zoomLayer } = this\n const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds()\n const center: IPointData = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 }\n\n let changeScale: number\n const { x, y, scaleX, scaleY } = zoomLayer.__\n\n if (typeof zoomType === 'string') {\n\n switch (zoomType) {\n case 'in':\n changeScale = getZoomScale(scaleX, 'in')\n break\n case 'out':\n changeScale = getZoomScale(scaleX, 'out')\n break\n case 'fit':\n zoomType = this.boxBounds\n break\n case 'fit-width':\n zoomType = new Bounds(this.boxBounds)\n zoomType.height = 0\n break\n case 'fit-height':\n zoomType = new Bounds(this.boxBounds)\n zoomType.width = 0\n break\n }\n\n } else if (typeof zoomType === 'number') {\n changeScale = zoomType / scaleX\n }\n\n\n if (changeScale) {\n\n changeScale = this.getValidScale(changeScale)\n zoomLayer.scaleOfWorld(center, changeScale, changeScale, false, transition)\n\n } else if (typeof zoomType === 'object') {\n\n const data = { x, y, scaleX, scaleY }\n const isArray = zoomType instanceof Array\n\n if (isArray || (zoomType as ILeaf).tag) {\n const list: ILeaf[] = isArray ? zoomType as ILeaf[] : [zoomType as ILeaf]\n bounds.setListWithFn(list, LeafBoundsHelper.worldBounds)\n } else {\n const innerBounds = getFixBounds(zoomType as IBoundsData, limitBounds)\n bounds.set(zoomLayer.getWorldBounds(innerBounds))\n }\n\n const { width, height } = bounds\n let moveX = limitBounds.x - bounds.x, moveY = limitBounds.y - bounds.y\n\n if (fixed) {\n\n moveX += Math.max((limitBounds.width - width) / 2, 0)\n moveY += Math.max((limitBounds.height - height) / 2, 0)\n\n } else {\n\n changeScale = this.getValidScale(Math.min(limitBounds.width / width, limitBounds.height / height))\n moveX += (limitBounds.width - width * changeScale) / 2\n moveY += (limitBounds.height - height * changeScale) / 2\n\n PointHelper.scaleOf(data, bounds, changeScale)\n bounds.scaleOf(bounds, changeScale)\n\n data.scaleX *= changeScale\n data.scaleY *= changeScale\n }\n\n PointHelper.move(data, moveX, moveY)\n bounds.move(moveX, moveY)\n\n zoomLayer.set(data, transition)\n\n return bounds\n\n }\n\n return zoomLayer.worldBoxBounds\n\n}"],"names":["Plugin","Leafer","Bounds","LeafBoundsHelper","PointHelper"],"mappings":";;;IAGgB,SAAA,YAAY,CAAC,MAAc,EAAE,IAAkB,EAAA;QAC3D,IAAI,KAAK,GAAG,CAAC;IACb,IAAA,MAAM,GAAG,GAAG,IAAI,KAAK,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACvD,IAAA,IAAI,QAAQ,GAAG,CAAC,EAAE;IACd,QAAA,OAAO,GAAG,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,IAAI,QAAQ;gBAAE,KAAK,IAAI,CAAC;IAC7D,QAAA,IAAI,GAAG;gBAAE,KAAK,IAAI,CAAC;;aAChB;IACH,QAAA,OAAO,GAAG,GAAG,KAAK,IAAI,QAAQ,GAAG,KAAK,GAAG,QAAQ;gBAAE,KAAK,IAAI,CAAC;IAC7D,QAAA,IAAI,CAAC,GAAG;gBAAE,KAAK,IAAI,CAAC;;QAExB,OAAO,KAAK,GAAG,MAAM;IACzB;IAEgB,SAAA,YAAY,CAAC,MAAmB,EAAE,WAAwB,EAAA;QACtE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;IACpC,IAAA,IAAI,GAAY;IAChB,IAAA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