@leafer-in/scroll 1.0.0-rc.30 → 1.0.1
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/scroll.cjs +7 -6
- package/dist/scroll.esm.js +2 -1
- package/dist/scroll.esm.min.js +1 -1
- package/dist/scroll.js +8 -8
- package/dist/scroll.min.cjs +1 -1
- package/dist/scroll.min.js +1 -1
- package/package.json +5 -4
- package/src/ScrollBar.ts +2 -1
- package/types/index.d.ts +2 -1
package/dist/scroll.cjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var draw = require('@leafer-ui/draw');
|
|
3
4
|
var core = require('@leafer-ui/core');
|
|
4
5
|
|
|
5
|
-
class ScrollBar extends
|
|
6
|
+
class ScrollBar extends draw.Group {
|
|
6
7
|
get isOutside() { return true; }
|
|
7
8
|
constructor(target, userConfig) {
|
|
8
9
|
super();
|
|
@@ -17,7 +18,7 @@ class ScrollBar extends core.Group {
|
|
|
17
18
|
}
|
|
18
19
|
this.target = target;
|
|
19
20
|
if (userConfig)
|
|
20
|
-
|
|
21
|
+
draw.DataHelper.assign(this.config, userConfig);
|
|
21
22
|
this.changeTheme(this.config.theme);
|
|
22
23
|
this.waitLeafer(this.__listenEvents, this);
|
|
23
24
|
}
|
|
@@ -34,7 +35,7 @@ class ScrollBar extends core.Group {
|
|
|
34
35
|
style = theme;
|
|
35
36
|
}
|
|
36
37
|
if (!this.scrollXBar)
|
|
37
|
-
this.addMany(this.scrollXBar = new
|
|
38
|
+
this.addMany(this.scrollXBar = new draw.Box(), this.scrollYBar = new draw.Box());
|
|
38
39
|
style = Object.assign({ strokeAlign: 'center', opacity: 0.5, width: 6, cornerRadius: 3, hoverStyle: { opacity: 0.6 }, pressStyle: { opacity: 0.7 } }, style);
|
|
39
40
|
if (!style.height)
|
|
40
41
|
style.height = style.width;
|
|
@@ -51,7 +52,7 @@ class ScrollBar extends core.Group {
|
|
|
51
52
|
const { worldRenderBounds } = zoomLayer;
|
|
52
53
|
if (check && this.scrollBounds && this.scrollBounds.isSame(worldRenderBounds))
|
|
53
54
|
return;
|
|
54
|
-
this.scrollBounds = new
|
|
55
|
+
this.scrollBounds = new draw.Bounds(worldRenderBounds);
|
|
55
56
|
const bounds = canvas.bounds.clone().shrink(padding);
|
|
56
57
|
const totalBounds = bounds.clone().add(worldRenderBounds);
|
|
57
58
|
const ratioX = this.ratioX = bounds.width / totalBounds.width;
|
|
@@ -95,8 +96,8 @@ class ScrollBar extends core.Group {
|
|
|
95
96
|
scrollYBar.on_(core.DragEvent.DRAG, this.onDrag, this),
|
|
96
97
|
scrollXBar.on_(core.DragEvent.END, this.onDragEnd, this),
|
|
97
98
|
scrollYBar.on_(core.DragEvent.END, this.onDragEnd, this),
|
|
98
|
-
this.target.on_(
|
|
99
|
-
this.target.leafer.on_(
|
|
99
|
+
this.target.on_(draw.RenderEvent.BEFORE, () => this.update(true)),
|
|
100
|
+
this.target.leafer.on_(draw.ResizeEvent.RESIZE, () => this.update())
|
|
100
101
|
];
|
|
101
102
|
}
|
|
102
103
|
__removeListenEvents() {
|
package/dist/scroll.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Group, DataHelper, Box, Bounds,
|
|
1
|
+
import { Group, DataHelper, Box, Bounds, RenderEvent, ResizeEvent } from '@leafer-ui/draw';
|
|
2
|
+
import { DragEvent } from '@leafer-ui/core';
|
|
2
3
|
|
|
3
4
|
class ScrollBar extends Group {
|
|
4
5
|
get isOutside() { return true; }
|
package/dist/scroll.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Group as t,DataHelper as i,Box as s,Bounds as e,
|
|
1
|
+
import{Group as t,DataHelper as i,Box as s,Bounds as e,RenderEvent as r,ResizeEvent as h}from"@leafer-ui/draw";import{DragEvent as o}from"@leafer-ui/core";class a extends t{get isOutside(){return!0}constructor(t,s){super(),this.config={theme:"light",padding:0,minSize:10},t.isApp&&(t.sky.add(this),t=t.tree),this.target=t,s&&i.assign(this.config,s),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(t){let i;"string"==typeof t?(i={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===t&&(i.fill="white",i.stroke="rgba(0,0,0,0.2)")):i=t,this.scrollXBar||this.addMany(this.scrollXBar=new s,this.scrollYBar=new s),i=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},i),i.height||(i.height=i.width),this.scrollXBar.set(Object.assign(Object.assign({},i),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},i),{visible:!1})),this.leafer&&this.update()}update(t){if(this.dragScrolling)return;const{minSize:i,padding:s}=this.config,{zoomLayer:r,canvas:h}=this.target.leafer,{worldRenderBounds:o}=r;if(t&&this.scrollBounds&&this.scrollBounds.isSame(o))return;this.scrollBounds=new e(o);const a=h.bounds.clone().shrink(s),n=a.clone().add(o),l=this.ratioX=a.width/n.width,g=this.ratioY=a.height/n.height,d=(a.x-n.x)/n.width,c=(a.y-n.y)/n.height,u=l<1,f=g<1,{scrollXBar:p,scrollYBar:m}=this,{x:_,y:v,width:y,height:w}=a.shrink([2,f?m.width+6:2,u?p.height+6:2,2]);p.set({x:_+y*d,y:v+w+2,width:Math.max(y*l,i),visible:u}),m.set({x:_+y+2,y:v+w*c,height:Math.max(w*g,i),visible:f})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const i=t.current===this.scrollXBar,s=this.target.leafer.getValidMove(i?-t.moveX/this.ratioX:0,i?0:-t.moveY/this.ratioY);this.target.moveWorld(s.x,s.y),t.current.moveWorld(s.x&&-s.x*this.ratioX,s.y&&-s.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:t,scrollYBar:i}=this;this.__eventIds=[t.on_(o.DRAG,this.onDrag,this),i.on_(o.DRAG,this.onDrag,this),t.on_(o.END,this.onDragEnd,this),i.on_(o.END,this.onDragEnd,this),this.target.on_(r.BEFORE,(()=>this.update(!0))),this.target.leafer.on_(h.RESIZE,(()=>this.update()))]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}export{a as ScrollBar};
|
package/dist/scroll.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
this.LeaferIN = this.LeaferIN || {};
|
|
2
|
-
this.LeaferIN.scroll = (function (exports, core) {
|
|
2
|
+
this.LeaferIN.scroll = (function (exports, draw, core) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
class ScrollBar extends
|
|
5
|
+
class ScrollBar extends draw.Group {
|
|
6
6
|
get isOutside() { return true; }
|
|
7
7
|
constructor(target, userConfig) {
|
|
8
8
|
super();
|
|
@@ -17,7 +17,7 @@ this.LeaferIN.scroll = (function (exports, core) {
|
|
|
17
17
|
}
|
|
18
18
|
this.target = target;
|
|
19
19
|
if (userConfig)
|
|
20
|
-
|
|
20
|
+
draw.DataHelper.assign(this.config, userConfig);
|
|
21
21
|
this.changeTheme(this.config.theme);
|
|
22
22
|
this.waitLeafer(this.__listenEvents, this);
|
|
23
23
|
}
|
|
@@ -34,7 +34,7 @@ this.LeaferIN.scroll = (function (exports, core) {
|
|
|
34
34
|
style = theme;
|
|
35
35
|
}
|
|
36
36
|
if (!this.scrollXBar)
|
|
37
|
-
this.addMany(this.scrollXBar = new
|
|
37
|
+
this.addMany(this.scrollXBar = new draw.Box(), this.scrollYBar = new draw.Box());
|
|
38
38
|
style = Object.assign({ strokeAlign: 'center', opacity: 0.5, width: 6, cornerRadius: 3, hoverStyle: { opacity: 0.6 }, pressStyle: { opacity: 0.7 } }, style);
|
|
39
39
|
if (!style.height)
|
|
40
40
|
style.height = style.width;
|
|
@@ -51,7 +51,7 @@ this.LeaferIN.scroll = (function (exports, core) {
|
|
|
51
51
|
const { worldRenderBounds } = zoomLayer;
|
|
52
52
|
if (check && this.scrollBounds && this.scrollBounds.isSame(worldRenderBounds))
|
|
53
53
|
return;
|
|
54
|
-
this.scrollBounds = new
|
|
54
|
+
this.scrollBounds = new draw.Bounds(worldRenderBounds);
|
|
55
55
|
const bounds = canvas.bounds.clone().shrink(padding);
|
|
56
56
|
const totalBounds = bounds.clone().add(worldRenderBounds);
|
|
57
57
|
const ratioX = this.ratioX = bounds.width / totalBounds.width;
|
|
@@ -95,8 +95,8 @@ this.LeaferIN.scroll = (function (exports, core) {
|
|
|
95
95
|
scrollYBar.on_(core.DragEvent.DRAG, this.onDrag, this),
|
|
96
96
|
scrollXBar.on_(core.DragEvent.END, this.onDragEnd, this),
|
|
97
97
|
scrollYBar.on_(core.DragEvent.END, this.onDragEnd, this),
|
|
98
|
-
this.target.on_(
|
|
99
|
-
this.target.leafer.on_(
|
|
98
|
+
this.target.on_(draw.RenderEvent.BEFORE, () => this.update(true)),
|
|
99
|
+
this.target.leafer.on_(draw.ResizeEvent.RESIZE, () => this.update())
|
|
100
100
|
];
|
|
101
101
|
}
|
|
102
102
|
__removeListenEvents() {
|
|
@@ -115,4 +115,4 @@ this.LeaferIN.scroll = (function (exports, core) {
|
|
|
115
115
|
|
|
116
116
|
return exports;
|
|
117
117
|
|
|
118
|
-
})({}, LeaferUI);
|
|
118
|
+
})({}, LeaferUI, LeaferUI);
|
package/dist/scroll.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer-ui/core");class
|
|
1
|
+
"use strict";var t=require("@leafer-ui/draw"),i=require("@leafer-ui/core");class e extends t.Group{get isOutside(){return!0}constructor(i,e){super(),this.config={theme:"light",padding:0,minSize:10},i.isApp&&(i.sky.add(this),i=i.tree),this.target=i,e&&t.DataHelper.assign(this.config,e),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(i){let e;"string"==typeof i?(e={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===i&&(e.fill="white",e.stroke="rgba(0,0,0,0.2)")):e=i,this.scrollXBar||this.addMany(this.scrollXBar=new t.Box,this.scrollYBar=new t.Box),e=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},e),e.height||(e.height=e.width),this.scrollXBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.leafer&&this.update()}update(i){if(this.dragScrolling)return;const{minSize:e,padding:s}=this.config,{zoomLayer:r,canvas:h}=this.target.leafer,{worldRenderBounds:a}=r;if(i&&this.scrollBounds&&this.scrollBounds.isSame(a))return;this.scrollBounds=new t.Bounds(a);const o=h.bounds.clone().shrink(s),n=o.clone().add(a),l=this.ratioX=o.width/n.width,g=this.ratioY=o.height/n.height,d=(o.x-n.x)/n.width,c=(o.y-n.y)/n.height,u=l<1,v=g<1,{scrollXBar:p,scrollYBar:_}=this,{x:f,y:y,width:m,height:B}=o.shrink([2,v?_.width+6:2,u?p.height+6:2,2]);p.set({x:f+m*d,y:y+B+2,width:Math.max(m*l,e),visible:u}),_.set({x:f+m+2,y:y+B*c,height:Math.max(B*g,e),visible:v})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const i=t.current===this.scrollXBar,e=this.target.leafer.getValidMove(i?-t.moveX/this.ratioX:0,i?0:-t.moveY/this.ratioY);this.target.moveWorld(e.x,e.y),t.current.moveWorld(e.x&&-e.x*this.ratioX,e.y&&-e.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:e,scrollYBar:s}=this;this.__eventIds=[e.on_(i.DragEvent.DRAG,this.onDrag,this),s.on_(i.DragEvent.DRAG,this.onDrag,this),e.on_(i.DragEvent.END,this.onDragEnd,this),s.on_(i.DragEvent.END,this.onDragEnd,this),this.target.on_(t.RenderEvent.BEFORE,(()=>this.update(!0))),this.target.leafer.on_(t.ResizeEvent.RESIZE,(()=>this.update()))]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}exports.ScrollBar=e;
|
package/dist/scroll.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.scroll=function(t,s){"use strict";class
|
|
1
|
+
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.scroll=function(t,s,i){"use strict";class e extends s.Group{get isOutside(){return!0}constructor(t,i){super(),this.config={theme:"light",padding:0,minSize:10},t.isApp&&(t.sky.add(this),t=t.tree),this.target=t,i&&s.DataHelper.assign(this.config,i),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(t){let i;"string"==typeof t?(i={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===t&&(i.fill="white",i.stroke="rgba(0,0,0,0.2)")):i=t,this.scrollXBar||this.addMany(this.scrollXBar=new s.Box,this.scrollYBar=new s.Box),i=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},i),i.height||(i.height=i.width),this.scrollXBar.set(Object.assign(Object.assign({},i),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},i),{visible:!1})),this.leafer&&this.update()}update(t){if(this.dragScrolling)return;const{minSize:i,padding:e}=this.config,{zoomLayer:r,canvas:h}=this.target.leafer,{worldRenderBounds:a}=r;if(t&&this.scrollBounds&&this.scrollBounds.isSame(a))return;this.scrollBounds=new s.Bounds(a);const n=h.bounds.clone().shrink(e),o=n.clone().add(a),l=this.ratioX=n.width/o.width,g=this.ratioY=n.height/o.height,d=(n.x-o.x)/o.width,c=(n.y-o.y)/o.height,u=l<1,v=g<1,{scrollXBar:f,scrollYBar:p}=this,{x:_,y:y,width:m,height:B}=n.shrink([2,v?p.width+6:2,u?f.height+6:2,2]);f.set({x:_+m*d,y:y+B+2,width:Math.max(m*l,i),visible:u}),p.set({x:_+m+2,y:y+B*c,height:Math.max(B*g,i),visible:v})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const s=t.current===this.scrollXBar,i=this.target.leafer.getValidMove(s?-t.moveX/this.ratioX:0,s?0:-t.moveY/this.ratioY);this.target.moveWorld(i.x,i.y),t.current.moveWorld(i.x&&-i.x*this.ratioX,i.y&&-i.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:t,scrollYBar:e}=this;this.__eventIds=[t.on_(i.DragEvent.DRAG,this.onDrag,this),e.on_(i.DragEvent.DRAG,this.onDrag,this),t.on_(i.DragEvent.END,this.onDragEnd,this),e.on_(i.DragEvent.END,this.onDragEnd,this),this.target.on_(s.RenderEvent.BEFORE,(()=>this.update(!0))),this.target.leafer.on_(s.ResizeEvent.RESIZE,(()=>this.update()))]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}return t.ScrollBar=e,t}({},LeaferUI,LeaferUI);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/scroll",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "@leafer-in/scroll",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,8 +34,9 @@
|
|
|
34
34
|
"leaferjs"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@leafer-ui/
|
|
38
|
-
"@leafer-ui/
|
|
39
|
-
"@leafer-
|
|
37
|
+
"@leafer-ui/draw": "1.0.1",
|
|
38
|
+
"@leafer-ui/core": "1.0.1",
|
|
39
|
+
"@leafer-ui/interface": "1.0.1",
|
|
40
|
+
"@leafer-in/interface": "1.0.1"
|
|
40
41
|
}
|
|
41
42
|
}
|
package/src/ScrollBar.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IApp, IBounds, IBox, IBoxInputData, IEventListenerId, IGroup } from '@leafer-ui/interface'
|
|
2
|
-
import {
|
|
2
|
+
import { Group, RenderEvent, ResizeEvent, Box, Bounds, DataHelper } from '@leafer-ui/draw'
|
|
3
|
+
import { DragEvent } from '@leafer-ui/core'
|
|
3
4
|
|
|
4
5
|
import { IScrollBar, IScrollBarConfig, IScrollBarTheme } from '@leafer-in/interface'
|
|
5
6
|
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IGroup, IBox, IBounds, IEventListenerId } from '@leafer-ui/interface';
|
|
2
|
-
import { Group
|
|
2
|
+
import { Group } from '@leafer-ui/draw';
|
|
3
|
+
import { DragEvent } from '@leafer-ui/core';
|
|
3
4
|
import { IScrollBar, IScrollBarConfig, IScrollBarTheme } from '@leafer-in/interface';
|
|
4
5
|
|
|
5
6
|
declare class ScrollBar extends Group implements IScrollBar {
|