You can add the js script in your theme/child-theme footer.php
template after wp_footer()
function or just before the closing body tag (</body>
).
Using your header element id theme-header
as the offset, you basically avoid scrolling on small devices, without having to set a condition to check for the viewport. Your video id is the-sticky-video
so I’m using this as the target to scroll to.
The code that does the scrolling is the "scrollTo"
method provided by the plugin. I’ve also added a small 100 milliseconds delay for the scrolling event (after the page is fully loaded).
Using the code below as is, you can add the id the-sticky-video
on any element in a page and it’ll scroll to that element:
(function($){
$(window).on("load",function(){
var idToScroll="#the-sticky-video";
if($(idToScroll).length){
setTimeout(function(){
$.mPageScroll2id("scrollTo",idToScroll,{
offset:"#theme-header"
});
},100);
}
});
})(jQuery);
If you want to change the id to scroll to change the idToScroll
variable and if you want to change the offset change the offset
attribute in mPageScroll2id
function.
Let me know
-
This reply was modified 1 year, 10 months ago by malihu.