Is there any way to do two (or more) $(''element'').setStyle changes atomically? I''m trying to do a Tab control, where one <div> is hidden as another appears, but I occasionally get flickering when (for a split second) both <div> elements are visible simultaneously. My calls are: -- div1.setStyle({height: div2.getHeight()+''px''}); -- div2.setStyle({height: 0}); For reasons specific to my code, I can''t use "display:none" to make it invisible; I have to use height. But sometimes, right in between these commands, both div1 & div2 occupy space in the document flow, causing the page to flicker. If I were simply to reverse the commands, then it will flicker in the other direction, so that won''t help, unfortunately. Any help would be greatly appreciated. Thanks, Jonathan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
By the way, I''m using standard Prototype and Scriptaculous for this (I forgot to make that clear before) On Oct 25, 7:57 pm, Jonathan <jonsol...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is there any way to do two (or more) $(''element'').setStyle changes > atomically? I''m trying to do a Tab control, where one <div> is hidden > as another appears, but I occasionally get flickering when (for a > split second) both <div> elements are visible simultaneously. > > My calls are: > -- div1.setStyle({height: div2.getHeight()+''px''}); > -- div2.setStyle({height: 0}); > > For reasons specific to my code, I can''t use "display:none" to make it > invisible; I have to use height. But sometimes, right in between these > commands, both div1 & div2 occupy space in the document flow, causing > the page to flicker. If I were simply to reverse the commands, then it > will flicker in the other direction, so that won''t help, > unfortunately. > > Any help would be greatly appreciated. > > Thanks, > Jonathan--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Oct 26, 9:57 am, Jonathan <jonsol...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is there any way to do two (or more) $(''element'').setStyle changes > atomically? I''m trying to do a Tab control, where one <div> is hidden > as another appears, but I occasionally get flickering when (for a > split second) both <div> elements are visible simultaneously. > > My calls are: > -- div1.setStyle({height: div2.getHeight()+''px''}); > -- div2.setStyle({height: 0});I don''t think you can expect a general library to support such a specialised need. I takes a few moments to write your own (very simple) function, something like: function swapHeights(el1, el2) { el1.setStyle(...); el2.setStyle(...) } or maybe you''d like to extend Element.methods. -- Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
My question, I guess, is whether there''s a way to make multiple calls to setStyle before any of them take effect. Essentially, I want the next browser update to have the results of both changes. I do not want to permit the browser to update in between (after the first but before the second). I''m not looking for something specific to my needs, for setting the Height specifically. I''m just wondering if there''s any way to solve this general problem. On Oct 26, 5:07 am, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> On Oct 26, 9:57 am, Jonathan <jonsol...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Is there any way to do two (or more) $(''element'').setStyle changes > > atomically? I''m trying to do a Tab control, where one <div> is hidden > > as another appears, but I occasionally get flickering when (for a > > split second) both <div> elements are visible simultaneously. > > > My calls are: > > -- div1.setStyle({height: div2.getHeight()+''px''}); > > -- div2.setStyle({height: 0}); > > I don''t think you can expect a general library to support such a > specialised need. I takes a few moments to write your own (very > simple) function, something like: > > function swapHeights(el1, el2) { > el1.setStyle(...); > el2.setStyle(...) > > } > > or maybe you''d like to extend Element.methods. > > -- > Rob--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Oct 27, 6:19 am, Jonathan <jonsol...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> My question, I guess, is whether there''s a way to make multiple calls > to setStyle before any of them take effect.Yes, exactly as shown.> Essentially, I want the > next browser update to have the results of both changes. I do not want > to permit the browser to update in between (after the first but before > the second).Browsers will not update the UI until the function ends. Any flickering that you see may be the result of other scripts running while the browser is trying to update, hence the flickering. You can only fix that by changing when the other scripts run, not the style setting function itself.> I''m not looking for something specific to my needs, for setting the > Height specifically. I''m just wondering if there''s any way to solve > this general problem.In that case, you need to look deeper into what scripts (and other UI updates) are running after the one that attempts to set the style changes.> On Oct 26, 5:07 am, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote: > > On Oct 26, 9:57 am, Jonathan <jonsol...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:I wish people here would not top-post. -- Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---