Working on stacked buttons.

This commit is contained in:
2019-07-30 16:56:29 +02:00
parent 0bcf931465
commit 5f46b4feae
115 changed files with 3277 additions and 5134 deletions
+10 -30
View File
@@ -1,4 +1,4 @@
/* globals */
/* globals ThrowPropsPlugin, Strong */
/* Imports */
import Events from '../events.js'
@@ -108,9 +108,7 @@ export default class List extends PIXI.Container {
if (this.opts.app) {
const app = this.opts.app
app.view.addEventListener('mousewheel', event => {
const bounds = this.mask
? this.mask.getBounds()
: this.getBounds()
const bounds = this.mask ? this.mask.getBounds() : this.getBounds()
const x = event.clientX - app.view.getBoundingClientRect().left
const y = event.clientY - app.view.getBoundingClientRect().top
if (bounds.contains(x, y)) {
@@ -167,14 +165,10 @@ export default class List extends PIXI.Container {
if (this.opts.orientation === 'vertical') {
switch (this.opts.align) {
case 'center':
this.__items.forEach(
it => (it.x = margin + this.width / 2 - it.width / 2)
)
this.__items.forEach(it => (it.x = margin + this.width / 2 - it.width / 2))
break
case 'right':
this.__items.forEach(
it => (it.x = margin + this.width - it.width)
)
this.__items.forEach(it => (it.x = margin + this.width - it.width))
break
default:
this.__items.forEach(it => (it.x = margin))
@@ -200,14 +194,10 @@ export default class List extends PIXI.Container {
this.__items.forEach(it => (it.y = margin))
break
case 'bottom':
this.__items.forEach(
it => (it.y = margin + this.height - it.height)
)
this.__items.forEach(it => (it.y = margin + this.height - it.height))
break
default:
this.__items.forEach(
it => (it.y = margin + this.height / 2 - it.height / 2)
)
this.__items.forEach(it => (it.y = margin + this.height / 2 - it.height / 2))
break
}
@@ -341,8 +331,7 @@ export default class List extends PIXI.Container {
{
throwProps,
ease: Strong.easeOut,
onComplete: () =>
ThrowPropsPlugin.untrack(this.container.position)
onComplete: () => ThrowPropsPlugin.untrack(this.container.position)
},
0.8,
0.4
@@ -363,20 +352,14 @@ export default class List extends PIXI.Container {
this.container.position.x -= event.deltaX
if (this.container.position.x > 0) {
this.container.position.x = 0
} else if (
this.container.position.x + this.innerWidth <
this.opts.width
) {
} else if (this.container.position.x + this.innerWidth < this.opts.width) {
this.container.position.x = this.opts.width - this.innerWidth
}
} else {
this.container.position.y -= event.deltaY
if (this.container.position.y > 0) {
this.container.position.y = 0
} else if (
this.container.position.y + this.innerHeight <
this.opts.height
) {
} else if (this.container.position.y + this.innerHeight < this.opts.height) {
this.container.position.y = this.opts.height - this.innerHeight
}
}
@@ -388,10 +371,7 @@ export default class List extends PIXI.Container {
* @param {event|PIXI.InteractionEvent} event - The PIXI event to capture.
*/
capture(event) {
const originalEvent =
event.data && event.data.originalEvent
? event.data.originalEvent
: event
const originalEvent = event.data && event.data.originalEvent ? event.data.originalEvent : event
Events.capturedBy(originalEvent, this)
}
}