0

I use this jquery plugin: http://tympanus.net/codrops/2013/03/29/quotes-rotator/ Here is JSFiddle: http://jsfiddle.net/LmuR7/

This is my settings(also there are some options but don't know how to use it):

      <script src="js/jquery.cbpQTRotator.min.js">
      </script>
      <script>
        $( function () {
          /*

            - how to call the plugin:
            $( selector ).cbpQTRotator( [options] );
            - options:
            {
                // default transition speed (ms)
                speed : 700,
                // default transition easing
                easing : 'ease',
                // rotator interval (ms)
                interval : 8000
            }
            - destroy:
            $( selector ).cbpQTRotator( 'destroy' );
            */


           $( '#cbp-qtrotator' ).cbpQTRotator();


         }
          );
       </script>

How can I stop code if it scrolled to top and start if it scrolled down?

2 Answers2

0

Use this:

$(window).scroll(function() {
  var currentScroll = $(this).scrollTop();
  if ( currentScroll <= 0 ) {
      $( selector ).cbpQTRotator( 'destroy' );
  } else {
      $('#cbp-qtrotator').cbpQTRotator();
  }
});
Barlas Apaydin
  • 7,233
  • 11
  • 55
  • 86
  • It stops code when is scroll on top but I need to run code when is on top... Here is also demo of program, I need qvote stop changing if scroll not on the top...http://tympanus.net/Blueprints/QuotesRotator/ – user3561857 Sep 29 '14 at 07:07
  • @user3561857 i don't think this plugin has a stop or pause option. – Barlas Apaydin Sep 29 '14 at 07:25
  • Here are options but don't know how to use: /* - how to call the plugin: $( selector ).cbpQTRotator( [options] ); - options: { // default transition speed (ms) speed : 700, // default transition easing easing : 'ease', // rotator interval (ms) interval : 8000 } - destroy: */Also I added JSFiddle up – user3561857 Sep 29 '14 at 07:44
0

Try this ...

<script>
        var lastScrollTop = 0;
        $(window).scroll(function(event){
           var scrollTop = $(this).scrollTop();
           if (scrollTop > lastScrollTop){
             $('#cbp-qtrotator').cbpQTRotator();
             console.log("construct");
           } else {
             $('#cbp-qtrotator').cbpQTRotator('destroy');
             console.log("destruct");
           }
           lastScrollTop = scrollTop;
       });
</script>

Ref: How can I determine the direction of a jQuery scroll event?

Community
  • 1
  • 1
Manoj Namodurai
  • 529
  • 2
  • 7