Bug Tracker

Modify

Ticket #7305 (closed bug: worksforme)

Opened 3 years ago

Last modified 2 years ago

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:1 Changed 3 years ago by anonymous

JQuery 1.43

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:4 Changed 3 years ago by anonymous

Confirmed, this happed to me too. v1.4.4

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 3 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:8 Changed 3 years ago by jitter

  • Version changed from 1.4.3 to 1.5
  • Milestone set to 1.next

comment:9 Changed 3 years ago by jitter

#8167 is a duplicate of this ticket.

comment:10 Changed 3 years ago by rwaldron

#8477 is a duplicate of this ticket.

comment:11 Changed 3 years 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 2 years 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.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.