![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
(...) On the complex page, when you click on "200", then "div1" overlaps "div2" until you resize the browser a little bit. And when you click on "50", you see "div2" is left hanging further down until you resize the browser a little. |
#2
| |||
| |||
|
|
On Oct 3, 5:07 pm, Stevo <n... (AT) mail (DOT) invalid> wrote: (...) On the complex page, when you click on "200", then "div1" overlaps "div2" until you resize the browser a little bit. And when you click on "50", you see "div2" is left hanging further down until you resize the browser a little. try this: function resizenow (x) { var s= document.getElementById("div1_inner").style; s.height= x+"px"; s.display= "none"; setTimeout(function () { s.display= ""; },1); }; -- Jorge. |
#3
| |||
| |||
|
|
Thanks Jorge, I'll give that a try. It might produce an undesirable flicker, but if it works, it at least might lead to another potential solution. Perhaps I can add another 1 pixel high DIV in between div1 and div2 and toggle that one's display property. |
#4
| |||
| |||
|
|
On Oct 3, 5:07*pm, Stevo <n... (AT) mail (DOT) invalid> wrote: (...) On the complex page, when you click on "200", then "div1" overlaps "div2" until you resize the browser a little bit. And when you click on "50", you see "div2" is left hanging further down until you resize the browser a little. try this: function resizenow (x) { * var s= document.getElementById("div1_inner").style; * s.height= x+"px"; * s.display= "none"; * setTimeout(function () { * * * s.display= ""; * },1); }; |
#5
| |||
| |||
|
|
Le 10/3/08 7:03 PM, Stevo a crit : Thanks Jorge, I'll give that a try. It might produce an undesirable flicker, but if it works, it at least might lead to another potential solution. Perhaps I can add another 1 pixel high DIV in between div1 and div2 and toggle that one's display property. an other soluce could be : function resizenow(x){ * *var d = document.getElementById("div1_inner"); * *var c = d.cloneNode(true); * *c.style.height=x+"px"; * *d.parentNode.replaceChild(c,d); } Not tested. |
#6
| |||
| |||
|
|
On Oct 3, 5:07*pm, Stevo <n... (AT) mail (DOT) invalid> wrote: (...) On the complex page, when you click on "200", then "div1" overlaps "div2" until you resize the browser a little bit. And when you click on "50", you see "div2" is left hanging further down until you resize the browser a little. try this: function resizenow (x) { * var s= document.getElementById("div1_inner").style; * s.height= x+"px"; * s.display= "none"; * setTimeout(function () { * * * s.display= ""; * },1); }; |
#7
| |||
| |||
|
|
Le 10/3/08 7:03 PM, Stevo a crit : Thanks Jorge, I'll give that a try. It might produce an undesirable flicker, but if it works, it at least might lead to another potential solution. Perhaps I can add another 1 pixel high DIV in between div1 and div2 and toggle that one's display property. an other soluce could be : function resizenow(x){ * *var d = document.getElementById("div1_inner"); * *var c = d.cloneNode(true); * *c.style.height=x+"px"; * *d.parentNode.replaceChild(c,d); } Not tested. |
#8
| |||
| |||
|
|
On Oct 3, 9:34*pm, Jorge <jo... (AT) jorgechamorro (DOT) com> wrote: try this: function resizenow (x) { * var s= document.getElementById("div1_inner").style; * s.height= x+"px"; * s.display= "none"; * setTimeout(function () { * * * s.display= ""; * },1); }; Though it might just work, can I ask the reasoning behind this workaround? Is this is a known issue or does putting everything in setTimeout always seems to solve the issue? ;-) |
#9
| |||
| |||
|
|
On Oct 4, 7:35*am, sasuke <database... (AT) gmail (DOT) com> wrote: On Oct 3, 9:34*pm, Jorge <jo... (AT) jorgechamorro (DOT) com> wrote: try this: function resizenow (x) { * var s= document.getElementById("div1_inner").style; * s.height= x+"px"; * s.display= "none"; * setTimeout(function () { * * * s.display= ""; * },1); }; Though it might just work, can I ask the reasoning behind this workaround? Is this is a known issue or does putting everything in setTimeout always seems to solve the issue? ;-) Hehe. What happens is that the the page isn't rendered until after the JS code has finished executing (except in chrome). Therefore, a way to force a redraw in the middle of some code, is to break it up in two halves, let the first half end and schedule the second half to run some ms later via a setTimeout(). |
#10
| |||
| |||
|
|
On Oct 6, 12:16*am, Jorge <jo... (AT) jorgechamorro (DOT) com> wrote: On Oct 4, 7:35*am, sasuke <database... (AT) gmail (DOT) com> wrote: On Oct 3, 9:34*pm, Jorge <jo... (AT) jorgechamorro (DOT) com> wrote: try this: function resizenow (x) { * var s= document.getElementById("div1_inner").style; * s.height= x+"px"; * s.display= "none"; * setTimeout(function () { * * * s.display= ""; * },1); }; Though it might just work, can I ask the reasoning behind this workaround? Is this is a known issue or does putting everything in setTimeout always seems to solve the issue? ;-) Hehe. What happens is that the the page isn't rendered until after the JS code has finished executing (except in chrome). Therefore, a way to force a redraw in the middle of some code, is to break it up in two halves, let the first half end and schedule the second half to run some ms later via a setTimeout(). Fair enough, but how does this scenario apply to the original post? In the very first post, the function `resizenow(x)' exits soon after setting the height to `x' pixels, so ideally the change should be reflected immediately [and yes, it does, except in FF2]. So the only reason here would be that the refresh isn't happening. So to trigger a refresh, after setting the required dimensions, we hide and show the DIV, with the only different thing being the showing of DIV be placed in a `setTimeout'. Am I correct here? |
![]() |
| Thread Tools | |
| Display Modes | |
| |