Skip to content

Commit 33c2fc0

Browse files
authored
Merge pull request #2120 from adumesny/master
demo for parent offset
2 parents 23e8e9d + 57ae798 commit 33c2fc0

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

demo/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ <h1>Demos</h1>
1818
<li><a href="nested.html">Nested grids</a></li>
1919
<li><a href="nested_constraint.html">Nested Constraint grids</a></li>
2020
<li><a href="nested_advanced.html">Nested Advanced grids</a></li>
21+
<li><a href="offset.html">Offset parent</a></li>
2122
<li><a href="react-hooks.html">ReactJS (Hooks)</a></li>
2223
<li><a href="react.html">ReactJS</a></li>
2324
<li><a href="responsive.html">Responsive</a></li>

demo/offset.html

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>Transform Parent demo</title>
8+
9+
<link rel="stylesheet" href="demo.css"/>
10+
<script src="../dist/gridstack-all.js"></script>
11+
12+
</head>
13+
<body>
14+
<div class="container-fluid">
15+
<h1>Transform Parent demo</h1>
16+
<p>example where the grid parent has a transform (50px, 100px). Scale not supported yet - see #1275</p>
17+
<div>
18+
<a class="btn btn-primary" onClick="addNewWidget()" href="#">Add Widget</a>
19+
</div>
20+
<br><br>
21+
<div style="transform: translate(50px, 100px)">
22+
<div class="grid-stack"></div>
23+
</div>
24+
</div>
25+
<script src="events.js"></script>
26+
<script type="text/javascript">
27+
let grid = GridStack.init({float: true});
28+
addEvents(grid);
29+
30+
let items = [
31+
{x: 0, y: 0, w: 2, h: 2},
32+
{x: 2, y: 0, w: 1},
33+
{x: 3, y: 0, h: 1},
34+
{x: 0, y: 2, w: 2},
35+
];
36+
let count = 0;
37+
38+
getNode = function() {
39+
let n = items[count] || {
40+
x: Math.round(12 * Math.random()),
41+
y: Math.round(5 * Math.random()),
42+
w: Math.round(1 + 3 * Math.random()),
43+
h: Math.round(1 + 3 * Math.random())
44+
};
45+
n.content = n.content || String(count);
46+
count++;
47+
return n;
48+
};
49+
50+
addNewWidget = function() {
51+
let w = grid.addWidget(getNode());
52+
};
53+
54+
addNewWidget();
55+
addNewWidget();
56+
addNewWidget();
57+
</script>
58+
</body>
59+
</html>

0 commit comments

Comments
 (0)