Prettified all files.
This commit is contained in:
+25
-26
@@ -3,7 +3,7 @@ import AbstractPopup from './abstractpopup.js'
|
||||
|
||||
/**
|
||||
* Class that represents a PixiJS Tooltip.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* // Create the app
|
||||
* const app = new PIXIApp({
|
||||
@@ -11,13 +11,13 @@ import AbstractPopup from './abstractpopup.js'
|
||||
* width: 900,
|
||||
* height: 250
|
||||
* }).setup().run()
|
||||
*
|
||||
*
|
||||
* // Add an DisplayObject to the app
|
||||
* const circle = new PIXI.Graphics()
|
||||
* circle.beginFill(0x5251a3)
|
||||
* circle.drawCircle(50, 50, 40)
|
||||
* app.scene.addChild(circle)
|
||||
*
|
||||
*
|
||||
* const tooltip = new Tooltip({
|
||||
* object: circle,
|
||||
* container: app.scene,
|
||||
@@ -29,10 +29,9 @@ import AbstractPopup from './abstractpopup.js'
|
||||
* @see {@link https://www.iwm-tuebingen.de/iwmbrowser/lib/pixi/tooltip.html|DocTest}
|
||||
*/
|
||||
export default class Tooltip extends AbstractPopup {
|
||||
|
||||
/**
|
||||
* Creates an instance of a Tooltip.
|
||||
*
|
||||
*
|
||||
* @constructor
|
||||
* @param {object} [opts] - An options object to specify to style and behaviour of the tooltip.
|
||||
* @param {number} [opts.minWidth=0] - The minimum width of the tooltip.
|
||||
@@ -45,19 +44,22 @@ export default class Tooltip extends AbstractPopup {
|
||||
* @param {number} [opts.delay=0] - A delay, after which the tooltip should be opened.
|
||||
*/
|
||||
constructor(opts = {}) {
|
||||
|
||||
const theme = Theme.fromString(opts.theme)
|
||||
|
||||
opts = Object.assign({}, {
|
||||
minWidth: 0,
|
||||
minHeight: 0,
|
||||
padding: theme.padding / 2,
|
||||
object: null,
|
||||
container: null,
|
||||
offsetLeft: 8,
|
||||
offsetTop: -8,
|
||||
delay: 0
|
||||
}, opts)
|
||||
|
||||
opts = Object.assign(
|
||||
{},
|
||||
{
|
||||
minWidth: 0,
|
||||
minHeight: 0,
|
||||
padding: theme.padding / 2,
|
||||
object: null,
|
||||
container: null,
|
||||
offsetLeft: 8,
|
||||
offsetTop: -8,
|
||||
delay: 0
|
||||
},
|
||||
opts
|
||||
)
|
||||
|
||||
opts.container = opts.container || opts.object
|
||||
|
||||
@@ -71,15 +73,14 @@ export default class Tooltip extends AbstractPopup {
|
||||
//-----------------
|
||||
this.layout()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates children and instantiates everything.
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @return {Tooltip} A reference to the tooltip for chaining.
|
||||
*/
|
||||
setup() {
|
||||
|
||||
super.setup()
|
||||
|
||||
// bind events this
|
||||
@@ -87,7 +88,7 @@ export default class Tooltip extends AbstractPopup {
|
||||
this.interactive = true
|
||||
|
||||
let mouseoverTooltip = false
|
||||
|
||||
|
||||
this.on('mouseover', e => {
|
||||
mouseoverTooltip = true
|
||||
})
|
||||
@@ -100,7 +101,7 @@ export default class Tooltip extends AbstractPopup {
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// bind events object
|
||||
//-----------------
|
||||
const object = this.opts.object
|
||||
@@ -109,7 +110,6 @@ export default class Tooltip extends AbstractPopup {
|
||||
let mouseoverObject = false
|
||||
|
||||
object.on('mouseover', e => {
|
||||
|
||||
this.timeout = window.setTimeout(() => {
|
||||
mouseoverObject = true
|
||||
this.visible = true
|
||||
@@ -136,15 +136,14 @@ export default class Tooltip extends AbstractPopup {
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculates and sets the position of the tooltip.
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @return {Tooltip} A reference to the tooltip for chaining.
|
||||
*/
|
||||
setPosition(e) {
|
||||
|
||||
const position = e.data.getLocalPosition(this.opts.container)
|
||||
|
||||
this.x = position.x + this.opts.offsetLeft
|
||||
|
||||
Reference in New Issue
Block a user