https://github.com/GBKS/Wookmark-jQueryを使用していくつかの動的レイアウトを実行しています。また、ウィンドウのサイズ変更に関する関数を添付しています。
var $windowWidth = $window.width();
var options = {
itemWidth: 100,
autoResize: true,
container: $('#tiles'),
offset: 5,
outerOffset: 0,
flexibleWidth: '30%'
};
if ($windowWidth >= 768 && $windowWidth <= 1200) {
options.itemsize = 200;
options.offset = 7;
} else if ($windowWidth > 1200) {
options.itemsize = 300;
options.offset = 10;
}
$('#tiles li').woodmark(options); <-- this is fine
しかし、プロパティを返す関数を作成したい:
function getOptions() {
var $windowWidth = $(window).width();
var sizes = {
itemsize: 100,
offset: 5,
autoResize: true,
outerOffset: 0,
flexibleWidth: '30%'
};
if ($windowWidth >= 768 && $windowWidth <= 1200) {
sizes.itemsize = 200;
sizes.offset = 7;
} else if ($windowWidth > 1200) {
sizes.itemsize = 300;
sizes.offset = 10;
}
return sizes;
}
$('#tiles li').wookmark(getOptions); <-- doesn't work
$('#tiles li').wookmark(function() { getOptions }); <-- doesn't work
wookmark のすべてのコード サンプルは jquery プラグインとして実行され、通常のブレークポイントは chrome インスペクターでは機能しません。