S
S
saveTibet2016-10-24 22:57:28
UIkit
saveTibet, 2016-10-24 22:57:28

How to get UIkit's smooth scroll to work?

UIkit has instructions for setting smooth scrolling to a page. I mean with JS, as they say at the bottom of the page -

UIkit.Utils.scrollToElement(UIkit.$(element, { /* options */ });

What to do with this code? Where to put it and how to do it right?

I tried to insert it in /template/js/theme.js like this -
$(UIkit.Utils.scrollToElement(UIkit.$('#main', { duration: 1000 })));
, and placed a link on the page that should gently scroll to the desired block - <a class="scroll-down-arrow" href="#main"></a>but this does not work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2016-10-25
@JarvisVRTX

I tried to paste it in /template/js/theme.js like this

don't do that :) Just add the data-uk-smooth-scroll attribute to each link, as shown in the example:
<a href="#my-id" class="uk-button" data-uk-smooth-scroll>...</a>

A
Alexander Kalinin, 2018-02-19
@kentovsky

if
then there should be a #kuda element that you should slide to, like:
<footer id="kuda"></footer>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question