Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9fe8879

Browse files
committed
fixed sizeToContent demo
* fixed with latest sidebar code path
1 parent 7f6a7ab commit 9fe8879

File tree

6 files changed

+23
-457
lines changed

6 files changed

+23
-457
lines changed

demo/sizeToContent.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ <h1>sizeToContent options demo</h1>
9191
grid.load(items); // test loading after
9292
GridStack.init({...opts, children:undefined}, '#grid2');
9393

94-
GridStack.setupDragIn('.sidebar .grid-stack-item', { appendTo: 'body', helper: 'clone' });
94+
GridStack.setupDragIn('.sidebar>.grid-stack-item');
9595

9696
function clearGrid() {
9797
grid.removeAll();
@@ -109,10 +109,7 @@ <h1>sizeToContent options demo</h1>
109109
grid.addWidget({content: `<div>New: ${text}</div>`});
110110
}
111111
function makeWidget() {
112-
let doc = document.implementation.createHTMLDocument();
113-
doc.body.innerHTML = `<div class="item"><div class="grid-stack-item-content"><div>New Make: ${text}</div></div></div>`;
114-
let el = doc.body.children[0];
115-
grid.el.appendChild(el);
112+
let el = GridStack.Utils.createWidgetDivs(undefined, {content: `<div>New Make: ${text}</div>`}, grid.el)
116113
grid.makeWidget(el, {w:2});
117114
}
118115
function more() {

demo/static.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ <h1>Static vs can move/drag Demo</h1>
4949
];
5050
grid.load(serializedData);
5151

52-
GridStack.setupDragIn('.sidebar .grid-stack-item', { appendTo: 'body', helper: 'clone' });
52+
GridStack.setupDragIn('.sidebar>.grid-stack-item');
5353

5454
// grid.setStatic(false); // TEST enable after disabled
5555

demo/two.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h1>Two grids demo</h1>
2323

2424
<div class="row">
2525
<div class="col-md-8">
26-
<!-- NOTE: add .grid-stack-item for acceptWidgets:true, but not needed for function which handles .sidebar-item -->
26+
<!-- NOTE: add .grid-stack-item for acceptWidgets:true, but not needed for function which handles .sidebar-item (anything) -->
2727
<div class="sidebar">
2828
<!-- will size to match content. Also see sidebarContent -->
2929
<div class="sidebar-item">Drag me</div>
@@ -73,7 +73,7 @@ <h1>Two grids demo</h1>
7373
];
7474
items.forEach((item, i) => item.content = item.content || String(i));
7575

76-
// sidebar content to create when we get dropped, instead of inserting the clone version
76+
// sidebar content (just 2, rest is other behavior) to create when we get dropped, instead of inserting the clone version
7777
let sidebarContent = [
7878
{content: 'dropped'},
7979
{content: 'max=3', w:2, h:1, maxW: 3},
@@ -85,9 +85,10 @@ <h1>Two grids demo</h1>
8585
cellHeight: 70,
8686
float: true,
8787
removable: '.trash', // true or drag-out delete class
88+
/** accepts everything fcn, not just .grid-stack-item (true case) but can also be: true | false | '.someClass' value */
89+
acceptWidgets: function(el) { return true },
8890
children: items,
8991
// itemClass: 'with-lines', // test a custom additional class #2110
90-
acceptWidgets: function(el) { return true } // function example, but can also be: true | false | '.someClass' value
9192
};
9293
let grids = GridStack.initAll(options);
9394
grids[1].float(false);

demo/web2.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<body>
3232
<h1>Advanced Demo</h1>
3333
<div class="row">
34-
<div class="col-md-2 d-none d-md-block">
34+
<div class="sidepanel col-md-2 d-none d-md-block">
3535
<div id="trash" style="padding: 5px; margin-bottom: 15px;" class="text-center">
3636
<div>
3737
<ion-icon name="trash" style="font-size: 300%"></ion-icon>
@@ -40,7 +40,7 @@ <h1>Advanced Demo</h1>
4040
<span>Drop here to remove!</span>
4141
</div>
4242
</div>
43-
<div class="newWidget grid-stack-item">
43+
<div class="grid-stack-item" gs-h="2">
4444
<div class="grid-stack-item-content" style="padding: 5px;">
4545
<div>
4646
<ion-icon name="add-circle" style="font-size: 300%"></ion-icon>
@@ -67,7 +67,7 @@ <h1>Advanced Demo</h1>
6767
acceptWidgets: true,
6868
removable: '#trash', // drag-out delete class
6969
});
70-
GridStack.setupDragIn('.newWidget', { appendTo: 'body', helper: 'clone' });
70+
GridStack.setupDragIn('.sidepanel>.grid-stack-item');
7171

7272
let items = [
7373
{x: 0, y: 0, w: 4, h: 2, content: '1'},

0 commit comments

Comments
 (0)