forked from gridstack/gridstack.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
float.html
55 lines (50 loc) · 1.53 KB
/
float.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en">
<head>
<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="demo.css"/>
<script src="../dist/gridstack.all.js"></script>
</head>
<body>
<div class="container-fluid">
<h1>Float grid demo</h1>
<div>
<a class="btn btn-primary" onClick="addNewWidget()" href="#">Add Widget</a>
<a class="btn btn-primary" onclick="toggleFloat()" id="float" href="#">float: true</a>
</div>
<br><br>
<div class="grid-stack"></div>
</div>
<script src="events.js"></script>
<script type="text/javascript">
let grid = GridStack.init({float: true});
addEvents(grid);
let items = [
{x: 1, y: 1, width: 1, height: 1},
{x: 2, y: 2, width: 3, height: 1},
{x: 4, y: 2, width: 1, height: 1},
{x: 3, y: 1, width: 1, height: 2},
{x: 0, y: 6, width: 2, height: 2}
];
let count = 0;
addNewWidget = function() {
let n = items[count] || {
x: Math.round(12 * Math.random()),
y: Math.round(5 * Math.random()),
width: Math.round(1 + 3 * Math.random()),
height: Math.round(1 + 3 * Math.random())
};
n.content = String(count++);
grid.addWidget(n);
};
toggleFloat = function() {
grid.float(! grid.getFloat());
document.querySelector('#float').innerHTML = 'float: ' + grid.getFloat();
};
addNewWidget();
</script>
</body>
</html>