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

scrollDown malfunctions if it needs to scroll up instead #506

Open
dstelzer opened this issue Mar 29, 2024 · 2 comments
Open

scrollDown malfunctions if it needs to scroll up instead #506

dstelzer opened this issue Mar 29, 2024 · 2 comments

Comments

@dstelzer
Copy link

The scrollDown method in main.js is supposed to scroll to the new text after making a choice. This normally does require, well, scrolling down. But it can sometimes require scrolling up instead, if there are enough choices that the top of the first choice is above the browser viewport. When this happens it tries to scroll upward forever, preventing the user from accessing anything lower on the page.

To reproduce, have a long enough list of choices and a high enough browser zoom that the top of the choice list is above the viewport. Click any choice. The scroll bar will become stuck at the top of the page else, preventing the user from seeing anything else.

The broken line is:

var duration = 300 + 300*dist/100;

This results in a negative duration when dist is negative, which means the animation never ends. It should instead use Math.abs(dist).

@dstelzer
Copy link
Author

Reported at inkjs also since this is specifically about the inkjs interpreter: y-lohse/inkjs#1048

@spaxton
Copy link

spaxton commented Aug 5, 2024

Here to +1 both the broken line and the proposed fix.

The use case for me is for adding images to ink choices, which extends their height and is causing a frequent scroll lock. This is especially prevalent on mobile devices. It's easy to test by shrinking the window height on desktop to smaller than the total height of the choices.

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

No branches or pull requests

2 participants