#7305 closed bug (worksforme)
Cant retrive current left and top css when $(obj) is hidden
Reported by: | svcorp77 | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | css | Version: | 1.5 |
Keywords: | top left css | Cc: | |
Blocked by: | Blocking: |
Description
var winObj = $('<div>Left AND Top set to Zero</div>')
.hide()
.appendTo('body')
.css({
width : 100,
height : 100,
left : '100px',
top : '100px',
position : 'absolute',
opacity : 0
}).animate({
width : 420,
height : 150,
opacity : 1,
left : ($(window).width() / 2 - 210) + 'px',
top : Math.round($(window).height() / 5) + 'px'
}, 450, function() {
console.log('animation complete');
console.log(winObj.attr('style'));
console.log(winObj.css('left'));
console.log(winObj.css('top'));
});
console.log(winObj.attr('style'));
console.log(winObj.css('left'));
console.log(winObj.css('top'));
display: none; width: 100px; height: 100px; left: 0px; top: 0px; position: absolute; opacity: 0; overflow: hidden;
0px
0px
animation complete
display: none; width: 420px; height: 150px; left: 741.5px; top: 117px; position: absolute; opacity: 1;
0px
0px
JQuery 1.43Pre display it correctly.
Change History (12)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Component: | unfiled → css |
---|---|
Keywords: | top left css added |
Priority: | undecided → low |
See http://jsfiddle.net/addyosmani/F9LKa/
The 1.4.2 output of your code is:
display: block; width: 100px; height: 100px; left: 100px; top: 100px; position: absolute; opacity: 0; overflow: hidden; 100px 100px animation complete display: block; width: 420px; height: 150px; left: 38px; top: 97px; position: absolute; opacity: 1; 38px 97px
The 1.4.3 output is:
display: none; width: 100px; height: 100px; left: 0px; top: 0px; position: absolute; opacity: 0; overflow: hidden; 0px 0px animation complete display: none; width: 420px; height: 150px; left: 38px; top: 97px; position: absolute; opacity: 1; 0px 0px
And the Current Git Version output is:
display: none; width: 100px; height: 100px; left: 0px; top: 0px; position: absolute; opacity: 0; overflow: hidden; 0px 0px animation complete display: none; width: 420px; height: 150px; left: 38px; top: 97px; position: absolute; opacity: 1; 0px 0px
On first glances, this may be related to #7225, but as we've closed that as fixed and your code is currently not working using that fix, I'm leaving open for further review.
comment:5 Changed 13 years ago by
$(obj).position() is also reporting incorrectly when $(obj) is hidden.
comment:6 Changed 13 years ago by
And on a final note, a workaround is doable as so, though not optimal.
$(obj).toggle(); var top = $(obj).css("top"); $(obj).toggle();
comment:7 Changed 12 years ago by
Here is solution for:
jQuery JavaScript Library v1.5, string 7610, function jQuery.fx.prototype.update
jQuery version > 1.4.3: the same mods.
// Set display property to block for height/width animations if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) { this.elem.style.display = "block"; }
Please, make this changes next update.
comment:8 Changed 12 years ago by
Milestone: | → 1.next |
---|---|
Version: | 1.4.3 → 1.5 |
comment:11 Changed 12 years ago by
not seeing this issue in 1.7b2 nor latest git. I'm not sure this bug is still valid.
comment:12 Changed 11 years ago by
Resolution: | → worksforme |
---|---|
Status: | open → closed |
I can no longer reproduce this bug. Since no new reports have come in, I'm considering this closed. Please reopen with a repro case if you feel this is an error.
JQuery 1.43