scroll to animate selected anchor in jquery
<p>I have simple JS function that's animate page scroll to selected anchor by id  </p>

<p>all anchor in my page have different offset value and position
tip: I user masonry effect
 but does not work correctly </p>

<pre><code>function scrollToAnchor(aid) {
    var aTag = $("a[id='" + aid + "']");
    $('html,body').animate({ scrollTop: aTag.position().top  }, 'slow');
}
</code></pre>
