带有模板的javascript函数问题
我刚买了一个模板,现在我发现其中一个页面的功能不起作用 正如您在本页中看到的: 如果你一直点击过滤按钮,栏的宽度就会越来越小,直到栏变得非常可怕 这是有错误的javascript函数,我无法找到问题带有模板的javascript函数问题,javascript,jquery,html,Javascript,Jquery,Html,我刚买了一个模板,现在我发现其中一个页面的功能不起作用 正如您在本页中看到的: 如果你一直点击过滤按钮,栏的宽度就会越来越小,直到栏变得非常可怕 这是有错误的javascript函数,我无法找到问题 //Masonery $(window).load(function() { $(function() { $.Isotope.prototype._getCenteredMasonryColumns = function() { this.wid
//Masonery
$(window).load(function() {
$(function() {
$.Isotope.prototype._getCenteredMasonryColumns = function() {
this.width = this.element.width();
var parentWidth = this.element.parent().width();
// i.e. options.masonry && options.masonry.columnWidth
var colW = this.options.masonry && this.options.masonry.columnWidth ||
// or use the size of the first item
this.$filteredAtoms.outerWidth(true) ||
// if there's no items, use size of container
parentWidth;
var cols = Math.floor(parentWidth / colW);
cols = Math.max(cols, 1);
// i.e. this.masonry.cols = ....
this.masonry.cols = cols;
// i.e. this.masonry.columnWidth = ...
this.masonry.columnWidth = colW;
};
$.Isotope.prototype._masonryReset = function() {
// layout-specific props
this.masonry = {};
// FIXME shouldn't have to call this again
this._getCenteredMasonryColumns();
var i = this.masonry.cols;
this.masonry.colYs = [];
while (i--) {
this.masonry.colYs.push(0);
}
};
$.Isotope.prototype._masonryResizeChanged = function() {
var prevColCount = this.masonry.cols;
// get updated colCount
this._getCenteredMasonryColumns();
return (this.masonry.cols !== prevColCount);
};
$.Isotope.prototype._masonryGetContainerSize = function() {
var unusedCols = 0,
i = this.masonry.cols;
// count unused columns
while (--i) {
if (this.masonry.colYs[i] !== 0) {
break;
}
unusedCols++;
}
return {
height: Math.max.apply(Math, this.masonry.colYs),
// fit container to columns that have been used;
width: (this.masonry.cols - unusedCols) * this.masonry.columnWidth
};
};
var $container = $('#container'),
$body = $('body'),
colW = 1,
columns = null;
$container.isotope({
// disable window resizing
resizable: false,
masonry: {
columnWidth: colW
}
});
//FILTERING
$('#filters a').click(function() {
var selector = $(this).attr('data-filter');
$container.isotope({
filter: selector
});
return false;
});
});
});
///End masonery
我不确定是什么原因导致
#容器的宽度缩小。看起来这里的计算是错误的
尝试调试此方法$.isototype.prototype.\u masonryGetContainerSize
我现在可以建议一个好的临时修复方法,就是将style.css中#container
的宽度设置为100%!重要信息
。这似乎很管用。有人知道bug在哪里吗?我试图理解,但我是javascript初学者…不幸的是设置#容器{宽度:100%!重要;}会弄乱响应设计:(