Jump to content
Search Community

Adding a scroll bar to a text field?

CueTable test
Moderator Tag

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

Hello and Welcome to the GreenSock Forums..

 

you can add the css overflow property:

 

See the Pen eEvcd by jonathan (@jonathan) on CodePen


 

div {
       overflow:auto;
}

make sure you add a width and definitely a height to your div so the browser can render the scroll bars

 

https://developer.mozilla.org/en-US/docs/Web/CSS/overflow

 

you might have to play with the width so you don't get horizontal scroll bars

 

overflow-x and overlfow-y might need a vendor prefix due to the fact that they are experimental css properties that are not supported the same in all browsers

 

:)

Link to comment
Share on other sites

Hi,

 

A few days ago amar posted a similar question and looking and experimenting a little bit with this JQuery plugin:

http://manos.malihu.gr/jquery-custom-content-scroller/

 

The results with Draggable aren't very good. That particular plugin works with the left or top property of the content container, while the parent of that one has an overflow:hidden property. When the Draggable instance was set to work with either of those properties the content container did moved, but the custom scrollbar didn't, then when you drag the scrollbar the content goes back to the position it had before being dragged with GSAP.

 

The issue is that the plugin uses it's own code to record the property based on the different scroll events (keys and mouse wheel) but not external ones. The funny thing is that GSAP's Draggable  does respect the current inline style, so if you drag the custom scrollbar and then you use Draggable to move the content you don't get any strange behaviour.

 

One choice could be look and tweak the plugin's code and try to associate the current inline value instead of the recorded one, in order to make it work with Draggable. That could turn into quite a chore considering the fact that you'll need to read and interpret the code in order to make the necessary changes. The second alternative is to create your own scroll/draggable system using only GSAP and your custom graphic base, personally I'd choose this one, for consistency and animation efficiency reasons, GSAP is so much better than JQuery in animation every day of the week and twice every day of the week again :D

 

You'll have to test the other plugins Jonathan posted in order to see how they work with Draggable.

 

Best,

Rodrigo.

  • Like 1
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.
×
×
  • Create New...