Answer the question
In order to leave comments, you need to log in
Smooth scrolling safari?
Please tell me how to add to this method so that smooth scrolling works on safari as well, or maybe there is another solution.
function scrollTo(element) {
window.scroll({
left: 0,
top: element.offsetTop,
behavior: 'smooth'
})
}
var contacts = document.querySelector('.contacts');
var footer = document.querySelector('.footer');
contacts.addEventListener('click', () => {
scrollTo(footer);
});
Answer the question
In order to leave comments, you need to log in
Safari doesn't support behavior: 'smooth' or even scroll-behavior. You need to do it through JS polyfills (I won’t say a specific one, google it and see which one is more convenient, I use our team’s bike).
I hope I'm wrong, and someone will now offer a native solution, because. I already suffered with this safari, on iOS polyfills are wildly slow.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question