Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrolling improvements #3663

Open
wants to merge 3 commits into
base: scrolling-improvements
Choose a base branch
from

Conversation

Tianfeng-Chen
Copy link

@Tianfeng-Chen Tianfeng-Chen commented Nov 28, 2022

Fix #3657

  • Use setOnGenericMotionListener to handle scrolling event
  • The logic is detecting input from source InputDevice.SOURCE_CLASS_POINTER and verify if this event is a motion event with a type of MotionEvent.ACTION_SCROLL
  • Get current pointers' X axis and Y axis value
  • Using event.getAxisValue(MotionEvent.AXIS_VSCROLL) to get the moving direction indicator (this can get a value between -1 and 1)
  • Use the current Y axis value to calculate the location that the scene should be scrolled to
  • Keep the same X axis value and utilize scrollTo() method to scroll the scene
  • Add constrains to verify the desired scrolling location is not off the screen.

@shai-almog
Copy link
Collaborator

@shannah please review

@shannah
Copy link
Collaborator

shannah commented Oct 2, 2023

This PR only appears to apply to peer components, not the general app.
The most obvious native component to test this on is the webview, but it has its own scrolling functionality, that would need to be tested thoroughly to make sure it doesn't conflict with this.

So, before merging this I need to:

  1. Create a test app with no native peer components, to ensure no regressions.
  2. Create a test app with a webview, and test with and without this change, and with and without scrolling enabled on the webview to make sure that it doesn't introduce regressions, and verify whether it improves anything.
  3. Create a test app with a non-webview native peer component and see how this affects the scrolling on that component.

Also, I sense that this was not the intention of the PR. The title of the PR and the associated issue make is sound like this was intended to add scroll-wheel support to CN1 android apps in general. I don't think it does that.
Probably this sort of thing would need to be added in the CodenameOneView class:
https://github.com/codenameone/CodenameOne/blob/master/Ports/Android/src/com/codename1/impl/android/CodenameOneView.java#L372

And possibly the AsyncView also.

* Mouse Event Listener used to handle mouse wheel events
* The mouse wheel can be used to scroll the page up or down
*/
layoutWrapper.setOnGenericMotionListener(new View.OnGenericMotionListener() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds a motion listener to a native peer component. E.g. a webview or other native component. Not the main view. Probably we need to add similar in CodenameOneView if we want this to be for general app.

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.

None yet

3 participants