javascript - Elements position changing after setting position to absolute -


I have participated in a very strange problem that I have been able to fix, but in a disgusting way.

I have the following working code which captures the element left and up (using MooTools) then it uses setStyles to copy these criteria into the style attribute is. It works all too well.

But as soon as I change the condition of the completion of the code in the code above it, it has to be changed.

Works but horrible:

  var Sortable = new class ({initialize: function (element, container)} {// element and Store its settings Element = element; this.size = element.getSize (); This.position = element.getPosition (container); // Set position element.setStyles ({left: this.position.x, top : This.position.y}) setTimeout (this.goAbsolute.bind (this), 0);}, goAbsolute: function () {this.element.setStyle ('position', 'absolute');}});   

As you can see, I am using an end time to isolate the left / top settings and status settings. The following code does not work. Store

  var Sortable = new class ({initialize: function (element, container) {// element and its settings. Element = element; this.size = Element.getSize (); This.position = element.getPosition (container); // set position element.setStyles ({left: this.position.x, top: this.position.y, position: 'absolute'});}});   

So, we can use it.

  this.size = element.getSize (); For example,   

and size.x will be equal to 100. Then with the line of this couple

  this.size = element.getSize (); Element.setStyle ('position', 'complete');   

Size. X will now equal 0. Although it was set after completion.

I have tried to cloning the object and its

anything seems to work.

Does anyone know how to find similar improvements but without setTimeout ? Or this is the best way.

The way I tried to explain my problem well, but it is a strange thing to comment with any question.

Thank you for any suggestions.

I believe (I'm not sure because you have the float: left Not mentioned) that you have the same problem as you, which I have answered well.

In short, you have to first set top and left on all the elements. After doing this, set position: full on all the elements.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -