Skip to content

Commit

Permalink
Fix text align with compressed output js (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmcgregor authored and bigtimebuddy committed Nov 22, 2016
1 parent d07e8be commit 72813d0
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions src/mixins/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/
const p = PIXI.Text.prototype;

// Possible align values
const ALIGN_VALUES = ["center", "right", "left"];

/**
* Setter for the alignment, also sets the anchor point
* to make sure the positioning is correct.
Expand All @@ -19,24 +22,11 @@ const p = PIXI.Text.prototype;
* @return {PIXI.Text} For chaining
*/
p.setAlign = p.g = function(align) {
this.style.align = align || "left";
var x;
if (typeof align == "string") {
switch (align) {
case "center":
x = 0.5;
break;
case "right":
x = 1;
break;
case "left":
x = 0;
break;
}
} else {
x = (align + 1) / 2;
align = ALIGN_VALUES.indexOf(align);
}
this.anchor.x = x;
this.style.align = ALIGN_VALUES[align] || "left";
this.anchor.x = (align + 1) / 2;
return this;
};

Expand Down Expand Up @@ -121,12 +111,12 @@ p.setShadow = p.sh = function(color, angle, distance) {

/**
* Check if a value is undefined, fallback to default value
* @method isUndefinedOr
* @method isUndefinedOr
* @private
* @param {*} value The value to check
* @param {*} defaultValue The default value if value is undefined
* @return {*} The either the value or the default value
*/
var isUndefinedOr = function(value, defaultValue) {
return value === undefined ? defaultValue : value;
};
};

0 comments on commit 72813d0

Please sign in to comment.