Skip to content

Commit

Permalink
add appendHoles method
Browse files Browse the repository at this point in the history
  • Loading branch information
kombai committed Jan 20, 2014
1 parent 9b0b409 commit 1ac8372
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 25 deletions.
20 changes: 16 additions & 4 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ <h3>Sorry the page you requested may have been moved or deleted.</h3>
opacity: 0
});
}
},
onComplete: function(item, setting) {
console.log(wall);
console.log(setting);
}
});

wall.setHoles([
// 4
{
Expand All @@ -90,8 +95,11 @@ <h3>Sorry the page you requested may have been moved or deleted.</h3>
left: 10,
width: 2,
height: 6
},
// 0
}
]);

// 0
wall.appendHoles([
{
top: 6,
left: 16,
Expand All @@ -115,8 +123,11 @@ <h3>Sorry the page you requested may have been moved or deleted.</h3>
left: 16,
width: 8,
height: 2
},
// 4
}
]);

// 4
wall.appendHoles([
{
top: 6,
left: 26,
Expand All @@ -136,6 +147,7 @@ <h3>Sorry the page you requested may have been moved or deleted.</h3>
height: 6
}
]);

wall.fitWidth();
wall.refresh();
</script>
Expand Down
53 changes: 41 additions & 12 deletions freewall.js
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,37 @@
klass.fireEvent('onBlockShow', item, setting);
});
},
/*
add one or more blank area (hole) on layout;
example:
wall.appendHoles({
top: 10,
left: 36,
width: 2,
height: 6
});
wall.appendHoles([
{
top: 16,
left: 16,
width: 8,
height: 2
},
{
top: 10,
left: 36,
width: 2,
height: 6
}
]);
*/
appendHoles: function(holes) {
runtime.holes = runtime.holes.concat(holes);
return this;
},

container: container,

Expand Down Expand Up @@ -1063,22 +1094,21 @@
$.extend(setting, option);
return this;
},

/*
create blank are on layout;
create one or more blank area (hole) on layout;
example:
wall.setHoles([
{
top: 2,
left: 2,
width: 2,
height: 2
}
]);
wall.setHoles({
top: 2,
left: 2,
width: 2,
height: 2
});
*/

setHoles: function(holes) {
runtime.holes = holes;
runtime.holes = [].concat(holes);
return this;
},

Expand All @@ -1087,7 +1117,6 @@
this.refresh();
return this;
}

});

container.attr('data-min-width', Math.floor($W.width() / 80) * 80);
Expand Down
20 changes: 11 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ <h2>Methods</h2>
<ul>
<li> addCustomEvent </li>
<li> appendBlock </li>
<li> appendHoles </li>
<li> fillHoles </li>
<li> filter </li>
<li> fireEvent </li>
Expand Down Expand Up @@ -427,6 +428,10 @@ <h3> addCustomEvent(name, handler) </h3>
<h3> appendBlock(items) </h3>
<div> Append one or more items into layout</div>
</li>
<li>
<h3> appendHoles(holes) </h3>
<div> Add one or more blank area into layout</div>
</li>
<li>
<h3> fillHoles() </h3>
<div> Let layout without gaps</div>
Expand Down Expand Up @@ -491,15 +496,12 @@ <h5> Example </h5>
var demo = $(".example");
ewall.reset({
selector: '.cell',
animate: false,
block: {
flex: 1
},
cell: {
width: 150,
height: 150
},
fillGap: true
animate: true,
delay: 20,
cellW: 15.5,
cellH: 15,
gutterX: 2,
gutterY: 2
});
ewall.fitWidth(cwidth);
</code>
Expand Down

0 comments on commit 1ac8372

Please sign in to comment.