1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+
4+ < head >
5+ < meta charset ="utf-8 ">
6+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
7+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
8+ < title > demo1</ title >
9+
10+ < link rel ="stylesheet " href ="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ">
11+ < link rel ="stylesheet " href ="demo.css " />
12+
13+ < script type ="module " src ="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.esm.js "> </ script >
14+ < script nomodule ="" src ="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.js "> </ script >
15+
16+ < script src ="../dist/gridstack-h5.js "> </ script >
17+ </ head >
18+
19+ < body >
20+ < h1 > Web demo 1</ h1 >
21+ < div class ="grid-stack "> </ div >
22+
23+ < script type ="text/javascript ">
24+ let grid = GridStack . init ( {
25+ cellHeight : 70 ,
26+ } ) ;
27+
28+ let items = [
29+ { x : 0 , y : 0 , w : 4 , h : 2 , content : '1' } ,
30+ { x : 4 , y : 0 , w : 4 , h : 4 , content : '2' } ,
31+ { x : 8 , y : 0 , w : 2 , h : 2 , content : '<p class="card-text text-center" style="margin-bottom: 0">Drag me!<p class="card-text text-center"style="margin-bottom: 0"><ion-icon name="hand" style="font-size: 300%"></ion-icon><p class="card-text text-center" style="margin-bottom: 0">' } ,
32+ { x : 10 , y : 0 , w : 2 , h : 2 , content : '4' } ,
33+ { x : 0 , y : 2 , w : 2 , h : 2 , content : '5' } ,
34+ { x : 2 , y : 2 , w : 2 , h : 4 , content : '6' } ,
35+ { x : 8 , y : 2 , w : 4 , h : 2 , content : '7' } ,
36+ { x : 0 , y : 4 , w : 2 , h : 2 , content : '8' } ,
37+ { x : 4 , y : 4 , w : 4 , h : 2 , content : '9' } ,
38+ { x : 8 , y : 4 , w : 2 , h : 2 , content : '10' } ,
39+ { x : 10 , y : 4 , w : 2 , h : 2 , content : '11' } ,
40+ ] ;
41+ grid . load ( items ) ;
42+
43+ grid . on ( 'added removed change' , function ( e , items ) {
44+ let str = '' ;
45+ items . forEach ( function ( item ) { str += ' (x,y)=' + item . x + ',' + item . y ; } ) ;
46+ console . log ( e . type + ' ' + items . length + ' items:' + str ) ;
47+ } ) ;
48+ </ script >
49+ </ body >
50+
51+ </ html >
0 commit comments