1

I would like the vertical scrollbar to be displayed when I call element.scrollTop = <somePosition>;

Here is an example of what I'm trying to achieve: https://plnkr.co/edit/0ls05cCa3XrvrWPO?open=lib%2Fscript.js&preview

If that example is loaded on iOS, when the left box is scrolled, the right box should sync with it. That works just fine, but I need a way for the scrollbar to also show up.

1
  • Does this answer helpful to you? Commented Nov 1, 2022 at 8:56

2 Answers 2

2
+50

I think your issue is that division being scrolled via Javascript is not recognized as active, to keep scrollbar visible. I would suggest to try any custom Scrollbar library, they manage scrollbars with divisions rather than browser's.

Many such would allow you to configure scrollbar to be shown and hidden using Javascript.

It would add additional work for you, but it can be a solution to go with.

Here are few you can try with: https://www.jqueryscript.net/blog/Best-Custom-Scroll-Bar-jQuery-Plugins.html

Sign up to request clarification or add additional context in comments.

Comments

1

You could dynamically add a css class to the container when performing scrollTop().

Try a class that implements overflow-y: scroll when applied. That should yield the desired effect.

3 Comments

Thanks for the idea, but unfortunately overflow: auto and overflow: scroll behave the same way on iOS / iPadOS. I tried but it didn't work. Maybe there is no solution for this.
Hello @GuilhermeLopes overflow: auto shows scrollbar when it's necessary & overflow: scroll always shows scrollbar
@AnkitTiwari not on iOS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.