I'm using Chris Coyier's plugin (actually, it is a modified version by Devin Sturgeon) to animate scrolling to anchor links:
// Easing for links pointing to anchors
$(document).ready(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
It works perfectly until I apply overflow values with jQuery. For example, after I close a modal window, this piece of code is in charge of hiding horizontal overflow and setting vertical overflow to auto:
$('.file-content a.close-reveal-modal').on('click', function() {
$('html, body').css({
'overflow-y' : 'auto',
'overflow-x' : 'hidden'
});
});
After those values are applied, the plugin to animate scrolling to anchor links stops working, clicking on them doesn't produce any result whatsoever. If I remove the code in charge of setting the overflows when closing a modal, Chris' plugin works like a charm every single time.
Why is this happening?
Any sort of help will be very much appreciated!