Prettified all files.
This commit is contained in:
+29
-20
@@ -3,7 +3,7 @@ import Popup from './popup.js'
|
||||
|
||||
/**
|
||||
* Class that represents a PixiJS PopupMenu.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* // Create the button and the modal when clicked
|
||||
* const button = new Button({
|
||||
@@ -28,10 +28,9 @@ import Popup from './popup.js'
|
||||
* @see {@link https://www.iwm-tuebingen.de/iwmbrowser/lib/pixi/popupmenu.html|DocTest}
|
||||
*/
|
||||
export default class PopupMenu extends Popup {
|
||||
|
||||
/**
|
||||
* Creates an instance of a PopupMenu.
|
||||
*
|
||||
*
|
||||
* @constructor
|
||||
* @param {object} [opts] - An options object to specify to style and behaviour of the modal.
|
||||
* @param {object[]} [opts.items=[]] - A list of the menu items. Each item must be of type object.
|
||||
@@ -43,38 +42,42 @@ export default class PopupMenu extends Popup {
|
||||
* @param {boolean} [opts.closeOnPopup=true] - The opacity of the background.
|
||||
*/
|
||||
constructor(opts = {}) {
|
||||
|
||||
const theme = Theme.fromString(opts.theme)
|
||||
|
||||
opts = Object.assign({}, {
|
||||
items: [],
|
||||
margin: theme.margin / 2,
|
||||
textStyle: theme.textStyle,
|
||||
closeOnPopup: true
|
||||
}, opts)
|
||||
|
||||
opts = Object.assign(
|
||||
{},
|
||||
{
|
||||
items: [],
|
||||
margin: theme.margin / 2,
|
||||
textStyle: theme.textStyle,
|
||||
closeOnPopup: true
|
||||
},
|
||||
opts
|
||||
)
|
||||
|
||||
super(opts)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates children and instantiates everything.
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @return {PopupMenu} A reference to the popupmenu for chaining.
|
||||
*/
|
||||
setup() {
|
||||
|
||||
// content
|
||||
//-----------------
|
||||
const content = new PIXI.Container()
|
||||
|
||||
|
||||
let y = 0
|
||||
for (let item of this.opts.items) {
|
||||
|
||||
let object = null
|
||||
|
||||
if (item.label) {
|
||||
object = new PIXI.Text(item.label, item.textStyle || this.opts.textStyle)
|
||||
object = new PIXI.Text(
|
||||
item.label,
|
||||
item.textStyle || this.opts.textStyle
|
||||
)
|
||||
} else {
|
||||
object = item.content
|
||||
}
|
||||
@@ -83,16 +86,22 @@ export default class PopupMenu extends Popup {
|
||||
|
||||
if (item.action) {
|
||||
if (item.disabled) {
|
||||
object.alpha = .5
|
||||
object.alpha = 0.5
|
||||
} else {
|
||||
object.interactive = true
|
||||
object.buttonMode = true
|
||||
}
|
||||
object.on('pointerover', e => {
|
||||
TweenLite.to(object, this.theme.fast, {alpha: .83, overwrite: 'none'})
|
||||
TweenLite.to(object, this.theme.fast, {
|
||||
alpha: 0.83,
|
||||
overwrite: 'none'
|
||||
})
|
||||
})
|
||||
object.on('pointerout', e => {
|
||||
TweenLite.to(object, this.theme.fast, {alpha: 1, overwrite: 'none'})
|
||||
TweenLite.to(object, this.theme.fast, {
|
||||
alpha: 1,
|
||||
overwrite: 'none'
|
||||
})
|
||||
})
|
||||
object.on('pointerup', e => {
|
||||
item.action.call(object, e, object)
|
||||
|
||||
Reference in New Issue
Block a user