感谢到目前为止为我提供帮助的每个人。还有另一个与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
});
});
答案 0 :(得分:0)
您尝试关注吗?
$('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;
});
我已将queue:false选项添加到您的最后一个动画函数中。默认情况下启用此功能。
更新:
您可以签出这个fiddle吗?我目前正在尝试重新创建您的工作状况。小提琴看起来像您的工作环境吗?
我已经发现,当按下等值线过滤器按钮时,$("a").on('click', fun...
也被称为/触发。