You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
705 B
30 lines
705 B
/* global woodmart_settings */
|
|
(function($) {
|
|
woodmartThemeModule.buttonSmoothScroll = function() {
|
|
$('.wd-button-wrapper.wd-smooth-scroll a').on('click', function(e) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
|
|
var $button = $(this);
|
|
var time = $button.parent().data('smooth-time');
|
|
var offset = $button.parent().data('smooth-offset');
|
|
var hash = $button.attr('href').split('#')[1];
|
|
|
|
var $anchor = $('#' + hash);
|
|
|
|
if ($anchor.length < 1) {
|
|
return;
|
|
}
|
|
|
|
var position = $anchor.offset().top;
|
|
|
|
$('html, body').animate({
|
|
scrollTop: position - offset
|
|
}, time);
|
|
});
|
|
};
|
|
|
|
$(document).ready(function() {
|
|
woodmartThemeModule.buttonSmoothScroll();
|
|
});
|
|
})(jQuery);
|
|
|