-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
245 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
|
||
<title>horizontal order</title> | ||
|
||
<style> | ||
* { box-sizing: border-box; } | ||
|
||
body { font-family: sans-serif; } | ||
|
||
.grid { | ||
background: #DDD; | ||
max-width: 900px; | ||
margin-bottom: 60px; | ||
} | ||
|
||
.grid-item { | ||
float: left; | ||
width: 150px; | ||
height: 150px; | ||
border: 1px solid #333; | ||
color: white; | ||
font-size: 20px; | ||
background: #19F; | ||
counter-increment: grid-item; | ||
} | ||
|
||
.grid-item:before { | ||
content: counter(grid-item); | ||
padding: 10px; | ||
} | ||
|
||
.grid-item--width2 { width: 300px; } | ||
.grid-item--width3 { width: 450px; } | ||
|
||
.grid-item--height2 { height: 200px; } | ||
.grid-item--height3 { height: 250px; } | ||
|
||
.grid-item.is-zero { height: 0; border: none; } | ||
|
||
.stamp { | ||
border: 1px solid #333; | ||
background: #E21; | ||
position: absolute; | ||
} | ||
|
||
.stamp--1 { | ||
width: 300px; | ||
height: 200px; | ||
right: 0; | ||
top: 0; | ||
} | ||
</style> | ||
|
||
</head> | ||
<body> | ||
|
||
<h1>horizontal order</h1> | ||
|
||
<div class="grid grid--1"> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height3"></div> | ||
<div class="grid-item grid-item--height2"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height2"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item is-zero"></div> | ||
<div class="grid-item grid-item--width2"></div> | ||
<div class="grid-item grid-item--height3"></div> | ||
<div class="grid-item grid-item--width3"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height2"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--width3"></div> | ||
<div class="grid-item grid-item--height2"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height2"></div> | ||
<div class="grid-item"></div> | ||
</div> | ||
|
||
<div class="grid grid--2"> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height3"></div> | ||
<div class="grid-item grid-item--height2"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height2"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height3"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height3"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height3"></div> | ||
<div class="grid-item grid-item--height2"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height2"></div> | ||
</div> | ||
|
||
<div class="grid grid--3"> | ||
<div class="stamp stamp--1"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height3"></div> | ||
<div class="grid-item grid-item--height2"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height2"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height3"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height2"></div> | ||
<div class="grid-item"></div> | ||
<div class="grid-item grid-item--height3"></div> | ||
<div class="grid-item"></div> | ||
</div> | ||
|
||
<script src="../bower_components/ev-emitter/ev-emitter.js"></script> | ||
<script src="../bower_components/get-size/get-size.js"></script> | ||
<script src="../bower_components/desandro-matches-selector/matches-selector.js"></script> | ||
<script src="../bower_components/fizzy-ui-utils/utils.js"></script> | ||
<script src="../bower_components/outlayer/item.js"></script> | ||
<script src="../bower_components/outlayer/outlayer.js"></script> | ||
|
||
<script src="../masonry.js"></script> | ||
|
||
<script> | ||
new Masonry( '.grid--1', { | ||
itemSelector: '.grid-item', | ||
horizontalOrder: true, | ||
}); | ||
|
||
new Masonry( '.grid--2', { | ||
itemSelector: '.grid-item', | ||
horizontalOrder: true, | ||
}); | ||
|
||
new Masonry( '.grid--3', { | ||
itemSelector: '.grid-item', | ||
horizontalOrder: true, | ||
stamp: '.stamp', | ||
}) | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
QUnit.test( 'horizontal order', function( assert ) { | ||
|
||
var grid = document.querySelector('#horizontal-order'); | ||
var itemElems = grid.querySelectorAll('.item'); | ||
new Masonry( grid, { | ||
horizontalOrder: true, | ||
}); | ||
|
||
// items should match %3 column | ||
for ( var i=0; i < itemElems.length; i++ ) { | ||
var itemElem = itemElems[i]; | ||
var col = i % 3; | ||
var left = col * 60 + 'px'; | ||
var message = 'item ' + (i+1) + ', column' + (col + 1); | ||
assert.equal( itemElem.style.left, left, message ); | ||
} | ||
|
||
}); |