-
-
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 #1402 from adumesny/v2
v2.0.2
- Loading branch information
Showing
10 changed files
with
104 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,8 +96,8 @@ alternatively in html | |
or using CDN (minimized): | ||
|
||
```html | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected].1/dist/gridstack.min.css" /> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/gridstack.all.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected].2/dist/gridstack.min.css" /> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].2/dist/gridstack.all.js"></script> | ||
``` | ||
|
||
.map files are included for debugging purposes. | ||
|
@@ -194,7 +194,7 @@ GridStack.init( {column: N} ); | |
|
||
2) include `gridstack-extra.css` if **N < 12** (else custom CSS - see next). Without these, things will not render/work correctly. | ||
```html | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected].1/dist/gridstack-extra.css"/> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected].2/dist/gridstack-extra.css"/> | ||
|
||
<div class="grid-stack grid-stack-N">...</div> | ||
``` | ||
|
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
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,87 @@ | ||
// dd-utils.ts 2.0.2 @preserve | ||
|
||
/** | ||
* https://gridstackjs.com/ | ||
* (c) 2020 Alain Dumesny, rhlin | ||
* gridstack.js may be freely distributed under the MIT license. | ||
*/ | ||
export class DDUtils { | ||
static clone(el: HTMLElement): HTMLElement { | ||
const node = el.cloneNode(true) as HTMLElement; | ||
node.removeAttribute('id'); | ||
return node; | ||
} | ||
|
||
static appendTo(el: HTMLElement, parent: string | HTMLElement | Node) { | ||
let parentNode: HTMLElement; | ||
if (typeof parent === 'string') { | ||
parentNode = document.querySelector(parent as string); | ||
} else { | ||
parentNode = parent as HTMLElement; | ||
} | ||
if (parentNode) { | ||
parentNode.append(el); | ||
} | ||
} | ||
static setPositionRelative(el) { | ||
if (!(/^(?:r|a|f)/).test(window.getComputedStyle(el).position)) { | ||
el.style.position = "relative"; | ||
} | ||
} | ||
|
||
static throttle(callback: (...args) => void, delay: number) { | ||
let isWaiting = false; | ||
|
||
return (...args) => { | ||
if (!isWaiting) { | ||
callback(...args); | ||
isWaiting = true; | ||
setTimeout(() => isWaiting = false, delay); | ||
} | ||
} | ||
} | ||
static addElStyles(el: HTMLElement, styles: { [prop: string]: string | string[] }) { | ||
if (styles instanceof Object) { | ||
for (const s in styles) { | ||
if (styles.hasOwnProperty(s)) { | ||
if (Array.isArray(styles[s])) { | ||
// support fallback value | ||
(styles[s] as string[]).forEach(val => { | ||
el.style[s] = val; | ||
}); | ||
} else { | ||
el.style[s] = styles[s]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
static copyProps(dst, src, props) { | ||
for (let i = 0; i < props.length; i++) { | ||
const p = props[i]; | ||
dst[p] = src[p]; | ||
} | ||
} | ||
|
||
static initEvent<T>(e: DragEvent|MouseEvent, info: {type: string; target?: EventTarget}) { | ||
const kbdProps = 'altKey,ctrlKey,metaKey,shiftKey'.split(','); | ||
const ptProps = 'pageX,pageY,clientX,clientY,screenX,screenY'.split(','); | ||
const evt = {type: info.type}; | ||
const obj = { | ||
button: 0, | ||
which: 0, | ||
buttons: 1, | ||
bubbles: true, | ||
cancelable: true, | ||
originEvent: e, | ||
target: info.target? info.target : e.target | ||
} | ||
if (e instanceof DragEvent) { | ||
Object.assign(obj, {dataTransfer: e.dataTransfer}); | ||
} | ||
DDUtils.copyProps(evt, e, kbdProps); | ||
DDUtils.copyProps(evt, e, ptProps); | ||
DDUtils.copyProps(evt, obj, Object.keys(obj)); | ||
return evt as unknown as T; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// gridstack-dd.ts 2.0.1-dev @preserve | ||
// gridstack-dd.ts 2.0.2 @preserve | ||
|
||
/** | ||
* https://gridstackjs.com/ | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// gridstack.ts 2.0.1-dev @preserve | ||
// gridstack.ts 2.0.2 @preserve | ||
|
||
/** | ||
* https://gridstackjs.com/ | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// types.ts 2.0.1-dev @preserve | ||
// types.ts 2.0.2 @preserve | ||
|
||
/** | ||
* https://gridstackjs.com/ | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// utils.ts 2.0.1-dev @preserve | ||
// utils.ts 2.0.2 @preserve | ||
|
||
/** | ||
* https://gridstackjs.com/ | ||
|