У меня есть функция прокрутки якорной ссылки с использованием ScrollMagic на веб-сайте, я пытаюсь сместить цель scrollTo на 100 пикселей по оси Y, я новичок в jquery и не знаю, где разместить такую инструкцию:
'scrollTop': $target.offset().top - 100
Вот мой рабочий код (из: https://github.com/janpaepke/ScrollMagic/wiki/Tutorial-:-Anchor-Navigation):
$(document).ready(function() {
// Init controller
var controller = new ScrollMagic.Controller();
// Change behavior of controller
// to animate scroll instead of jump
controller.scrollTo(function(target) {
TweenMax.to(window, 2, {
scrollTo : {
y : target, // scroll position of the target along y axis
autoKill : true, // allows user to kill scroll action smoothly
},
ease : Cubic.easeInOut
});
});
// Bind scroll to anchor links
$(document).on("click", "a[href^=#]", function(e) {
var id = $(this).attr("href");
if($(id).length > 0) {
e.preventDefault();
// trigger scroll
controller.scrollTo(id);
// If supported by the browser we can also update the URL
if (window.history && window.history.pushState) {
history.pushState("", document.title, id);
}
};
});
});
Любые указатели очень ценятся. Спасибо