samedi 29 novembre 2014

SmoothScroll not working in Wordpress


I have been asked to take a HTML website and develop a Wordpress theme out of it. The website uses SmoothScroll so when a button in the footer is clicked, it scrolls nicely to the top of the page. Except now it is in Wordpress, I click the button and it just reloads the page at siteurl.com/#about


The jquery in the .js include (as well as a smoothscroll.js include) was:



$(function() {
'use strict';

$('.scroll').bind('click', function(event) {
var $anchor = $(this);
var headerH = $('#navigation').outerHeight();
$('html, body').stop().animate({
scrollTop : $($anchor.attr('href')).offset().top - headerH + "px"
}, 1200, 'easeInOutExpo');

event.preventDefault();
});
});


And i changed this to put in non-conflict or whatever it is you call it:



jQuery(document).ready(function( $ ) {
$(function() {
'use strict';

$('.scroll').bind('click', function(event) {
var $anchor = $(this);
var headerH = $('#navigation').outerHeight();
$('html, body').stop().animate({
scrollTop : $($anchor.attr('href')).offset().top - headerH + "px"
}, 1200, 'easeInOutExpo');

event.preventDefault();
});
});
});


There are also a couple of other jquery effects that aren't working but jquery is working because some things are ie. toggle to display map etc..


Any suggestions? Could it just be the way it is loading the URL with the slash in between?


Thanks.





Aucun commentaire:

Enregistrer un commentaire