Can you Insert a newImageRect into a ScrollView while it is still drifting?

I’ve tried to do this in the “if (phase == “began”)” (or “ended”) section of my scrollListener, but if I scrollView:insert(myNewImageRect) there, it stops any drifting of my scrollView, no matter the tension.

If I wait until the “stopped” phase, it works normally, drifting nicely, but then it obviously appears a little later than I’d like.

The idea is that my fingertips are leaving “stains” on the page I am scrolling as I touch them, but I’d love the drift to be normal. Somehow inserting a new bitmap into the scrollView is interrupting the “began”…“ended”…“stopped” process with regard to friction(less) drift and ending any natural drift.

Any ideas? I’m not sure why inserting is interrupting the natural touch flow of the scrollView, but it clearly is.

I faced this problem so I grabbed the source for the widgets library and changed it. It is on github so you can alter it to whatever functionality you’d like.

How do I know I’m grabbing the latest? Do these libraries get updated for new releases/OSes? Is there any other danger/cautions/concerns to doing this?

Is it this? https://github.com/coronalabs/framework-widget

Sorry, still a bit of a newbie here.

(Also, is there a proper place to request this be added to the functionality if it’s an actual limitation of the existing codebase? Is there any reason you’d want this to be the resulting behavior?)

You can put a request on GitHub but it is unlikely to get changed as this may well break the library for other users…

The line you want to remove is this one

self:scrollToPosition( { x = origX, y = origY, time = 0 } )

It is around line 450 in widget_scrollview.lua.

I would send you mine but it is heavily bespoked for my implementation.

Thanks, SGS. And thanks especially for helping me get down to the line at play. :slight_smile:

Um, okay, this may just be me being a little new to lua and rusty to libraries and includes, but is there a short answer to how I include this code instead of the typical library? Is there a cleanest way to do it and have this override the other?

I assume rather than including the library at the start of my code with local widget = require( “widget” ) I’m somehow including this instead? Or can I somehow get away with just including the altered widget_scrollview.lua and have it override that part of the library, or am I needing to override the whole widget library and include the whole framework? (I found the line you referenced at the end of the scrollView:updateScrollAreaSize() function; just not sure best to include and then modify it.)

(Sorry for the hassle; this part is never my favorite, and I guess I’m not quite sure how to proceed. Should maybe have put this in the Newbies section…)

Put the entire rep in a sub folder called widget and then when you want to use your amended version you would do this instead.

local widget = require( "widget.widget" )

Well, that doesn’t quite work for me.

I assume you meant the widgetLibrary folder, not the “entire rep,” because if I put all of framework-widget in there I get a far more solid error message. But when I put the widgetLibrary in there, rename it to widget, and then change that require line in my main.lua, I get a different set of error messages at runtime (this is on the Simulator, mind you), all related to being “Unable to perform arithmatic on field ‘_oldAnchorX’ (a nil value)” and traced to Line 476 in function _calculatePosition in widget.lua.

Sigh. Should this work in the Simulator? After my last post I did some other searches through the archive and there are alternate instructions for doing this with the widget library, including an option called “WidgetFix” and a whole string of “package.preload.widget_button = onRequireWidgetLibrary”-type commands and the like. Problem is, a lot of these posts are 3 or 4 years old, so I’m not sure whether to take them seriously and try them or whether things have changed or simplified.

(Well, I’ve tried them too, and also get errors.)

Thanks again for the assistance, and if there’s a more official and recent thread on how to do this, feel free to direct me there.

I use the entire rep as I have amended some of the other widgets too. I do remember there being some issues when I did it. Don’t rename anything otherwise you’ll break the dependencies.

It works in the sim just fine. I use scrollviews with thousands of dynamically inserted objects - both for speed and memory management.

Well, so far this is just me trying to replace the library, with NO changes. Not even commenting out the one line I should to get the behavior I want.

I guess I’ll tinker around with it a little more, but right now simply replacing the library and pointing to it with require doesn’t seem to quite do it. (At least not with the versions of things I’m running, which I might play with also I guess.)