Prettified all files.
This commit is contained in:
@@ -1442,7 +1442,7 @@
|
||||
|
||||
/**
|
||||
* Class that represents a PixiJS Progress.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* // Create the progress
|
||||
* const progress = new Progress({
|
||||
@@ -1458,10 +1458,9 @@
|
||||
* @see {@link https://www.iwm-tuebingen.de/iwmbrowser/lib/pixi/progress.html|DocTest}
|
||||
*/
|
||||
export default class Progress extends PIXI.Container {
|
||||
|
||||
/**
|
||||
* Creates an instance of a Progress.
|
||||
*
|
||||
*
|
||||
* @constructor
|
||||
* @param {object} [opts] - An options object to specify to style and behaviour of the progress.
|
||||
* @param {number} [opts.id=auto generated] - The id of the progress.
|
||||
@@ -1493,36 +1492,39 @@ export default class Progress extends PIXI.Container {
|
||||
* @param {boolean} [opts.visible=true] - Is the progress initially visible (property visible)?
|
||||
*/
|
||||
constructor(opts = {}) {
|
||||
|
||||
super()
|
||||
|
||||
|
||||
const theme = Theme.fromString(opts.theme)
|
||||
this.theme = theme
|
||||
|
||||
this.opts = Object.assign({}, {
|
||||
id: PIXI.utils.uid(),
|
||||
app: window.app,
|
||||
width: null,
|
||||
height: 2,
|
||||
margin: 100,
|
||||
padding: 0,
|
||||
fill: theme.fill,
|
||||
fillAlpha: theme.fillAlpha,
|
||||
fillActive: theme.primaryColor,
|
||||
fillActiveAlpha: theme.fillActiveAlpha,
|
||||
stroke: theme.stroke,
|
||||
strokeWidth: 0,
|
||||
strokeAlpha: theme.strokeAlpha,
|
||||
strokeActive: theme.strokeActive,
|
||||
strokeActiveWidth: 0,
|
||||
strokeActiveAlpha: theme.strokeActiveAlpha,
|
||||
background: false,
|
||||
backgroundFill: theme.background,
|
||||
backgroundFillAlpha: 1,
|
||||
radius: theme.radius,
|
||||
destroyOnComplete: true,
|
||||
visible: true
|
||||
}, opts)
|
||||
this.opts = Object.assign(
|
||||
{},
|
||||
{
|
||||
id: PIXI.utils.uid(),
|
||||
app: window.app,
|
||||
width: null,
|
||||
height: 2,
|
||||
margin: 100,
|
||||
padding: 0,
|
||||
fill: theme.fill,
|
||||
fillAlpha: theme.fillAlpha,
|
||||
fillActive: theme.primaryColor,
|
||||
fillActiveAlpha: theme.fillActiveAlpha,
|
||||
stroke: theme.stroke,
|
||||
strokeWidth: 0,
|
||||
strokeAlpha: theme.strokeAlpha,
|
||||
strokeActive: theme.strokeActive,
|
||||
strokeActiveWidth: 0,
|
||||
strokeActiveAlpha: theme.strokeActiveAlpha,
|
||||
background: false,
|
||||
backgroundFill: theme.background,
|
||||
backgroundFillAlpha: 1,
|
||||
radius: theme.radius,
|
||||
destroyOnComplete: true,
|
||||
visible: true
|
||||
},
|
||||
opts
|
||||
)
|
||||
|
||||
this.id = this.opts.id
|
||||
|
||||
@@ -1531,7 +1533,7 @@ export default class Progress extends PIXI.Container {
|
||||
this.barActive = null
|
||||
|
||||
this.alpha = 0
|
||||
|
||||
|
||||
this.visible = this.opts.visible
|
||||
|
||||
this._progress = 0
|
||||
@@ -1544,15 +1546,14 @@ export default class Progress extends PIXI.Container {
|
||||
//-----------------
|
||||
this.layout()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates children and instantiates everything.
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @return {Progress} A reference to the progress for chaining.
|
||||
*/
|
||||
setup() {
|
||||
|
||||
// interaction
|
||||
//-----------------
|
||||
this.on('added', e => {
|
||||
@@ -1579,14 +1580,13 @@ export default class Progress extends PIXI.Container {
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Should be called to refresh the layout of the progress. Can be used after resizing.
|
||||
*
|
||||
*
|
||||
* @return {Progress} A reference to the progress for chaining.
|
||||
*/
|
||||
layout() {
|
||||
|
||||
const width = this.opts.app.size.width
|
||||
const height = this.opts.app.size.height
|
||||
|
||||
@@ -1594,7 +1594,10 @@ export default class Progress extends PIXI.Container {
|
||||
//-----------------
|
||||
if (this.opts.background) {
|
||||
this.background.clear()
|
||||
this.background.beginFill(this.opts.backgroundFill, this.opts.backgroundFillAlpha)
|
||||
this.background.beginFill(
|
||||
this.opts.backgroundFill,
|
||||
this.opts.backgroundFillAlpha
|
||||
)
|
||||
this.background.drawRect(0, 0, width, height)
|
||||
this.background.endFill()
|
||||
}
|
||||
@@ -1603,15 +1606,14 @@ export default class Progress extends PIXI.Container {
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws the canvas.
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @return {Progress} A reference to the progress for chaining.
|
||||
*/
|
||||
draw() {
|
||||
|
||||
this.bar.clear()
|
||||
this.barActive.clear()
|
||||
|
||||
@@ -1620,59 +1622,80 @@ export default class Progress extends PIXI.Container {
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws the bar.
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @return {Progress} A reference to the progress for chaining.
|
||||
*/
|
||||
drawBar() {
|
||||
|
||||
const width = this.opts.app.size.width
|
||||
const height = this.opts.app.size.height
|
||||
|
||||
this.radius = this.opts.radius
|
||||
if ((this.radius * 2) > this.opts.height) {
|
||||
if (this.radius * 2 > this.opts.height) {
|
||||
this.radius = this.opts.height / 2
|
||||
}
|
||||
|
||||
const wantedWidth = this.opts.width || (width - (2 * this.opts.margin))
|
||||
const wantedWidth = this.opts.width || width - 2 * this.opts.margin
|
||||
const wantedHeight = this.opts.height
|
||||
|
||||
this.bar.lineStyle(this.opts.strokeWidth, this.opts.stroke, this.opts.strokeAlpha)
|
||||
this.bar.lineStyle(
|
||||
this.opts.strokeWidth,
|
||||
this.opts.stroke,
|
||||
this.opts.strokeAlpha
|
||||
)
|
||||
this.bar.beginFill(this.opts.fill, this.opts.fillAlpha)
|
||||
if (this.radius > 1) {
|
||||
this.bar.drawRoundedRect(0, 0, wantedWidth, wantedHeight, this.radius)
|
||||
this.bar.drawRoundedRect(
|
||||
0,
|
||||
0,
|
||||
wantedWidth,
|
||||
wantedHeight,
|
||||
this.radius
|
||||
)
|
||||
} else {
|
||||
this.bar.drawRect(0, 0, wantedWidth, wantedHeight)
|
||||
}
|
||||
this.bar.endFill()
|
||||
|
||||
|
||||
this.bar.x = width / 2 - this.bar.width / 2
|
||||
this.bar.y = height / 2 - this.bar.height / 2
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws the active bar.
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @return {Progress} A reference to the progress for chaining.
|
||||
*/
|
||||
drawBarActive() {
|
||||
const wantedWidth = this.bar.width - 2 * this.opts.padding
|
||||
const wantedHeight = this.bar.height - 2 * this.opts.padding
|
||||
|
||||
const wantedWidth = this.bar.width - (2 * this.opts.padding)
|
||||
const wantedHeight = this.bar.height - (2 * this.opts.padding)
|
||||
|
||||
const barActiveWidth = wantedWidth * this._progress / 100
|
||||
const barActiveWidth = (wantedWidth * this._progress) / 100
|
||||
|
||||
this.barActive.lineStyle(this.opts.strokeActiveWidth, this.opts.strokeActive, this.opts.strokeActiveAlpha)
|
||||
this.barActive.beginFill(this.opts.fillActive, this.opts.fillActiveAlpha)
|
||||
this.barActive.lineStyle(
|
||||
this.opts.strokeActiveWidth,
|
||||
this.opts.strokeActive,
|
||||
this.opts.strokeActiveAlpha
|
||||
)
|
||||
this.barActive.beginFill(
|
||||
this.opts.fillActive,
|
||||
this.opts.fillActiveAlpha
|
||||
)
|
||||
if (barActiveWidth > 0) {
|
||||
if (this.radius > 1) {
|
||||
this.barActive.drawRoundedRect(0, 0, barActiveWidth, wantedHeight, this.radius)
|
||||
this.barActive.drawRoundedRect(
|
||||
0,
|
||||
0,
|
||||
barActiveWidth,
|
||||
wantedHeight,
|
||||
this.radius
|
||||
)
|
||||
} else {
|
||||
this.barActive.drawRect(0, 0, barActiveWidth, wantedHeight)
|
||||
}
|
||||
@@ -1684,39 +1707,41 @@ export default class Progress extends PIXI.Container {
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shows the progress (sets his alpha values to 1).
|
||||
*
|
||||
*
|
||||
* @return {Progress} A reference to the progress for chaining.
|
||||
*/
|
||||
show() {
|
||||
TweenLite.to(this, this.theme.fast, {alpha: 1})
|
||||
TweenLite.to(this, this.theme.fast, { alpha: 1 })
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hides the progress (sets his alpha values to 1).
|
||||
*
|
||||
*
|
||||
* @return {Progress} A reference to the progress for chaining.
|
||||
*/
|
||||
hide() {
|
||||
TweenLite.to(this, this.theme.fast, {alpha: 0, onComplete: () => this.visible = false})
|
||||
TweenLite.to(this, this.theme.fast, {
|
||||
alpha: 0,
|
||||
onComplete: () => (this.visible = false)
|
||||
})
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets or sets the progress. Has to be a number between 0 and 100.
|
||||
*
|
||||
*
|
||||
* @member {number}
|
||||
*/
|
||||
get progress() {
|
||||
return this._progress
|
||||
}
|
||||
set progress(value) {
|
||||
|
||||
value = Math.round(value)
|
||||
|
||||
if (value < 0) {
|
||||
@@ -1734,7 +1759,7 @@ export default class Progress extends PIXI.Container {
|
||||
if (value === 100 && this.opts.destroyOnComplete) {
|
||||
TweenLite.to(this, this.theme.fast, {
|
||||
alpha: 0,
|
||||
onComplete: () => this.destroy({children: true})
|
||||
onComplete: () => this.destroy({ children: true })
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1754,7 +1779,7 @@ export default class Progress extends PIXI.Container {
|
||||
|
||||
<footer class="content-size">
|
||||
<div class="footer">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.2</a> on Wed Jul 10 2019 11:54:25 GMT+0200 (Mitteleuropäische Sommerzeit)
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Jul 18 2019 12:16:18 GMT+0200 (Mitteleuropäische Sommerzeit)
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user