var $ = require('jQuery')
var Freewall = require('freewall')
var app = Ractive.extend({
el: 'main'
})
app = new app()
layoutGrid()
function layoutGrid(){
$.fn.freewalltize = function(opts) {
if (!opts) opts = {};
this.each(function() {
var $el = $(this);
var widthReference = $el.children().first().width();
var wall = new Freewall(this);
reset();
imagesLoaded(this, reset);
function reset() {
wall.reset({
selector: opts.selector || '.thumb',
animate: false,
cellW: 200,
cellH: 'auto',
fixSize: 1,
gutterX: opts.gutterX || 20,
gutterY: opts.gutterY || 20,
onResize: function() {
wall.fitWidth();
wall.refresh();
}
});
wall.fitWidth();
}
})
}
$('[freewall]').freewalltize();
}
HTML
<div freewall>
{{#items}}
<div class="thumb">
<img src=“{{img}}”/>
</div>
{{/items}}
</div>
将freewalljs和NodeJS与Ractive模板一起使用
一旦我设法使它工作,但它没有显示任何网格布局。过了一会儿,freewall不起作用。然后我在console.log上看到:Uncaught TypeError:Freewall不是一个函数。我看了看,无法找到原因。