I just started a small Rails app, and right now I have only one static page that I'm trying to add a smooth scroll effect for links to anchors on that page. You can see the site at http://kylerm42.herokuapp.com. I noticed that the script is being included, so I know it's not being left out. When I put that static page along with the jQuery into JSFiddle, everything works as it should. But it won't have that effect on my local machine or production. Here's the link for that: http://jsfiddle.net/YtJcL/478/
The jQuery was found in an answer here on SO, and here is the code for that:
$(".scroll").click(function (event) {
event.preventDefault();
//calculate destination place
var dest = 0;
if ($(this.hash).offset().top > $(document).height() - $(window).height()) {
dest = $(document).height() - $(window).height();
} else {
dest = $(this.hash).offset().top;
}
//go to destination
$('html,body').animate({
scrollTop: dest
}, 1500, 'swing');
});
My guess is that some default Rails file is interfering, but I'm not experienced enough yet to know where to look. It could also very well be a simple mistake I made somewhere along the way. Any help is appreciated! Thanks!