@leafer-in/view 1.6.6 → 1.7.0
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 +14 -2
- package/dist/view.esm.js +14 -2
- package/dist/view.esm.min.js +1 -1
- package/dist/view.esm.min.js.map +1 -1
- package/dist/view.js +14 -2
- package/dist/view.min.cjs +1 -1
- package/dist/view.min.cjs.map +1 -1
- package/dist/view.min.js +1 -1
- package/dist/view.min.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +14 -3
package/dist/view.cjs
CHANGED
|
@@ -30,8 +30,16 @@ function getFixBounds(bounds, scaleBounds) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
draw.Plugin.add('view');
|
|
33
|
-
draw.Leafer.prototype.zoom = function (zoomType,
|
|
33
|
+
draw.Leafer.prototype.zoom = function (zoomType, optionsOrPadding, scroll, transition) {
|
|
34
34
|
this.killAnimate();
|
|
35
|
+
let padding;
|
|
36
|
+
if (typeof optionsOrPadding === 'object' && !(optionsOrPadding instanceof Array)) {
|
|
37
|
+
padding = optionsOrPadding.padding;
|
|
38
|
+
scroll = optionsOrPadding.scroll;
|
|
39
|
+
transition = optionsOrPadding.transition;
|
|
40
|
+
}
|
|
41
|
+
else
|
|
42
|
+
padding = optionsOrPadding;
|
|
35
43
|
const { zoomLayer } = this;
|
|
36
44
|
const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new draw.Bounds();
|
|
37
45
|
const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
|
|
@@ -78,7 +86,7 @@ draw.Leafer.prototype.zoom = function (zoomType, padding, fixed, transition) {
|
|
|
78
86
|
}
|
|
79
87
|
const { width, height } = bounds;
|
|
80
88
|
let moveX = limitBounds.x - bounds.x, moveY = limitBounds.y - bounds.y;
|
|
81
|
-
if (
|
|
89
|
+
if (scroll) {
|
|
82
90
|
moveX += Math.max((limitBounds.width - width) / 2, 0);
|
|
83
91
|
moveY += Math.max((limitBounds.height - height) / 2, 0);
|
|
84
92
|
}
|
|
@@ -91,6 +99,10 @@ draw.Leafer.prototype.zoom = function (zoomType, padding, fixed, transition) {
|
|
|
91
99
|
data.scaleX *= changeScale;
|
|
92
100
|
data.scaleY *= changeScale;
|
|
93
101
|
}
|
|
102
|
+
if (scroll === 'x')
|
|
103
|
+
moveY = 0;
|
|
104
|
+
else if (scroll === 'y')
|
|
105
|
+
moveX = 0;
|
|
94
106
|
draw.PointHelper.move(data, moveX, moveY);
|
|
95
107
|
bounds.move(moveX, moveY);
|
|
96
108
|
zoomLayer.set(data, transition);
|
package/dist/view.esm.js
CHANGED
|
@@ -28,8 +28,16 @@ function getFixBounds(bounds, scaleBounds) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
Plugin.add('view');
|
|
31
|
-
Leafer.prototype.zoom = function (zoomType,
|
|
31
|
+
Leafer.prototype.zoom = function (zoomType, optionsOrPadding, scroll, transition) {
|
|
32
32
|
this.killAnimate();
|
|
33
|
+
let padding;
|
|
34
|
+
if (typeof optionsOrPadding === 'object' && !(optionsOrPadding instanceof Array)) {
|
|
35
|
+
padding = optionsOrPadding.padding;
|
|
36
|
+
scroll = optionsOrPadding.scroll;
|
|
37
|
+
transition = optionsOrPadding.transition;
|
|
38
|
+
}
|
|
39
|
+
else
|
|
40
|
+
padding = optionsOrPadding;
|
|
33
41
|
const { zoomLayer } = this;
|
|
34
42
|
const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds();
|
|
35
43
|
const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
|
|
@@ -76,7 +84,7 @@ Leafer.prototype.zoom = function (zoomType, padding, fixed, transition) {
|
|
|
76
84
|
}
|
|
77
85
|
const { width, height } = bounds;
|
|
78
86
|
let moveX = limitBounds.x - bounds.x, moveY = limitBounds.y - bounds.y;
|
|
79
|
-
if (
|
|
87
|
+
if (scroll) {
|
|
80
88
|
moveX += Math.max((limitBounds.width - width) / 2, 0);
|
|
81
89
|
moveY += Math.max((limitBounds.height - height) / 2, 0);
|
|
82
90
|
}
|
|
@@ -89,6 +97,10 @@ Leafer.prototype.zoom = function (zoomType, padding, fixed, transition) {
|
|
|
89
97
|
data.scaleX *= changeScale;
|
|
90
98
|
data.scaleY *= changeScale;
|
|
91
99
|
}
|
|
100
|
+
if (scroll === 'x')
|
|
101
|
+
moveY = 0;
|
|
102
|
+
else if (scroll === 'y')
|
|
103
|
+
moveX = 0;
|
|
92
104
|
PointHelper.move(data, moveX, moveY);
|
|
93
105
|
bounds.move(moveX, moveY);
|
|
94
106
|
zoomLayer.set(data, transition);
|
package/dist/view.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Plugin as t,Leafer as e,Bounds as i,LeafBoundsHelper as s,PointHelper as
|
|
1
|
+
import{Plugin as t,Leafer as e,Bounds as i,LeafBoundsHelper as s,PointHelper as o}from"@leafer-ui/draw";function h(t,e){let i=1;const s="out"===e,o=Math.abs(t);if(o>1){for(;s?i<o:i<=o;)i*=2;s&&(i/=2)}else{for(;s?i>=o:i>o;)i/=2;s||(i*=2)}return i/t}t.add("view"),e.prototype.zoom=function(t,e,n,a){let c;this.killAnimate(),"object"!=typeof e||e instanceof Array?c=e:(c=e.padding,n=e.scroll,a=e.transition);const{zoomLayer:r}=this,l=this.canvas.bounds.clone().shrink(void 0!==c?c:30),d=new i,f={x:l.x+l.width/2,y:l.y+l.height/2};let u;const{x:w,y:g,scaleX:y,scaleY:x}=r.__;if("string"==typeof t)switch(t){case"in":u=h(y,"in");break;case"out":u=h(y,"out");break;case"fit":t=this.boxBounds;break;case"fit-width":(t=new i(this.boxBounds)).height=0;break;case"fit-height":(t=new i(this.boxBounds)).width=0}else"number"==typeof t&&(u=t/y);if(u)u=this.getValidScale(u),r.scaleOfWorld(f,u,u,!1,a);else if("object"==typeof t){const e={x:w,y:g,scaleX:y,scaleY:x},i=t instanceof Array;if(i||t.tag){const e=i?t:[t];d.setListWithFn(e,s.worldBounds)}else{const e=function(t,e){let i,{x:s,y:o,width:h,height:n}=t;return n||(n=h*(e.height/e.width),i=!0),h||(h=n*(e.width/e.height),i=!0),i?{x:s,y:o,width:h,height:n}:t}(t,l);d.set(r.getWorldBounds(e))}const{width:h,height:c}=d;let f=l.x-d.x,b=l.y-d.y;return n?(f+=Math.max((l.width-h)/2,0),b+=Math.max((l.height-c)/2,0)):(u=this.getValidScale(Math.min(l.width/h,l.height/c)),f+=(l.width-h*u)/2,b+=(l.height-c*u)/2,o.scaleOf(e,d,u),d.scaleOf(d,u),e.scaleX*=u,e.scaleY*=u),"x"===n?b=0:"y"===n&&(f=0),o.move(e,f,b),d.move(f,b),r.set(e,a),d}return r.worldBoxBounds};
|
|
2
2
|
//# sourceMappingURL=view.esm.min.js.map
|
package/dist/view.esm.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.esm.min.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,
|
|
1
|
+
{"version":3,"file":"view.esm.min.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, IZoomOptions, 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, optionsOrPadding?: IZoomOptions | IFourNumber, scroll?: 'x' | 'y' | boolean, transition?: ITransition): IBoundsData {\n\n this.killAnimate()\n\n let padding: IFourNumber\n\n if (typeof optionsOrPadding === 'object' && !(optionsOrPadding instanceof Array)) {\n padding = optionsOrPadding.padding\n scroll = optionsOrPadding.scroll\n transition = optionsOrPadding.transition\n } else padding = optionsOrPadding\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 (scroll) {\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 if (scroll === 'x') moveY = 0\n else if (scroll === 'y') moveX = 0\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":["getZoomScale","scaleX","type","scale","out","absScale","Math","abs","Plugin","add","Leafer","prototype","zoom","zoomType","optionsOrPadding","scroll","transition","padding","this","killAnimate","Array","zoomLayer","limitBounds","canvas","bounds","clone","shrink","undefined","Bounds","center","x","width","y","height","changeScale","scaleY","__","boxBounds","getValidScale","scaleOfWorld","data","isArray","tag","list","setListWithFn","LeafBoundsHelper","worldBounds","innerBounds","scaleBounds","fix","getFixBounds","set","getWorldBounds","moveX","moveY","max","min","PointHelper","scaleOf","move","worldBoxBounds"],"mappings":"wGAGgB,SAAAA,EAAaC,EAAgBC,GACzC,IAAIC,EAAQ,EACZ,MAAMC,EAAe,QAATF,EAAgBG,EAAWC,KAAKC,IAAIN,GAChD,GAAII,EAAW,EAAG,CACd,KAAOD,EAAMD,EAAQE,EAAWF,GAASE,GAAUF,GAAS,EACxDC,IAAKD,GAAS,OACf,CACH,KAAOC,EAAMD,GAASE,EAAWF,EAAQE,GAAUF,GAAS,EACvDC,IAAKD,GAAS,GAEvB,OAAOA,EAAQF,CACnB,CCRAO,EAAOC,IAAI,QAGXC,EAAOC,UAAUC,KAAO,SAAUC,EAAqBC,EAA+CC,EAA8BC,GAIhI,IAAIC,EAFJC,KAAKC,cAI2B,iBAArBL,GAAmCA,aAA4BM,MAInEH,EAAUH,GAHbG,EAAUH,EAAiBG,QAC3BF,EAASD,EAAiBC,OAC1BC,EAAaF,EAAiBE,YAGlC,MAAMK,UAAEA,GAAcH,KAChBI,EAAcJ,KAAKK,OAAOC,OAAOC,QAAQC,YAAmBC,IAAZV,EAAwBA,EAAU,IAAKO,EAAS,IAAII,EACpGC,EAAqB,CAAEC,EAAGR,EAAYQ,EAAIR,EAAYS,MAAQ,EAAGC,EAAGV,EAAYU,EAAIV,EAAYW,OAAS,GAE/G,IAAIC,EACJ,MAAMJ,EAAEA,EAACE,EAAEA,EAAC/B,OAAEA,EAAMkC,OAAEA,G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iD,KAAKjC,EAAYS,MAAQA,GAAS,EAAG,GACnDuB,GAAShD,KAAKiD,KAAKjC,EAAYW,OAASA,GAAU,EAAG,KAIrDC,EAAchB,KAAKoB,cAAchC,KAAKkD,IAAIlC,EAAYS,MAAQA,EAAOT,EAAYW,OAASA,IAC1FoB,IAAU/B,EAAYS,MAAQA,EAAQG,GAAe,EACrDoB,IAAUhC,EAAYW,OAASA,EAASC,GAAe,EAEvDuB,EAAYC,QAAQlB,EAAMhB,EAAQU,GAClCV,EAAOkC,QAAQlC,EAAQU,GAEvBM,EAAKvC,QAAUiC,EACfM,EAAKL,QAAUD,GAGJ,MAAXnB,EAAgBuC,EAAQ,EACR,MAAXvC,IAAgBsC,EAAQ,GAEjCI,EAAYE,KAAKnB,EAAMa,EAAOC,GAC9B9B,EAAOmC,KAAKN,EAAOC,GAEnBjC,EAAU8B,IAAIX,EAAMxB,GAEbQ,EAIX,OAAOH,EAAUuC,cAErB"}
|
package/dist/view.js
CHANGED
|
@@ -29,8 +29,16 @@
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
draw.Plugin.add('view');
|
|
32
|
-
draw.Leafer.prototype.zoom = function (zoomType,
|
|
32
|
+
draw.Leafer.prototype.zoom = function (zoomType, optionsOrPadding, scroll, transition) {
|
|
33
33
|
this.killAnimate();
|
|
34
|
+
let padding;
|
|
35
|
+
if (typeof optionsOrPadding === 'object' && !(optionsOrPadding instanceof Array)) {
|
|
36
|
+
padding = optionsOrPadding.padding;
|
|
37
|
+
scroll = optionsOrPadding.scroll;
|
|
38
|
+
transition = optionsOrPadding.transition;
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
padding = optionsOrPadding;
|
|
34
42
|
const { zoomLayer } = this;
|
|
35
43
|
const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new draw.Bounds();
|
|
36
44
|
const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
|
|
@@ -77,7 +85,7 @@
|
|
|
77
85
|
}
|
|
78
86
|
const { width, height } = bounds;
|
|
79
87
|
let moveX = limitBounds.x - bounds.x, moveY = limitBounds.y - bounds.y;
|
|
80
|
-
if (
|
|
88
|
+
if (scroll) {
|
|
81
89
|
moveX += Math.max((limitBounds.width - width) / 2, 0);
|
|
82
90
|
moveY += Math.max((limitBounds.height - height) / 2, 0);
|
|
83
91
|
}
|
|
@@ -90,6 +98,10 @@
|
|
|
90
98
|
data.scaleX *= changeScale;
|
|
91
99
|
data.scaleY *= changeScale;
|
|
92
100
|
}
|
|
101
|
+
if (scroll === 'x')
|
|
102
|
+
moveY = 0;
|
|
103
|
+
else if (scroll === 'y')
|
|
104
|
+
moveX = 0;
|
|
93
105
|
draw.PointHelper.move(data, moveX, moveY);
|
|
94
106
|
bounds.move(moveX, moveY);
|
|
95
107
|
zoomLayer.set(data, transition);
|
package/dist/view.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@leafer-ui/draw");function t(e,t){let i=1;const s="out"===t,o=Math.abs(e);if(o>1){for(;s?i<o:i<=o;)i*=2;s&&(i/=2)}else{for(;s?i>=o:i>o;)i/=2;s||(i*=2)}return i/e}e.Plugin.add("view"),e.Leafer.prototype.zoom=function(i,s,o,
|
|
1
|
+
"use strict";var e=require("@leafer-ui/draw");function t(e,t){let i=1;const s="out"===t,o=Math.abs(e);if(o>1){for(;s?i<o:i<=o;)i*=2;s&&(i/=2)}else{for(;s?i>=o:i>o;)i/=2;s||(i*=2)}return i/e}e.Plugin.add("view"),e.Leafer.prototype.zoom=function(i,s,o,n){let h;this.killAnimate(),"object"!=typeof s||s instanceof Array?h=s:(h=s.padding,o=s.scroll,n=s.transition);const{zoomLayer:a}=this,r=this.canvas.bounds.clone().shrink(void 0!==h?h:30),l=new e.Bounds,c={x:r.x+r.width/2,y:r.y+r.height/2};let d;const{x:u,y:f,scaleX:w,scaleY:g}=a.__;if("string"==typeof i)switch(i){case"in":d=t(w,"in");break;case"out":d=t(w,"out");break;case"fit":i=this.boxBounds;break;case"fit-width":(i=new e.Bounds(this.boxBounds)).height=0;break;case"fit-height":(i=new e.Bounds(this.boxBounds)).width=0}else"number"==typeof i&&(d=i/w);if(d)d=this.getValidScale(d),a.scaleOfWorld(c,d,d,!1,n);else if("object"==typeof i){const t={x:u,y:f,scaleX:w,scaleY:g},s=i instanceof Array;if(s||i.tag){const t=s?i:[i];l.setListWithFn(t,e.LeafBoundsHelper.worldBounds)}else{const e=function(e,t){let i,{x:s,y:o,width:n,height:h}=e;return h||(h=n*(t.height/t.width),i=!0),n||(n=h*(t.width/t.height),i=!0),i?{x:s,y:o,width:n,height:h}:e}(i,r);l.set(a.getWorldBounds(e))}const{width:h,height:c}=l;let y=r.x-l.x,x=r.y-l.y;return o?(y+=Math.max((r.width-h)/2,0),x+=Math.max((r.height-c)/2,0)):(d=this.getValidScale(Math.min(r.width/h,r.height/c)),y+=(r.width-h*d)/2,x+=(r.height-c*d)/2,e.PointHelper.scaleOf(t,l,d),l.scaleOf(l,d),t.scaleX*=d,t.scaleY*=d),"x"===o?x=0:"y"===o&&(y=0),e.PointHelper.move(t,y,x),l.move(y,x),a.set(t,n),l}return a.worldBoxBounds};
|
|
2
2
|
//# sourceMappingURL=view.min.cjs.map
|
package/dist/view.min.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.min.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,
|
|
1
|
+
{"version":3,"file":"view.min.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, IZoomOptions, 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, optionsOrPadding?: IZoomOptions | IFourNumber, scroll?: 'x' | 'y' | boolean, transition?: ITransition): IBoundsData {\n\n this.killAnimate()\n\n let padding: IFourNumber\n\n if (typeof optionsOrPadding === 'object' && !(optionsOrPadding instanceof Array)) {\n padding = optionsOrPadding.padding\n scroll = optionsOrPadding.scroll\n transition = optionsOrPadding.transition\n } else padding = optionsOrPadding\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 (scroll) {\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 if (scroll === 'x') moveY = 0\n else if (scroll === 'y') moveX = 0\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":["getZoomScale","scaleX","type","scale","out","absScale","Math","abs","Plugin","add","Leafer","prototype","zoom","zoomType","optionsOrPadding","scroll","transition","padding","this","killAnimate","Array","zoomLayer","limitBounds","canvas","bounds","clone","shrink","undefined","Bounds","center","x","width","y","height","changeScale","scaleY","__","boxBounds","getValidScale","scaleOfWorld","data","isArray","tag","list","setListWithFn","LeafBoundsHelper","worldBounds","innerBounds","scaleBounds","fix","getFixBounds","set","getWorldBounds","moveX","moveY","max","min","PointHelper","scaleOf","move","worldBoxBounds"],"mappings":"8CAGgB,SAAAA,EAAaC,EAAgBC,GACzC,IAAIC,EAAQ,EACZ,MAAMC,EAAe,QAATF,EAAgBG,EAAWC,KAAKC,IAAIN,GAChD,GAAII,EAAW,EAAG,CACd,KAAOD,EAAMD,EAAQE,EAAWF,GAASE,GAAUF,GAAS,EACxDC,IAAKD,GAAS,OACf,CACH,KAAOC,EAAMD,GAASE,EAAWF,EAAQE,GAAUF,GAAS,EACvDC,IAAKD,GAAS,GAEvB,OAAOA,EAAQF,CACnB,CCRAO,EAAAA,OAAOC,IAAI,QAGXC,EAAAA,OAAOC,UAAUC,KAAO,SAAUC,EAAqBC,EAA+CC,EAA8BC,GAIhI,IAAIC,EAFJC,KAAKC,cAI2B,iBAArBL,GAAmCA,aAA4BM,MAInEH,EAAUH,GAHbG,EAAUH,EAAiBG,QAC3BF,EAASD,EAAiBC,OAC1BC,EAAaF,EAAiBE,YAGlC,MAAMK,UAAEA,GAAcH,KAChBI,EAAcJ,KAA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AM,CAAEnB,IAAGE,IAAGD,QAAOE,UAAWT,CAC3C,CC+CgC0B,CAAarC,EAAyBS,GAC1DE,EAAO2B,IAAI9B,EAAU+B,eAAeL,IAGxC,MAAMhB,MAAEA,EAAKE,OAAEA,GAAWT,EAC1B,IAAI6B,EAAQ/B,EAAYQ,EAAIN,EAAOM,EAAGwB,EAAQhC,EAAYU,EAAIR,EAAOQ,EA4BrE,OA1BIjB,GAEAsC,GAAS/C,KAAKiD,KAAKjC,EAAYS,MAAQA,GAAS,EAAG,GACnDuB,GAAShD,KAAKiD,KAAKjC,EAAYW,OAASA,GAAU,EAAG,KAIrDC,EAAchB,KAAKoB,cAAchC,KAAKkD,IAAIlC,EAAYS,MAAQA,EAAOT,EAAYW,OAASA,IAC1FoB,IAAU/B,EAAYS,MAAQA,EAAQG,GAAe,EACrDoB,IAAUhC,EAAYW,OAASA,EAASC,GAAe,EAEvDuB,EAAAA,YAAYC,QAAQlB,EAAMhB,EAAQU,GAClCV,EAAOkC,QAAQlC,EAAQU,GAEvBM,EAAKvC,QAAUiC,EACfM,EAAKL,QAAUD,GAGJ,MAAXnB,EAAgBuC,EAAQ,EACR,MAAXvC,IAAgBsC,EAAQ,GAEjCI,EAAAA,YAAYE,KAAKnB,EAAMa,EAAOC,GAC9B9B,EAAOmC,KAAKN,EAAOC,GAEnBjC,EAAU8B,IAAIX,EAAMxB,GAEbQ,EAIX,OAAOH,EAAUuC,cAErB"}
|
package/dist/view.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t){"use strict";function e(t,e){let i=1;const s="out"===e,o=Math.abs(t);if(o>1){for(;s?i<o:i<=o;)i*=2;s&&(i/=2)}else{for(;s?i>=o:i>o;)i/=2;s||(i*=2)}return i/t}t.Plugin.add("view"),t.Leafer.prototype.zoom=function(i,s,o,
|
|
1
|
+
!function(t){"use strict";function e(t,e){let i=1;const s="out"===e,o=Math.abs(t);if(o>1){for(;s?i<o:i<=o;)i*=2;s&&(i/=2)}else{for(;s?i>=o:i>o;)i/=2;s||(i*=2)}return i/t}t.Plugin.add("view"),t.Leafer.prototype.zoom=function(i,s,o,n){let h;this.killAnimate(),"object"!=typeof s||s instanceof Array?h=s:(h=s.padding,o=s.scroll,n=s.transition);const{zoomLayer:a}=this,c=this.canvas.bounds.clone().shrink(void 0!==h?h:30),l=new t.Bounds,r={x:c.x+c.width/2,y:c.y+c.height/2};let d;const{x:f,y:u,scaleX:g,scaleY:w}=a.__;if("string"==typeof i)switch(i){case"in":d=e(g,"in");break;case"out":d=e(g,"out");break;case"fit":i=this.boxBounds;break;case"fit-width":(i=new t.Bounds(this.boxBounds)).height=0;break;case"fit-height":(i=new t.Bounds(this.boxBounds)).width=0}else"number"==typeof i&&(d=i/g);if(d)d=this.getValidScale(d),a.scaleOfWorld(r,d,d,!1,n);else if("object"==typeof i){const e={x:f,y:u,scaleX:g,scaleY:w},s=i instanceof Array;if(s||i.tag){const e=s?i:[i];l.setListWithFn(e,t.LeafBoundsHelper.worldBounds)}else{const t=function(t,e){let i,{x:s,y:o,width:n,height:h}=t;return h||(h=n*(e.height/e.width),i=!0),n||(n=h*(e.width/e.height),i=!0),i?{x:s,y:o,width:n,height:h}:t}(i,c);l.set(a.getWorldBounds(t))}const{width:h,height:r}=l;let y=c.x-l.x,x=c.y-l.y;return o?(y+=Math.max((c.width-h)/2,0),x+=Math.max((c.height-r)/2,0)):(d=this.getValidScale(Math.min(c.width/h,c.height/r)),y+=(c.width-h*d)/2,x+=(c.height-r*d)/2,t.PointHelper.scaleOf(e,l,d),l.scaleOf(l,d),e.scaleX*=d,e.scaleY*=d),"x"===o?x=0:"y"===o&&(y=0),t.PointHelper.move(e,y,x),l.move(y,x),a.set(e,n),l}return a.worldBoxBounds}}(LeaferUI);
|
|
2
2
|
//# sourceMappingURL=view.min.js.map
|
package/dist/view.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.min.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,
|
|
1
|
+
{"version":3,"file":"view.min.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, IZoomOptions, 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, optionsOrPadding?: IZoomOptions | IFourNumber, scroll?: 'x' | 'y' | boolean, transition?: ITransition): IBoundsData {\n\n this.killAnimate()\n\n let padding: IFourNumber\n\n if (typeof optionsOrPadding === 'object' && !(optionsOrPadding instanceof Array)) {\n padding = optionsOrPadding.padding\n scroll = optionsOrPadding.scroll\n transition = optionsOrPadding.transition\n } else padding = optionsOrPadding\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 (scroll) {\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 if (scroll === 'x') moveY = 0\n else if (scroll === 'y') moveX = 0\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":["getZoomScale","scaleX","type","scale","out","absScale","Math","abs","Plugin","add","Leafer","prototype","zoom","zoomType","optionsOrPadding","scroll","transition","padding","this","killAnimate","Array","zoomLayer","limitBounds","canvas","bounds","clone","shrink","undefined","Bounds","center","x","width","y","height","changeScale","scaleY","__","boxBounds","getValidScale","scaleOfWorld","data","isArray","tag","list","setListWithFn","LeafBoundsHelper","worldBounds","innerBounds","scaleBounds","fix","getFixBounds","set","getWorldBounds","moveX","moveY","max","min","PointHelper","scaleOf","move","worldBoxBounds"],"mappings":"0BAGgB,SAAAA,EAAaC,EAAgBC,GACzC,IAAIC,EAAQ,EACZ,MAAMC,EAAe,QAATF,EAAgBG,EAAWC,KAAKC,IAAIN,GAChD,GAAII,EAAW,EAAG,CACd,KAAOD,EAAMD,EAAQE,EAAWF,GAASE,GAAUF,GAAS,EACxDC,IAAKD,GAAS,OACf,CACH,KAAOC,EAAMD,GAASE,EAAWF,EAAQE,GAAUF,GAAS,EACvDC,IAAKD,G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
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/view",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
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.
|
|
38
|
-
"@leafer-ui/interface": "^1.
|
|
39
|
-
"@leafer-in/interface": "^1.
|
|
37
|
+
"@leafer-ui/draw": "^1.7.0",
|
|
38
|
+
"@leafer-ui/interface": "^1.7.0",
|
|
39
|
+
"@leafer-in/interface": "^1.7.0"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILeaf, IBoundsData, IZoomType, IFourNumber, IPointData, ITransition } from '@leafer-ui/interface'
|
|
1
|
+
import { ILeaf, IBoundsData, IZoomType, IZoomOptions, IFourNumber, IPointData, ITransition } from '@leafer-ui/interface'
|
|
2
2
|
import { Leafer, Bounds, LeafBoundsHelper, Plugin, PointHelper } from '@leafer-ui/draw'
|
|
3
3
|
|
|
4
4
|
import { getFixBounds, getZoomScale } from './helper'
|
|
@@ -7,10 +7,18 @@ import { getFixBounds, getZoomScale } from './helper'
|
|
|
7
7
|
Plugin.add('view')
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
Leafer.prototype.zoom = function (zoomType: IZoomType,
|
|
10
|
+
Leafer.prototype.zoom = function (zoomType: IZoomType, optionsOrPadding?: IZoomOptions | IFourNumber, scroll?: 'x' | 'y' | boolean, transition?: ITransition): IBoundsData {
|
|
11
11
|
|
|
12
12
|
this.killAnimate()
|
|
13
13
|
|
|
14
|
+
let padding: IFourNumber
|
|
15
|
+
|
|
16
|
+
if (typeof optionsOrPadding === 'object' && !(optionsOrPadding instanceof Array)) {
|
|
17
|
+
padding = optionsOrPadding.padding
|
|
18
|
+
scroll = optionsOrPadding.scroll
|
|
19
|
+
transition = optionsOrPadding.transition
|
|
20
|
+
} else padding = optionsOrPadding
|
|
21
|
+
|
|
14
22
|
const { zoomLayer } = this
|
|
15
23
|
const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds()
|
|
16
24
|
const center: IPointData = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 }
|
|
@@ -66,7 +74,7 @@ Leafer.prototype.zoom = function (zoomType: IZoomType, padding?: IFourNumber, fi
|
|
|
66
74
|
const { width, height } = bounds
|
|
67
75
|
let moveX = limitBounds.x - bounds.x, moveY = limitBounds.y - bounds.y
|
|
68
76
|
|
|
69
|
-
if (
|
|
77
|
+
if (scroll) {
|
|
70
78
|
|
|
71
79
|
moveX += Math.max((limitBounds.width - width) / 2, 0)
|
|
72
80
|
moveY += Math.max((limitBounds.height - height) / 2, 0)
|
|
@@ -84,6 +92,9 @@ Leafer.prototype.zoom = function (zoomType: IZoomType, padding?: IFourNumber, fi
|
|
|
84
92
|
data.scaleY *= changeScale
|
|
85
93
|
}
|
|
86
94
|
|
|
95
|
+
if (scroll === 'x') moveY = 0
|
|
96
|
+
else if (scroll === 'y') moveX = 0
|
|
97
|
+
|
|
87
98
|
PointHelper.move(data, moveX, moveY)
|
|
88
99
|
bounds.move(moveX, moveY)
|
|
89
100
|
|