Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jQuery mystery issue

Featured Replies

It's the intervals queueing up.

 

You need to assign all the intervals to the same var, so var timeout = setTimeOut(...);

 

If that doesn't work try a callback function on the jqeury animate which basically sets a alreadyrunning variable to true and when it ends to false.

 

Also append queue:false into the jquery options (for animate)

  • Author

Hey

 

Thanks for the input.

 

So, the functions in each of the timeouts each "show()" a different element so how can I use one var for all?

 

Also, I'm not 100% certain about what you meant about "ry a callback function on the jqeury animate". Could you please elaborate a bit? (jQuery Newbie here!)

 

Thanks!

 

G

jQuery('selector').animate({params}, speed, callback);

 

for your callback you can put either a function name, or something like

 

function() { alert("reached my callback"); }

 

 

Hope this helps!

Hey

 

Thanks for the input.

 

So, the functions in each of the timeouts each "show()" a different element so how can I use one var for all?

 

Also, I'm not 100% certain about what you meant about "ry a callback function on the jqeury animate". Could you please elaborate a bit? (jQuery Newbie here!)

 

Thanks!

 

G

 

As ChristopherDarling says just link it to an external function rather than using a callback function.

 

 

E.g.

 


var intervalRunning = false;

function intervalStart(obj)
{
   intervalRunning = true;
}
function intervalEnd(ob)
{
   intervalRunning = false;
}

 

You would then do a check before using jquery animate.

 

e.g. if(userClicksThis && !intervalRunning) { // run here (jquery animate }

 

 

 

So heres something i haven't tested...

 

$(function(){
$('.hidden').css({'position': 'relative', 
                   'right': '-650px'});

$('.disp-none').css('display', 'none');

var $xhtml_a = $('#xhtml-a');
var $desc = $('#descriptions');
var $visibleChildren = $('#descriptions').children();
var $xhtml_p = $('#xhtml');
var $css_p = $('#css');
var $jquery_p = $('#jquery');
var $drupal_p = $('#drupal');		
var anchors = $('#languages a');
var intervalRunning = false;

$('.toggle-definition').click(function(){					       
   var this_id = $(this).attr('id');
   anchors.removeClass('active');
   $(this).addClass('active')
   $visibleChildren.fadeOut(500, function(){$(this).css('right', '-650px') });			  


   if(this_id == 'xhtml-a' && !intervalRunning){
       intervalStart();
       setTimeout(function(){$xhtml_p.show().animate({'right': '0'}, 1000); }, 600,intervalEnd());						
   }
   else if (this_id == 'css-a' && !intervalRunning){
       intervalStart();
       setTimeout(function(){$css_p.show().animate({'right': '0'}, 1000); }, 600,intervalEnd());	
   }
   else if (this_id == 'jquery-a' && !intervalRunning){
       intervalStart();
       setTimeout(function(){$jquery_p.show().animate({'right': '0'}, 1000); }, 600,intervalEnd());	
   }

   else if (this_id == 'drupal-a' && !intervalRunning){
       intervalStart();
       setTimeout(function(){$drupal_p.show().animate({'right': '0'}, 1000); }, 600,"",intervalEnd());	
   }
   return false;
});




function intervalStart()
{
   intervalRunning = true;
}
function intervalEnd()
{
   intervalRunning = false;
}

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.