Skip to content

Conversation

matthew-carroll
Copy link
Contributor

Extract gesture and physics configuration (Resolves #60)

Move hard-coded static values into properties and configuration objects.

I think I also must have regenerated the Android example project because there are a bunch of those files that changed in this PR, too.

@matthew-carroll
Copy link
Contributor Author

@dodgog do you wanna take a look at the changes made in this PR to the gesture widgets and see if it provides enough control for you?

@dodgog
Copy link
Contributor

dodgog commented Jul 16, 2025

Matt, thank you so much for this PR. I think that there's still a couple of things we want for ultimate control. I'm wondering if we can just finish with all the constants being bundled into parameters. For example, the sigmoid tuning mentioned in the issue to be applied here:

  double _calculateVelocityMultiplierFromRepeatedSwipeCount(int numberOfRepeatedAcceleratedSwipes) {
    const double transitionValue = 9; // where the function takes it's intermediate value
    const double k = 0.5; // how quickly the shift happens (smaller is slower)
    const double startValue = 1;
    const double endValue = 14;
    return startValue +
        (endValue - startValue) / (1 + math.exp(-k * (numberOfRepeatedAcceleratedSwipes - transitionValue)));
  }

Additionally, I think the goal of the refactor is to allow quick iteration of the physics in the consuming application. That means an ability to dependency inject the config into the page list viewport is really needed, unless I'm not understanding something about the design which you're proposing here.

So, as an example, in our PDF reader, which uses the viewport, we want to be able to adjust a parameter like, for example, a multiplier for panning axis simulation initial velocity: lockedAxisSimulationInitialVelocityMultiplier, rebuild the widget, and have it behaving differently.

@matthew-carroll
Copy link
Contributor Author

@dodgog I piped ballistics into the PageListViewportGestures.

Now PageListViewportGestures can receive an axisLock configuration and a ballistics configuration.

Do you see any other property configurations that I added in this PR that need to be piped to PageListViewportGestures?

Re: "sigmoid configuration" - I don't see the term "sigmoid" anywhere in the source code. I see that you copied a method into your last response, but since I don't know what you mean by sigmoid, and nothing is called a sigmoid, I'm not sure what exactly you're asking me to bundle and expose.

@dodgog
Copy link
Contributor

dodgog commented Jul 23, 2025

Matt, this looks really great. Thank you. I think we are approaching perfection. I opened a pr in which I isolated the last few coefficients and defined a sigmoid. Could you have a look? #63

@matthew-carroll
Copy link
Contributor Author

@dodgog - I integrated your changes from #64 - please let me know if we need any further changes.

@matthew-carroll
Copy link
Contributor Author

@dodgog after the initial velocity change, the scrolling tests broke. This breakage is not completely unexpected - changing velocity calculations are expected to impact our locked down ballistic motion. However, it would be good if you could confirm that you've used this package with the changes to the velocity multiplication, and that you really do want the new behavior. We can update the test to expect the newly reported values.

Looking at the test failures, we're seeing things like Expected resting place: Offset(0.0, -1679.7), actual resting place: Offset(0.0, -1480.8), - so the ballistic motion is stopping about 200px earlier than previously, which constitutes about a 15% reduction in distance.

@dodgog
Copy link
Contributor

dodgog commented Aug 18, 2025

Okay, this looks good. If we set the multipliers to 1 in tests, they shouldn't break. Would that be right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make viewport physics configurable
2 participants