This commit is contained in:
Uwe Oestermeier 2019-08-08 12:06:27 +02:00
commit 7e7b37f524
3 changed files with 76 additions and 52 deletions

56
dist/iwmlib.pixi.js vendored
View File

@ -3378,18 +3378,21 @@
* @param {*} event * @param {*} event
*/ */
onStart(event) { onStart(event) {
this.__dragging = true;
this.capture(event); if ((this.opts.maxWidth != null && this.__initWidth > this.opts.maxWidth) || (this.opts.maxHeight != null && this.__initHeight > this.opts.maxHeight)) {
this.__dragging = true;
this.__delta = { this.capture(event);
x: this.container.position.x - event.data.global.x,
y: this.container.position.y - event.data.global.y
};
TweenLite.killTweensOf(this.container.position, { x: true, y: true }); this.__delta = {
if (typeof ThrowPropsPlugin != 'undefined') { x: this.container.position.x - event.data.global.x,
ThrowPropsPlugin.track(this.container.position, 'x,y'); y: this.container.position.y - event.data.global.y
};
TweenLite.killTweensOf(this.container.position, { x: true, y: true });
if (typeof ThrowPropsPlugin != 'undefined') {
ThrowPropsPlugin.track(this.container.position, 'x,y');
}
} }
} }
@ -3483,25 +3486,28 @@
* @param {*} event * @param {*} event
*/ */
onScroll(event) { onScroll(event) {
this.capture(event);
if (this.opts.orientation === 'horizontal') { if ((this.opts.maxWidth != null && this.__initWidth > this.opts.maxWidth) || (this.opts.maxHeight != null && this.__initHeight > this.opts.maxHeight)) {
this.container.position.x -= event.deltaX; this.capture(event);
if (this.container.position.x > 0) {
this.container.position.x = 0; if (this.opts.orientation === 'horizontal') {
} else if (this.container.position.x + this.__initWidth < this.opts.maxWidth) { this.container.position.x -= event.deltaX;
this.container.position.x = this.opts.maxWidth - this.__initWidth; if (this.container.position.x > 0) {
} this.container.position.x = 0;
} else { } else if (this.container.position.x + this.__initWidth < this.opts.maxWidth) {
this.container.position.y -= event.deltaY; this.container.position.x = this.opts.maxWidth - this.__initWidth;
if (this.container.position.y > 0) { }
this.container.position.y = 0; } else {
} else if (this.container.position.y + this.container.height < this.opts.maxHeight) { this.container.position.y -= event.deltaY;
this.container.position.y = this.opts.maxHeight - this.container.height; if (this.container.position.y > 0) {
this.container.position.y = 0;
} else if (this.container.position.y + this.container.height < this.opts.maxHeight) {
this.container.position.y = this.opts.maxHeight - this.container.height;
}
} }
this.stack();
} }
this.stack();
} }
/** /**

View File

@ -30,7 +30,7 @@
const app = new PIXIApp({ const app = new PIXIApp({
view: canvas, view: canvas,
width: 1000, width: 1000,
height: 1400 height: 1700
}).setup().run() }).setup().run()
const buttonGroup1 = new ButtonGroup({ const buttonGroup1 = new ButtonGroup({
@ -324,12 +324,24 @@ const buttonGroup18 = new ButtonGroup({
app app
}) })
const buttonGroup19 = new ButtonGroup({
x: 10,
y: 1420,
buttons: [
{label: 'move'},
{label: 'explanation dried'},
{label: 'out catch'}
],
maxWidth: 500,
app
})
app.scene.addChild(buttonGroup1, buttonGroup2, buttonGroup3) app.scene.addChild(buttonGroup1, buttonGroup2, buttonGroup3)
app.scene.addChild(buttonGroup4) app.scene.addChild(buttonGroup4)
app.scene.addChild(buttonGroup5, buttonGroup6) app.scene.addChild(buttonGroup5, buttonGroup6)
app.scene.addChild(buttonGroup7, buttonGroup8) app.scene.addChild(buttonGroup7, buttonGroup8)
app.scene.addChild(buttonGroup9, buttonGroup10, buttonGroup11, buttonGroup12, buttonGroup13) app.scene.addChild(buttonGroup9, buttonGroup10, buttonGroup11, buttonGroup12, buttonGroup13)
app.scene.addChild(buttonGroup14, buttonGroup15, buttonGroup16, buttonGroup17, buttonGroup18) app.scene.addChild(buttonGroup14, buttonGroup15, buttonGroup16, buttonGroup17, buttonGroup18, buttonGroup19)
</script> </script>
</body> </body>
</html> </html>

View File

@ -440,18 +440,21 @@ export default class ButtonGroup extends PIXI.Container {
* @param {*} event * @param {*} event
*/ */
onStart(event) { onStart(event) {
this.__dragging = true
this.capture(event) if ((this.opts.maxWidth != null && this.__initWidth > this.opts.maxWidth) || (this.opts.maxHeight != null && this.__initHeight > this.opts.maxHeight)) {
this.__dragging = true
this.__delta = { this.capture(event)
x: this.container.position.x - event.data.global.x,
y: this.container.position.y - event.data.global.y
}
TweenLite.killTweensOf(this.container.position, { x: true, y: true }) this.__delta = {
if (typeof ThrowPropsPlugin != 'undefined') { x: this.container.position.x - event.data.global.x,
ThrowPropsPlugin.track(this.container.position, 'x,y') y: this.container.position.y - event.data.global.y
}
TweenLite.killTweensOf(this.container.position, { x: true, y: true })
if (typeof ThrowPropsPlugin != 'undefined') {
ThrowPropsPlugin.track(this.container.position, 'x,y')
}
} }
} }
@ -545,25 +548,28 @@ export default class ButtonGroup extends PIXI.Container {
* @param {*} event * @param {*} event
*/ */
onScroll(event) { onScroll(event) {
this.capture(event)
if (this.opts.orientation === 'horizontal') { if ((this.opts.maxWidth != null && this.__initWidth > this.opts.maxWidth) || (this.opts.maxHeight != null && this.__initHeight > this.opts.maxHeight)) {
this.container.position.x -= event.deltaX this.capture(event)
if (this.container.position.x > 0) {
this.container.position.x = 0 if (this.opts.orientation === 'horizontal') {
} else if (this.container.position.x + this.__initWidth < this.opts.maxWidth) { this.container.position.x -= event.deltaX
this.container.position.x = this.opts.maxWidth - this.__initWidth if (this.container.position.x > 0) {
} this.container.position.x = 0
} else { } else if (this.container.position.x + this.__initWidth < this.opts.maxWidth) {
this.container.position.y -= event.deltaY this.container.position.x = this.opts.maxWidth - this.__initWidth
if (this.container.position.y > 0) { }
this.container.position.y = 0 } else {
} else if (this.container.position.y + this.container.height < this.opts.maxHeight) { this.container.position.y -= event.deltaY
this.container.position.y = this.opts.maxHeight - this.container.height if (this.container.position.y > 0) {
this.container.position.y = 0
} else if (this.container.position.y + this.container.height < this.opts.maxHeight) {
this.container.position.y = this.opts.maxHeight - this.container.height
}
} }
this.stack()
} }
this.stack()
} }
/** /**