Added badge content example to button doctest.

This commit is contained in:
2019-08-06 12:01:32 +02:00
parent ca16516073
commit 05c952fbe1
70 changed files with 217 additions and 177 deletions
+36 -25
View File
@@ -1791,34 +1791,12 @@ export default class Button extends PIXI.Container {
}
const badge = new Badge(opts)
switch (opts.align) {
case 'left':
badge.x = this.x - badge.width / 2 + opts.offsetLeft
break
case 'center':
badge.x = this.x + this.width / 2 - badge.width / 2 + opts.offsetLeft
break
case 'right':
badge.x = this.x + this.width - badge.width / 2 + opts.offsetLeft
}
switch (opts.verticalAlign) {
case 'top':
badge.y = this.y - badge.height / 2 + opts.offsetTop
break
case 'middle':
badge.y = this.y + this.height / 2 - badge.height / 2 + opts.offsetTop
break
case 'bottom':
badge.y = this.y + this.height - badge.height / 2 + opts.offsetTop
}
this.addChild(badge)
this.badge = badge
}
this.layout()
// set position
//-----------------
this.position.set(this.opts.x, this.opts.y)
@@ -1903,6 +1881,39 @@ export default class Button extends PIXI.Container {
this.icon = icon
// badge
//--------------------
if (this.badge) {
this.removeChild(this.badge)
const width = this.width
const height = this.height
this.addChild(this.badge)
const badge = this.badge
switch (badge.opts.align) {
case 'left':
badge.x = -badge.width / 2 + badge.opts.offsetLeft
break
case 'center':
badge.x = width / 2 - badge.width / 2 + badge.opts.offsetLeft
break
case 'right':
badge.x = width - badge.width / 2 + badge.opts.offsetLeft
}
switch (badge.opts.verticalAlign) {
case 'top':
badge.y = -badge.height / 2 + badge.opts.offsetTop
break
case 'middle':
badge.y = height / 2 - badge.height / 2 + badge.opts.offsetTop
break
case 'bottom':
badge.y = height - badge.height / 2 + badge.opts.offsetTop
}
}
// draw
//-----------------
this.draw()
@@ -2163,7 +2174,7 @@ export default class Button extends PIXI.Container {
<footer class="content-size">
<div class="footer">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Mon Aug 05 2019 11:44:33 GMT+0200 (Mitteleuropäische Sommerzeit)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Aug 06 2019 12:01:03 GMT+0200 (Mitteleuropäische Sommerzeit)
</div>
</footer>
</div>