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

iOS: Be able to specify animation parameters to "scrollToTop" and "scrollToBottom" #13203

Open
1 task done
hansemannn opened this issue Dec 6, 2021 · 1 comment · May be fixed by #13204
Open
1 task done

iOS: Be able to specify animation parameters to "scrollToTop" and "scrollToBottom" #13203

hansemannn opened this issue Dec 6, 2021 · 1 comment · May be fixed by #13204
Labels
feature ios needs triage This issue hasn't been reviewed by maintainers

Comments

@hansemannn
Copy link
Collaborator

I have searched and made sure there are no existing issues for the issue I am filing

  • I have searched the existing issues

Description

There is currently no way to disable the animation when using scrollToTop and scrollToBottom.

Solution

It can be changed while keeping backwards compatibility 👍 Not sure if Android also allows this, so it could be added parity. To move fast, I would like to add iOS first and then add Android later if anyone needs it as well.

Alternatives

No response

Platforms

iOS

@hansemannn hansemannn added feature needs triage This issue hasn't been reviewed by maintainers labels Dec 6, 2021
@m1ga
Copy link
Contributor

m1ga commented Dec 7, 2021

About Android:

#9601

Animated vertical scrolling bugs mentioned above were solved by disabling the smooth scrolling animation. It now immediately jumps to the given position. This appears to be a Google bug in their Java NestedScrollView class.

That said: It works for me like this but it should be default false of course and we might need to add that note to the README. Just in case:

https://github.com/appcelerator/titanium_mobile/blob/c706bea567d683d318fe179c97ba33cb20809ab4/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIScrollView.java#L997-L1005

	public void scrollToBottom(boolean animated)
	{
		View view = this.scrollView;
		if (view instanceof TiHorizontalScrollView) {
			((TiHorizontalScrollView) view).fullScroll(View.FOCUS_RIGHT);
		} else if (view instanceof TiVerticalScrollView) {
			if (animated == false) {
				((TiVerticalScrollView) view).fullScroll(View.FOCUS_DOWN);
			} else {
				NestedScrollView nestedScrollView = ((TiVerticalScrollView) view);
				nestedScrollView.smoothScrollBy(0, nestedScrollView.getChildAt(0).getHeight());
			}
		}
	}

https://github.com/appcelerator/titanium_mobile/blob/fe3deddcea07ecb3555673cf2dba8d676fd79611/android/modules/ui/src/java/ti/modules/titanium/ui/ScrollViewProxy.java#L80-L85

	@Kroll.method
	public void scrollToBottom(@Kroll.argument(optional = true) HashMap args)
	{
		boolean animated = false;
		if (args != null) {
			animated = TiConvert.toBoolean(args.get("animated"), false);
		}
		handleScrollToBottom(animated);
	}

https://github.com/appcelerator/titanium_mobile/blob/fe3deddcea07ecb3555673cf2dba8d676fd79611/android/modules/ui/src/java/ti/modules/titanium/ui/ScrollViewProxy.java#L97-L100

	public void handleScrollToBottom(boolean animated)
	{
		getScrollView().scrollToBottom(animated);
	}

@m1ga m1ga added the ios label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ios needs triage This issue hasn't been reviewed by maintainers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants