Skip to content

Commit

Permalink
[gui.SpritePlugin] Support float translate values
Browse files Browse the repository at this point in the history
[gui.SpritePlugin] Adjust tests for floating points

[gui.SpritePlugin] Fixed special IE test case
  • Loading branch information
Daniel Spitzer committed Jul 14, 2017
1 parent de2dcec commit 542d5f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ describe('gui.Sprite', function likethis() {
this.sandbox.appendChild(spirit.element);
spirit.setSpriteStuff();
var cssText = this.sandbox.children[0].style.cssText;
expect(cssText.indexOf('transform-origin: 10px 10px 10px;')).toBeGreaterThan(-1);
expect(cssText.indexOf('transform-origin: 10.01px 10.01px 10.01px;')).toBeGreaterThan(-1);
expect(
cssText.indexOf('transform: translate3d(10px, 10px, 10px) scale(10.01);')
cssText.indexOf('transform: translate3d(10.01px, 10.01px, 10.01px) scale(10.01);')
).toBeGreaterThan(-1);
} else {
expect("this browser can't test this feature").toBeTruthy();
Expand All @@ -56,7 +56,7 @@ describe('gui.Sprite', function likethis() {
var cssText = this.sandbox.children[0].style.cssText;
expect(cssText.indexOf('left: 20px;')).toBeGreaterThan(-1);
expect(cssText.indexOf('top: 20px;')).toBeGreaterThan(-1);
expect(cssText.indexOf('-ms-transform-origin: 10px 10px;')).toBeGreaterThan(-1);
expect(cssText.indexOf('-ms-transform-origin: 10.01px 10.01px;')).toBeGreaterThan(-1);
expect(cssText.indexOf('-ms-transform: scale(10.01);')).toBeGreaterThan(-1);
} else {
expect("this browser shouldn't test this feature").toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ gui.SpritePlugin = (function() {
var coords = this._pos;
var origin = this._org;
var scaled = parseFloat(this._gro);
var tforms = [coords.x, coords.y, coords.z].map(Math.round);
var offset = [origin.x, origin.y, origin.z].map(Math.round);
var tforms = [coords.x, coords.y, coords.z].map(parseFloat);
var offset = [origin.x, origin.y, origin.z].map(parseFloat);
var plugin = this.spirit.css;
// if (set.reduce(total) === 0) {
// this.reset(); // Should reset to CSS values, not remove them
Expand All @@ -193,8 +193,8 @@ gui.SpritePlugin = (function() {
} else {
var iepos = this._defpos(plugin);
plugin.style({
left: iepos.x + tforms[0] + offset[0],
top: iepos.y + tforms[1] + offset[1],
left: Math.round(iepos.x + tforms[0] + offset[0]),
top: Math.round(iepos.y + tforms[1] + offset[1]),
msTransformOrigin: offset[0] + 'px' + ' ' + offset[1] + 'px',
msTransform: 'scale(' + scaled + ')'
});
Expand Down

0 comments on commit 542d5f6

Please sign in to comment.