Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix text align with compressed output js #31

Merged
merged 1 commit into from
Nov 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
};
};