add floating sample
This commit is contained in:
parent
41b1a40fa0
commit
cb6f1aa8f2
2 changed files with 88 additions and 1 deletions
|
|
@ -121,7 +121,7 @@ $(function () {
|
|||
- `draggable` - allows to owerride jQuery UI draggable options. (default: `{handle: '.grid-stack-item-content', scroll: true, appendTo: 'body'}`)
|
||||
- `handle` - draggable handle selector (default: `'.grid-stack-item-content'`)
|
||||
- `height` - maximum rows amount. Default is `0` which means no maximum rows
|
||||
- `float` - enable floating widgets (default: `false`)
|
||||
- `float` - enable floating widgets (default: `false`) See [example](http://troolee.github.io/gridstack.js/demo/float.html)
|
||||
- `item_class` - widget class (default: `'grid-stack-item'`)
|
||||
- `min_width` - minimal width. If window width is less grid will be shown in one-column mode (default: `768`)
|
||||
- `placeholder_class` - class for placeholder (default: `'grid-stack-placeholder'`)
|
||||
|
|
|
|||
87
demo/float.html
Normal file
87
demo/float.html
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Float grid demo</title>
|
||||
|
||||
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css"/>
|
||||
<link rel="stylesheet" href="../src/gridstack.css"/>
|
||||
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.0/jquery-ui.js"></script>
|
||||
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/3.5.0/lodash.min.js"></script>
|
||||
<script src="../src/gridstack.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
.grid-stack {
|
||||
background: lightgoldenrodyellow;
|
||||
}
|
||||
|
||||
.grid-stack-item-content {
|
||||
color: #2c3e50;
|
||||
text-align: center;
|
||||
background-color: #18bc9c;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<h1>Float grid demo</h1>
|
||||
|
||||
<div>
|
||||
<a class="btn btn-default" id="add-new-widget" href="#">Add Widget</a>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
<div class="grid-stack">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var options = {
|
||||
float: true
|
||||
};
|
||||
$('.grid-stack').gridstack(options);
|
||||
|
||||
new function () {
|
||||
this.items = [
|
||||
{x: 0, y: 0, width: 2, height: 2},
|
||||
{x: 3, y: 1, width: 1, height: 2},
|
||||
{x: 4, y: 1, width: 1, height: 1},
|
||||
{x: 2, y: 3, width: 3, height: 1},
|
||||
// {x: 1, y: 4, width: 1, height: 1},
|
||||
// {x: 1, y: 3, width: 1, height: 1},
|
||||
// {x: 2, y: 4, width: 1, height: 1},
|
||||
{x: 2, y: 5, width: 1, height: 1}
|
||||
];
|
||||
|
||||
this.grid = $('.grid-stack').data('gridstack');
|
||||
|
||||
this.add_new_widget = function () {
|
||||
var node = this.items.pop() || {
|
||||
x: 12 * Math.random(),
|
||||
y: 5 * Math.random(),
|
||||
width: 1 + 3 * Math.random(),
|
||||
height: 1 + 3 * Math.random()
|
||||
};
|
||||
this.grid.add_widget($('<div><div class="grid-stack-item-content" /><div/>'),
|
||||
node.x, node.y, node.width, node.height);
|
||||
}.bind(this);
|
||||
|
||||
$('#add-new-widget').click(this.add_new_widget);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue