<html ng-app="antix.cells">
<head>
<meta name="description" content="angularjs cell layout" />
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
//.Three{margin-top:-25px}
//.Five{margin-top:-50px}
.found{
border-color:green;
}
</style>
</head>
<body ng-controller="demo">
<cells-container cells="cells">
<cell ng-repeat="cell in cells"
class="{{cell.content}}"
ng-style="{'height':cell.height+'px'}">
<div>
{{cell.content}}
</div>
</cell>
</cells-container>
</body>
</html>
*{
box-sizing:border-box;
}
cells-container{
position:absolute;
overflow:auto;
width:600px;
}
cell{
float:left;
width:33.3%;
padding:4px;
}
cell>div{
font-family:verdana, sans-serif;
color:#fff;
height:100%;
border-radius:2px;
padding:10px;
box-shadow:1px 1px 5px rgba(0,0,0,.1)
}
cell:nth-child(3n)>div{
background-color:#e66;
}
cell:nth-child(3n+1)>div{
background-color:#6e6;
}
cell:nth-child(3n+2)>div{
background-color:#88e;
}
angular.module('antix.cells', [])
.controller('demo',[
'$scope',
function($scope){
$scope.cells = [
{content:'One', height: 150},
{content:'Two', height:225},
{content:'Three', height:255},
{content:'Four', height:105},
{content:'Five', height:230},
{content:'Six', height:259},
{content:'Seven', height:110},
{content:'Eigth', height:120}
];
}
])
.directive('cellsContainer',[
function(){
return {
restrict:'AE',
scope:{cells:'@'},
controller:function($scope){
var columns = {};
$scope.cellElements = [];
this.addElement = function(cellElement){
var left=cellElement[0].offsetLeft,
top=cellElement[0].offsetTop,
height=cellElement[0].offsetHeight;
var column='_'+left;
if(!columns[column]) columns[column] = 0;
cellElement.css({marginTop:(columns[column]-top)+'px'});
columns[column]+=height;
$scope.cellElements.push(cellElement);
};
}
};
}
])
.directive('cell',[
function(){
return {
restrict:'AE',
require:'^cellsContainer',
link:function(
$scope,
element,
attributes,
cellsContainer){
$scope.$evalAsync(function() {
cellsContainer.addElement(element);
});
}
};
}
]);
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |