[solved] Developing slider(flickering problem)

here you will find only solved 1.1 Help topics

Moderator: 1.1 Moderators

[solved] Developing slider(flickering problem)

Postby xmen on Fri Oct 09, 2009 6:48 am

I've a div on right side of page, so I want when I hover mouse on it. It should get expand. So I coded like this


  1.        function onHover() {
  2.             var divS = document.getElementById("containerMailDiv");
  3.             var curr_width = parseInt(divS.style.width);
  4.             var myEffects = new Fx.Styles('containerMailDiv', { duration: slideDuration, transition: Fx.Transitions.linear });
  5.             myEffects.custom({
  6.                 'width': [curr_width, 100],
  7.                 'opacity': [0, 1]
  8.             });
  9.         }
  10.        
  11.         function onOut() {
  12.             var divS = document.getElementById("containerMailDiv");
  13.             var curr_width = parseInt(divS.style.width);
  14.             var myEffects = new Fx.Styles('containerMailDiv', { duration: slideDuration, transition: Fx.Transitions.linear });
  15.             myEffects.custom({
  16.                 'width': [100, 20]
  17.             });
  18.         }


now when I over mouse on it, It flicks too much...

any help ?
xmen
 
Posts: 5
Joined: Fri Oct 09, 2009 6:41 am

Re: Developing slider(flickering problem)

Postby wowenkho on Fri Oct 09, 2009 6:56 am

moved to MooTools 1.1 Help, since it apparently uses MooTools 1.1 classes.

i think the reason why you've got your animation flicker like crazy is because your 2 Fx.Styles declarations fight themselves out over a single element. good practice when it comes to these kinds of stuff is to declare just a single Fx.Styles class instance outside of those functions and manipulating that single instance instead. also, another thing you could try is to add the option "link":"cancel" or "wait":false in the Fx.Styles instance.
my sword is yours...
http://wowenkho.com

for those who want to talk with me quicker, add me on Yahoo! Messenger through my ID: michaelapeles
User avatar
wowenkho
mootools freak
 
Posts: 1146
Joined: Sat Aug 15, 2009 10:38 am
Location: Antipolo City, Philippines

Re: Developing slider(flickering problem)

Postby xmen on Fri Oct 09, 2009 11:34 am

Okay, I tried to declare it above functions but Im getting null error.

like this
  1. var myEffects = new Fx.Styles('containerMailDiv', { link: "cancel", wait: false, duration: slideDuration, transition: Fx.Transitions.linear });
  2.         function onHover() {
  3.             clearInterval(interValID);
  4.             var divS = document.getElementById("containerMailDiv");
  5.             var curr_width = parseInt(divS.style.width);
  6.            
  7.             myEffects.custom({
  8.                 'width': [curr_width, 100],
  9.                 'opacity': [0, 1]
  10.             });
  11.         }
  12.  
  13.         function onOut() {
  14.             var divS = document.getElementById("containerMailDiv");
  15.             var curr_width = parseInt(divS.style.width);
  16.            
  17.             myEffects.custom({
  18.                 'width': [100, 20]
  19.             });
  20.         }


so I tried this

  1.        function onHover() {
  2.  
  3.             var divS = document.getElementById("containerMailDiv");
  4.             var curr_width = parseInt(divS.style.width);
  5.             var myEffects = new Fx.Styles('containerMailDiv', { link: "cancel", wait: false, duration: slideDuration, transition: Fx.Transitions.linear });
  6.             myEffects.custom({
  7.                 'width': [curr_width, 100],
  8.                 'opacity': [0, 1]
  9.             });
  10.         }
  11.  
  12.         function onOut() {
  13.             var divS = document.getElementById("containerMailDiv");
  14.             var curr_width = parseInt(divS.style.width);
  15.             var myEffects = new Fx.Styles('containerMailDiv', { link: "cancel", wait: false, duration: slideDuration, transition: Fx.Transitions.linear });
  16.             myEffects.custom({
  17.                 'width': [100, 20]
  18.             });
  19.         }


it works sometimes good onOver but never in onOut
xmen
 
Posts: 5
Joined: Fri Oct 09, 2009 6:41 am

Re: Developing slider(flickering problem)

Postby xmen on Fri Oct 09, 2009 5:29 pm

Okay, I get it working...Simply checking div width before doing animation
xmen
 
Posts: 5
Joined: Fri Oct 09, 2009 6:41 am


Return to Solutions

Who is online

Users browsing this forum: No registered users and 1 guest