Restoring deleted ScrollView feature: endedScroll event

Back in the glory days of the earlier incarnation of Corona’s widget library, we had a ScrollView widget that would generate wonderful “endedScroll” events, as you can see mentioned here in the migration guide to widgets 2.0:

http://docs.coronalabs.com/api/library/widget/migration.html

The key point is that the old endedScroll event would trigger after the ScrollView was flicked and *actually finished scrolling*. This is no longer the case with widgets 2.0. That functionality has been deleted. The new event is called “ended” and it fires when the finger is lifted from the screen. Depending on a bunch of factors including friction, scrolling might continue for an extra few seconds. 

Unfortunately now, with widgets 2.0, there’s no way for the app to know when that scrolling is complete.

This is where someone comes back to me and say “Well, add it to the open-source widget library on Github and stop whining!” Well, I did. It’s only a line or two of code. But the problem with that approach is that the Github code (https://github.com/coronalabs/framework-widget/blob/master/widgetLibrary/widget_scrollview.lua) is at least a month old, so I don’t benefit from more recent bug fixes in the daily builds. Or, perhaps more importantly, future ones.

Is there any reason this deleted functionality can’t be restored in the daily builds and made part of the core widget library? I’d imagine it would take less than 5 minutes to do and would be useful for those of us creating something other than games…

There is a new event.phase that tells you when you have reached the end actually. You can even get things like scroll direction etc. Check out the ScrollView sample. Here’s the listener from that sample. Hope this helps. 

-- Our ScrollView listener local function scrollListener( event ) local phase = event.phase local direction = event.direction if "began" == phase then --print( "Began" ) elseif "moved" == phase then --print( "Moved" ) elseif "ended" == phase then --print( "Ended" ) end -- If the scrollView has reached it's scroll limit if event.limitReached then if "up" == direction then print( "Reached Top Limit" ) elseif "down" == direction then print( "Reached Bottom Limit" ) elseif "left" == direction then print( "Reached Left Limit" ) elseif "right" == direction then print( "Reached Right Limit" ) end end return true end

Thanks, ksan, but the event.phase == “Ended” you’re referring to is the same “Ended” event I’m referring to in my post. It eliminates functionality that existed in the earlier widgets library, and does not tell you when the animation is complete. Put another way, event.phase only tells you when the *touch* is over, not when the *scrolling animation* is over. These are very different things that could be seconds apart.

It would be nice to hear from one of our esteemed Corona reps – who must get paid quite a bit to deal with our incessant complaints here on the forums. :slight_smile:

Ah I see what you mean. I wasn’t thinking of “ended” but I was thinking of event.limitReached (see below) but then again that also requires you to lift your finger to fire. 

if event.limitReached then
        if “up” == direction then
            print( “Reached Top Limit” )

Well, you know what CL will say about this. I share your frustration. 

Yep. FYI I’ve added it to the Corona SDK Widget 2.0 bugs spreadsheet (row 28):

https://docs.google.com/spreadsheet/ccc?key=0AsuRVbWElS3YdGpCN0V3emtmWnlwQmRUOVlpb3RkOGc&usp=sharing#gid=0

I would submit it as a bug report but it’s more of a deleted-feature-please-restore-it report…

Well, I’m with you on this one. I would consider it a bug as well. It is an age old industry practice to announce features that are planned to be taken out as “deprecated” and then still support them for a while and then eventually drop them. CL dropped many features in the past without any notice. I was happy to see they didn’t do it with Storyboard --> Composer this time. A change for the better.

I’m seeing a user maintained branch of the widgets in the near future :smiley:

Atanas is already there with his mods. We just have to consolidate our efforts and hope that the official branch gets a bit more frequent updates on github so we can use what corona has fixed or improved aswell.

Perhaps anyone who contributes useful code to this user-maintained branch of the widgets library should get a free Corona subscription or shares of Corona Labs Inc.? :slight_smile:

I’m generally in favor of open source development, but it seems odd to devote my time and copyrighted code to propping up the obvious fundamentals – properly scrolling text and graphics! – of a proprietary development environment…

Just realized how much I miss this from G1.0. It would be great to have this added back in. Super useful to pause timers and transitions when you start scrolling and then resume once the scroll animation is complete.

You know you can make a pull request from github, add your changes and submit them back for inclusion in the core library.  If it’s something practical and makes sense, we can include it in the main library.  That’s part of what making the library open source is about.

Rob

Rob, we tried that. Atanas and I submitted a number of smaller mods to test the waters and none of them are accepted so far. Not sure why. Can you kindly check to see if there is a reason for this so we know and don’t waste our energy anymore? Thanks

So any update on this?

Naveen: No update that I’m aware of. Rob, what say you? Can you folks restore this deleted functionality in a daily build sometime this month?

Also I just noticed that the Scrollview in the open-source widget library on Github (https://github.com/coronalabs/framework-widget) has actually not been updated since October 29.

If those of us who need the deleted functionality use the October version, we miss out on other changes and bug fixes to the Scrollview widget since then, including the scrollView:setIsLocked() method added on December 20, the November 22 changes that fix transitions, the November 20 changes that fix event.phase, the November 13 addition of the scrollBarAutoHide property, etc.

Rob?

I thought the scrollView in GitHub along with all else was synched to Corona build # 2114 which is about 6 weeks old now. See https://github.com/coronalabs/framework-widget/tree/master/widgetLibrary

@corona273, if you need it sooner than later, your best bet is to pick up the Widget Library from github and look to add that feature back in.  But at the risk of bringing the wrath of the users down upon me…

Just keep in mind, that as useful as Kerem’s spreadsheet is, it doesn’t generate engineering tasks.  We would need a bug report or feature request in our tracking systems before the work would even be considered.

I would go ahead and file a bug report on it, but given the current workload, it might be faster with the open source.

Rob

There is a new event.phase that tells you when you have reached the end actually. You can even get things like scroll direction etc. Check out the ScrollView sample. Here’s the listener from that sample. Hope this helps. 

-- Our ScrollView listener local function scrollListener( event ) local phase = event.phase local direction = event.direction if "began" == phase then --print( "Began" ) elseif "moved" == phase then --print( "Moved" ) elseif "ended" == phase then --print( "Ended" ) end -- If the scrollView has reached it's scroll limit if event.limitReached then if "up" == direction then print( "Reached Top Limit" ) elseif "down" == direction then print( "Reached Bottom Limit" ) elseif "left" == direction then print( "Reached Left Limit" ) elseif "right" == direction then print( "Reached Right Limit" ) end end return true end

Thanks, ksan, but the event.phase == “Ended” you’re referring to is the same “Ended” event I’m referring to in my post. It eliminates functionality that existed in the earlier widgets library, and does not tell you when the animation is complete. Put another way, event.phase only tells you when the *touch* is over, not when the *scrolling animation* is over. These are very different things that could be seconds apart.

It would be nice to hear from one of our esteemed Corona reps – who must get paid quite a bit to deal with our incessant complaints here on the forums. :slight_smile:

Ah I see what you mean. I wasn’t thinking of “ended” but I was thinking of event.limitReached (see below) but then again that also requires you to lift your finger to fire. 

if event.limitReached then
        if “up” == direction then
            print( “Reached Top Limit” )

Well, you know what CL will say about this. I share your frustration. 

Yep. FYI I’ve added it to the Corona SDK Widget 2.0 bugs spreadsheet (row 28):

https://docs.google.com/spreadsheet/ccc?key=0AsuRVbWElS3YdGpCN0V3emtmWnlwQmRUOVlpb3RkOGc&usp=sharing#gid=0

I would submit it as a bug report but it’s more of a deleted-feature-please-restore-it report…