Smooth Scrolling List
One of the features that got cut from 3.0 was "smooth scrolling". List and other list-related classes scroll by row/column which can be a bit choppy at times. We tried to leave the hooks in to allow someone to do it, but we ran out of time to finish the job.
It's too bad we didn't finish the job as there are some difficult things to workaround in trying to get smooth scrolling to work, but I cooked this prototype up to give you a sense for how you might be able to get it working in your apps. Note that the prototype assumes that all rows are the same height. If you have variableRowHeight, that's a whole different problem.
Usual caveats apply, and no, I don't currently have time to make examples for TileList and DataGrid. Maybe some one else will have the time.
Comments
It's a real shame that smooth scrolling didn't make it in. I see it as a big hole in the Flex UI framework considering its graphics/animations roots.
I still don't understand why its such a hard problem... would it not be implemented with just some number of offscreen rows and then a bit of scrollRect math? I even think the caveat that when the user stops scrolling the list "snaps" to a row (like your solution) is a fine compromise.
---------------------
Alex responds:
If you look at the code, you'll see what was "hard". The List classes make lots of assumptions that they are scrolled to integer scrollPositions, and ScrollThumb does as well. Plus, we would have been tasked with making this work for variableRowHeight=true, which would require some much fancier scrolling logic as you wouldn't want to jump by 1/8 of a row for really tall rows or short rows as I do in this example.
Maybe we could have placed restrictions that it wouldn't work for variableRowHeight. BTW, you can probably get rid of the snap-to-row by adding THUMB_POSITION to the THUMB_TRACK case.
Posted by: Troy Gilbert | March 3, 2008 11:45 AM
Are there any plans of adding mouse wheel support?
--------------------
Alex responds:
No plans, but you're welcome to do it and share how you did it.
Posted by: Luke | March 3, 2008 01:59 PM
Thanks for this. The lack of smooth scrolling support is really obvious in cases where row height is high, for example in a TileList with a large itemRenderer. I was able to paste this directly into a component which extended TileList and got the desired behavior, with one bug: when the height of the list is less than the list's rowHeght, the height of the scrollThumb is incorrect. However it is possible that something in my particular implementation is causing that...
------------------------
Alex responds:
Glad it works for TileList. I would not expect things to work correctly if you can't see at least one full row.
Posted by: Josh Santangelo | March 10, 2008 04:48 PM
I am trying to do this horizontally.
var thumb:DisplayObject = horizontalScrollBar.getChildAt(2);
trace(thumb.x);
Any idea why thumb.x keeps returning 0?
Thank you
Posted by: Michael | March 18, 2008 01:24 PM
Well, it is obvious. The scroll bar is rotated. So it is always is thumb.y.
-------------------
Yes it is. List already supports smooth scrolling horizontally. Are you trying to do this for DataGrid or TileList?
Posted by: Michael | March 19, 2008 04:12 AM
Thank you. Currently I am extending TileBase. List already supports smooth scrolling horizontally? How? I have to look a that.
------------------
Alex responds:
List has only one "column" so if you set maxHorizontalScrollPosition, it will scroll by pixel and not by column.
Posted by: Michael | March 25, 2008 02:57 AM
Have tried using this component for a horizontal list, setting columnCount to say 4 and rowCount to 1 - which works on a regular list.
However, it still creates a as many rows as my dataProvider and creates a column with a single item in it on each row 4 columnWidths wide.
Hope that makes sense.
Am I missing something?
---------------------------
Alex responds:
Are you subclassing List or HorizontalList? Someone said they got it working vertically with TileLIst, so you should be able to get to to work horizontally with TileList/HorizontalList
Posted by: Al | April 1, 2008 05:25 PM
I can accept that if clicking on the down or up arrow the list scrolls one item. But what I can't bear is when clicking beneath the scroll bar, it advances one item instead of the # of visible items. Makes for ugly scrolling. Is this difficult to fix or am I missing something?
------------------------------
Alex responds:
I'm not sure what you mean by "beneath the scrollbar". When I run the demo, clicking beneath the thumb advances by a whole page.
Posted by: John | April 3, 2008 05:51 PM
Thanks for the smooth scrolling works very well!
I have one problem with it: I want to zoom into the items of the list... that is working to a certain point by increasing the rowheight. anyway the width of the elements doesn't extend the width of the list itself.
I want them to be a kind of masked... by the bounderies of the list....
-------------------------
Alex responds:
If the scrollbar is up, the width of the renderers is masked at the scrollbar's edge. The renderers can extend beyond that by setting horizontalScrollPolicy="on" and setting maxHorizontalScrollPolicy
Posted by: joerg | April 10, 2008 06:11 AM