Jump to content
GreenSock

bromel

scrolling an object using buttons (onPress)

Go to solution Solved by Diaco,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Good evening All
 
I have created a modal info box for which I had added the Draggable and scrollTo plugin for some added functionality. I am trying to do 2 things.
1. At the moment when you press either the 'up or down' button you get an incremental tween.
2. I am wanting to control the scroll by making it so that when either button is pressed and held down the scroll will smoothly move in the direction that you have pressed.
 
I am not sure if this more a JS question since it would depend on the function used to make the call. I did come across this fiddle on my travels which works to an extent.

var timeout, clicker = $('#clicker');

clicker.mousedown(function(){
    timeout = setInterval(function(){
        // Do something continuously 
    }, 500);

    return false;
});

$(document).mouseup(function(){
    clearInterval(timeout);
    return false;
});

I am wonder what would be the best way to approach this. Any ideas or suggestions most welcome.

 

regards

 

bromel

See the Pen azzrZa by w9914420 (@w9914420) on CodePen

Edited by bromel
Link to comment
Share on other sites

  • Solution

Hi bromel  :)

 

try this :

Draggable.create(content, {
type:"ScrollTop",
bounds:content,
edgeResistance:0.65
});

function scrl(Y){
TweenMax.to(content, 1, {scrollTo:{y:Y},ease:Linear.easeNone,onComplete:scrl,onCompleteParams:[Y]})
}

$("#up").mousedown(function() { scrl("+=100");  });
$("#down").mousedown(function() { scrl("-=100"); });
$("#up,#down").mouseup(function() { TweenMax.killTweensOf(content); });

See the Pen jEPqjz by anon (@anon) on CodePen

  • Like 1
Link to comment
Share on other sites

Hi Diaco.AW

 

Many, many thanks :)

 

I very much appreciate your time on this, plus you have given me something to study and ponder on.

 

regards

 

bromel

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×