Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix failing spinner ui test

fix rounding of pixel decimals in chrome
Fixes spec for opera (scrolling issue)
  • Loading branch information...
commit 57b4afd20b9c75e6149b932f71ebe129f1c4a141 1 parent 2658339
@fat fat authored
View
8 Source/Element/Element.Position.js
@@ -97,7 +97,7 @@ var local = Element.Position = {
},
getPosition: function(element, options){
- var position = {position: 'absolute'};
+ var position = {};
options = local.getOptions(element, options);
var relativeTo = document.id(options.relativeTo) || document.body;
@@ -188,14 +188,14 @@ var local = Element.Position = {
case 'left': edgeOffset.x = 0; break;
case 'right': edgeOffset.x = -dimensions.x - dimensions.computedRight - dimensions.computedLeft; break;
// center
- default: edgeOffset.x = -(dimensions.totalWidth / 2); break;
+ default: edgeOffset.x = -(Math.round(dimensions.totalWidth / 2)); break;
}
switch(edge.y){
case 'top': edgeOffset.y = 0; break;
case 'bottom': edgeOffset.y = -dimensions.y - dimensions.computedTop - dimensions.computedBottom; break;
// center
- default: edgeOffset.y = -(dimensions.totalHeight / 2); break;
+ default: edgeOffset.y = -(Math.round(dimensions.totalHeight / 2)); break;
}
position.x += edgeOffset.x;
@@ -222,7 +222,7 @@ Element.implement({
if (options && (options.x != null || options.y != null)) {
return (original ? original.apply(this, arguments) : this);
}
- var position = this.calculatePosition(options);
+ var position = this.setStyle('position', 'absolute').calculatePosition(options);
return (options && options.returnPos) ? position : this.setStyles(position);
},
View
10 Specs/1.3/Element/Element.Position.js
@@ -12,6 +12,7 @@ describe("Element.Position", function(){
options;
beforeEach(function(){
+ window.scroll(0,0); //calculations are based off of zero scroll unless otherwise set
options = {};
element = new Element('div').inject(document.body);
});
@@ -42,7 +43,6 @@ describe("Element.Position", function(){
var position = element.position(options);
expect(position.left).not.toEqual(null);
expect(position.top).not.toEqual(null);
- expect(position.position).not.toEqual(null);
});
});
@@ -122,7 +122,7 @@ describe("Element.Position", function(){
placements.each(function(placement){
it(testVerbage(placement, edge, blockPosition, where), function(){
- setup(position, element, options);
+ setup(blockPosition, element, options);
element.inject(container, where);
options.position = placement;
options.relFixedPosition = blockPosition == 'fixed';
@@ -168,6 +168,12 @@ describe("Element.Position", function(){
});
+ it('should return the correct position of an element not positioned with css', function(){
+ var foo = new Element('div').adopt(new Element('div', {styles: {width: 10}})).inject(document.body);
+ expect(element.position({returnPos: true, relativeTo: document.body}).left).not.toEqual(0);
+ foo.destroy();
+ });
+
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.