views:

279

answers:

1

Hi,

I have two javascript functions.

First one is:

    function gallery(page)
    { 
      $.scrollTo( '#'+page, 1000, '#' );       
    }

The next one is like this:

      window.onscroll = function () 
      {
        makeCallv();    
      }

Here i want to disable window.onscroll function when gallery function is called. And scroll function should be active when function gallery is not called.

Can anyone help me as i am getting this problem for two days. Thanks in advance

+3  A: 

Seems that you are using the scrollTo jQuery plugin, with this plugin you can bind an event that executes when the scrolling animation has ended (onAfter).

You could unbind the window.onscroll event before calling the plugin, and re-bind it when the scrolling animation ends:

function gallery(page) { 
  window.scroll = null; // unbind the event before scrolling
  $.scrollTo( '#'+page, 1000, '#', {onAfter: function () {
      window.onscroll = makeCallv; // bind the event when the animation ends
    }
  });       
}

window.onscroll = makeCallv;
CMS
Was in the process of using this very solution. +1
cpharmston
Thanks CMS. It worked for FF, IE but not for Safari in Mac. Thanks again.