JuliaPluto / PlutoUI.jl

https://featured.plutojl.org/basic/plutoui.jl
The Unlicense
299 stars 54 forks source link

Use an external JS library for consistent smooth scrolling #254

Closed disberd closed 1 year ago

disberd commented 1 year ago

As discussed in #238, the smooth scrolling is broken in some browsers (e.g. Chrome).

This PR just loads an external library to ensure consistent smooth scrolling across browsers.

The library seems maintained and seems to solve the problem in the issue, so it fixes #238.

Here is a video example like in #238

https://user-images.githubusercontent.com/12846528/235166253-562a9b65-f1ce-4013-9843-aa2eeec75efe.mp4

github-actions[bot] commented 1 year ago

Try this Pull Request!

Open Julia and type:

  julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/disberd/PlutoUI.jl", rev="smooth-scroll")
julia> using PlutoUI

Or run this code in your browser: Run with binder

disberd commented 1 year ago

This might create issues when opening Pluto notebooks while offline as the library for smooth scrolling can't be downloaded. What is the best approach here? Since this is to some extent a problem also in jumps in Pluto we might have this used internally in Pluto and be provided as asset....

fonsp commented 1 year ago

Awesome! Like you pointed out, using an external library is not ideal. I went for the easiest solution: just bundle it by hand and inline into our code.

I also added a second call to scrollIntoView to fix some wrong scrolls when you initially loaded a notebook. The first time you scroll somewhere, the codemirrors will get rendered and their heights may change, so an easy fix is to just scroll again.

https://user-images.githubusercontent.com/6933510/235625618-62ab0626-7cc1-4d5c-a253-03b06895e6a4.mov

fonsp commented 1 year ago

Thanks!!

fonsp commented 1 year ago

Releasing in v0.7.51