T
T
Trixiborsh2021-02-19 15:02:48
safari
Trixiborsh, 2021-02-19 15:02:48

How to make smooth anchor scroll for safari ios?

The css has the property scroll-behavior: smoth; , which does not work in some browsers, including safari on ios.
I found the only option on the net - the smoothscroll.js polyfill. The option is either difficult, or I do not have enough experience / skill to put it.
Are there alternatives? Or maybe an instruction in Russian for installing a polyfill? I would be glad for any help :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DrWeyber, 2021-02-19
@DrWeyber

smoothscroll.js, translating the documentation
Add before the closing body

<script src="path/to/smooth-scroll.polyfills.min.js"></script>
or
CDN in the header
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll/dist/smooth-scroll.polyfills.min.js"></script>

Create a link and an anchor (go any)
<a data-scroll href="#bazinga">Anchor Link</a>
...
<div id="bazinga">Bazinga!</div>

Also below
<script>
  var scroll = new SmoothScroll('a[href*="#"]');
</script>

Can you adjust the speed
var scroll = new SmoothScroll('a[href*="#"]', {
  speed: 300
});

Everything is clear in the doc

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question