-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1621 from adumesny/develop
collision overall - support for swap
- Loading branch information
Showing
9 changed files
with
433 additions
and
243 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,92 @@ | ||
<!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>swap demo</title> | ||
|
||
<link rel="stylesheet" href="../../../demo/demo.css"/> | ||
<script src="../../../dist/gridstack-h5.js"></script> | ||
|
||
</head> | ||
<body> | ||
<div class="container-fluid"> | ||
<h1>Swap collision demo</h1> | ||
<div> | ||
<a class="btn btn-primary" onClick="addNewWidget()" href="#">Add Widget</a> | ||
<a class="btn btn-primary" onclick="toggleFloat()" id="float" href="#"></a> | ||
<a class="btn btn-primary" onclick="toggleMax()" id="max" href="#"></a> | ||
<a class="btn btn-primary" onclick="toggleBigger()" id="big" href="#"></a> | ||
</div> | ||
<br><br> | ||
<div class="grid-stack"></div> | ||
</div> | ||
<script src="../../../demo/events.js"></script> | ||
<script type="text/javascript"> | ||
let floatButton = document.getElementById('float'); | ||
let maxButton = document.getElementById('max'); | ||
let bigButton = document.getElementById('big'); | ||
let size = 1; | ||
|
||
let grid = GridStack.init({float: false, cellHeight: 70, maxRow: 0}); | ||
addEvents(grid); | ||
|
||
let count = 0; | ||
let items = [ | ||
{x:0, y:0}, {x:0, y:1}, {x:0, y:2},{x:1, y:0}, {x:1, y:1}, {x:1, y:2}, | ||
{x:5, y:0}, {x:4, y:1, w:3, locked: false, _content: 'locked'}, {x:5, y:2}, | ||
{x:7, y:0}, {x:8, y:0}, {x:9, y:0}, {x:7, y:1, w:3}, {x:8, y:2}, | ||
{x:11, y:0}, {x:11, y:1, h:2}, | ||
]; | ||
items.forEach(n => {n.id = count; n.content = n.content || String(count); count++}) | ||
grid.load(items); | ||
|
||
addNewWidget = function() { | ||
let n = { | ||
x: Math.round(12 * Math.random()), | ||
y: Math.round(5 * Math.random()), | ||
w: Math.round(1 + 3 * Math.random()), | ||
h: Math.round(1 + 3 * Math.random()), | ||
content: String(count++) | ||
}; | ||
grid.addWidget(n); | ||
}; | ||
|
||
toggleFloat = function() { | ||
grid.float(! grid.getFloat()); | ||
floatButton.innerHTML = 'float: ' + grid.getFloat(); | ||
}; | ||
floatButton.innerHTML = 'float: ' + grid.getFloat(); | ||
|
||
toggleMax = function() { | ||
grid.opts.maxRow = grid.engine.maxRow = grid.opts.maxRow ? 0 : 3; | ||
maxButton.innerHTML = 'Max: ' + grid.opts.maxRow; | ||
}; | ||
maxButton.innerHTML = 'Max: ' + grid.opts.maxRow; | ||
|
||
toggleBigger = function() { | ||
size = size === 1 ? 2 : 1; | ||
setSize(size); | ||
}; | ||
setSize = function(size) { | ||
items.sort((a,b) => a.id - b.id); | ||
items.forEach((n,i) => { | ||
if (i<6) { | ||
n.w = n.h = size; | ||
n.y = i * size; | ||
if (n.x) n.x = size; | ||
} else { | ||
n.h = size; | ||
} | ||
}); | ||
grid.opts.maxRow = grid.engine.maxRow = grid.opts.maxRow ? (size === 1 ? 3 : 6) : 0; | ||
grid.load(items); | ||
bigButton.innerHTML = 'Size: ' + size; | ||
maxButton.innerHTML = 'Max: ' + grid.opts.maxRow; | ||
} | ||
bigButton.innerHTML = 'Size: ' + size; | ||
if (size !== 1) setSize(size); | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!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>old swap</title> | ||
|
||
<link rel="stylesheet" href="../../../demo/demo.css"/> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/gridstack.min.css"/> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gridstack.all.js"></script> | ||
|
||
</head> | ||
<body> | ||
<div class="container-fluid"> | ||
<h1>Swap collision demo from older 1.x builds</h1> | ||
<div> | ||
<a class="btn btn-primary" onClick="addNewWidget()" href="#">Add Widget</a> | ||
<a class="btn btn-primary" onclick="toggleFloat()" id="float" href="#"></a> | ||
<a class="btn btn-primary" onclick="toggleMax()" id="max" href="#"></a> | ||
</div> | ||
<br><br> | ||
<div class="grid-stack"> | ||
<div class="grid-stack-item" data-gs-x="0" data-gs-y="0"><div class="grid-stack-item-content">0</div></div> | ||
<div class="grid-stack-item" data-gs-x="0" data-gs-y="1"><div class="grid-stack-item-content">1</div></div> | ||
<div class="grid-stack-item" data-gs-x="0" data-gs-y="2"><div class="grid-stack-item-content">2</div></div> | ||
<div class="grid-stack-item" data-gs-x="1" data-gs-y="0"><div class="grid-stack-item-content">3</div></div> | ||
<div class="grid-stack-item" data-gs-x="1" data-gs-y="1"><div class="grid-stack-item-content">4</div></div> | ||
<div class="grid-stack-item" data-gs-x="1" data-gs-y="2"><div class="grid-stack-item-content">5</div></div> | ||
</div> | ||
</div> | ||
<script type="text/javascript"> | ||
let floatButton = document.getElementById('float'); | ||
let maxButton = document.getElementById('max'); | ||
let count = 6; | ||
let grid = GridStack.init({float: false, cellHeight: 70, maxRow: 3}); | ||
|
||
addNewWidget = function() { | ||
let n = { | ||
x: Math.round(12 * Math.random()), | ||
y: Math.round(5 * Math.random()), | ||
w: Math.round(1 + 3 * Math.random()), | ||
h: Math.round(1 + 3 * Math.random()), | ||
content: String(count++) | ||
}; | ||
grid.addWidget(n); | ||
}; | ||
|
||
toggleFloat = function() { | ||
grid.float(! grid.getFloat()); | ||
floatButton.innerHTML = 'float: ' + grid.float(); | ||
}; | ||
floatButton.innerHTML = 'float: ' + grid.float(); | ||
|
||
toggleMax = function() { | ||
grid.opts.maxRow = grid.engine.maxRow = grid.opts.maxRow ? 0 : 3; | ||
maxButton.innerHTML = 'Max: ' + grid.opts.maxRow; | ||
}; | ||
maxButton.innerHTML = 'Max: ' + grid.opts.maxRow; | ||
|
||
</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
Oops, something went wrong.