I have a problem with plugin scrollTo
(tweenMax), When I click on and the menu link the website slide to the section ID that I chose on menu. But the website doesn't stop on begin of the section, and I need to show the h2 (Title).
My Code
$(function(){
var wrapper = $("#wrapper"),
$menu = $("#menu");
$menu.on("click","li", function(){
var $this = $(this),
href = $(this).find("a").attr("href"),
topY = $(href).offset().top;
TweenLite.to(window, 2, {scrollTo:{y:topY, x:0}, ease:Cubic.easeIn});
return false;
});
});
section{
margin-top: 200px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/plugins/ScrollToPlugin.min.js"></script>
<div class="wrap">
<nav id="menu" class="menu">
<ul class="row-centered">
<li class="icon-play"><a href="#home">Home</a></li>
<li class="link-empresa"><a href="#empresa">Link 2</a></li>
<li class="link-tecnologias"><a href="#tecnologicas">Link 3</a></li>
<li class="link-cases"><a href="#cases">Link 3</a></li>
<li class="link-contato"><a href="#contato">Link 4</a></li>
</ul>
</nav>
<section id="home"><h2>Title 1</h2></section>
<section id="empresa"><h2>Title 2</h2></section>
<section id="tecnologicas"><h2>Title 3</h2></section>
<section id="cases"><h2>Title 4</h2></section>
<section id="contato"><h2>Title 5</h2></section>
</div>
In this example above, it's OK. But in my site the same code not working well. In my website there is a menu fixed on the top, it has a height = 75px, I put {scrollTo:{y:topY -75, x:0}
but not worked.
Update 1