Ticket #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: | |
| Blocking: | Blocked by: |
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
comment:2 Changed 3 years ago by addyosmani
- Keywords top left css added
- Priority changed from undecided to low
- Component changed from unfiled to css
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:3 Changed 3 years ago by SlexAxton
- Status changed from new to open
properly setting to 'open'. tsk tsk addy. ;-)
comment:5 Changed 3 years ago by anonymous
$(obj).position() is also reporting incorrectly when $(obj) is hidden.
comment:6 Changed 3 years ago by anonymous
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 2 years ago by svcorp77
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:10 Changed 2 years ago by rwaldron
#8477 is a duplicate of this ticket.
comment:11 Changed 19 months ago by mikesherov
not seeing this issue in 1.7b2 nor latest git. I'm not sure this bug is still valid.
comment:12 Changed 15 months ago by mikesherov
- Status changed from open to closed
- Resolution set to worksforme
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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

JQuery 1.43