感谢到目前为止帮助我的每个人。还有另一个与JS有关的问题。任何有提前知识的人都可以帮助我解决此错误吗?我的网站既具有光滑的滚动效果,又具有JavaScript图像过滤器。但是平滑的滚动功能可防止图像过滤器功能的功能。我无法上传完整的HTML CSS和JavaScript代码,因为此网站可以防止它。因此,我将上传JavaScript代码。请看一下并帮助我修复它。
// ISOTOPE PORTFOLIO WITH FILTER
if(isExists('.portfolioContainer')){
var $container = $('.portfolioContainer');
$container.isotope({
filter: '*',
animationOptions: {
duration: 750,
easing: 'linear',
queue: false
}
});
$('.portfolioFilter a').click(function(){
$('.portfolioFilter .current').removeClass('current');
$(this).addClass('current');
var selector = $(this).attr('data-filter');
$container.isotope({
filter: selector,
animationOptions: {
duration: 750,
easing: 'linear',
queue: false
}
});
return false;
});
}
$(document).ready(function(){
// Add smooth scrolling to all links
$("a").on('click', function(event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "#portfolio") {
// Prevent default anchor click behavior
event.preventDefault();
// Store hash
var hash = this.hash;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 400, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash = hash;
});
} // End if
});
});
您是否尝试关注?
$('html, body').animate({
scrollTop: $(hash).offset().top
}, {
queue: false,
duration: 400
}, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash = hash;
});
我已将队列:false选项添加到您的最后一个动画函数中。默认情况下启用了这一点。
更新:你能检查一下这个小提琴吗?我目前正在尝试重新创建您的工作状况。小提琴看起来像您的工作环境吗?我已经发现的是,按下同位过滤器按钮时,$("a").on('click', fun...
也被调用/触发。