Skip to content

Commit

Permalink
Merge pull request #1402 from adumesny/v2
Browse files Browse the repository at this point in the history
v2.0.2
  • Loading branch information
adumesny authored Oct 6, 2020
2 parents b9d33a7 + 32b62cd commit a858509
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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>
```
Expand Down
9 changes: 7 additions & 2 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Change log
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*

- [2.0.1-dev](#201-dev)
- [2.0.2-dev](#202-dev)
- [2.0.2 (2020-10-05)](#202-2020-10-05)
- [2.0.1 (2020-09-26)](#201-2020-09-26)
- [2.0.0 (2020-09-07)](#200-2020-09-07)
- [1.2.1 (2020-09-04)](#121-2020-09-04)
Expand Down Expand Up @@ -38,7 +39,11 @@ Change log

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## 2.0.1-dev
## 2.0.2-dev

- TBD

## 2.0.2 (2020-10-05)

- fix `animate` to not re-create CSS style each time (should be faster too) and made it default now since so much nicer. pass `{animate: false}` grid options if you want instant again [937](https://github.com/gridstack/gridstack.js/issues/937)
- fix `resizable: { handles: ...}` forcing `alwaysShowResizeHandle` behavior [1373](https://github.com/gridstack/gridstack.js/issues/1373)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gridstack",
"version": "2.0.1-dev",
"version": "2.0.2",
"description": "TypeScript/Javascript lib for dashboard layout and creation, no external dependencies, with many wrappers (React, Angular, Ember, knockout...)",
"main": "./dist/gridstack.js",
"types": "./dist/gridstack.d.ts",
Expand Down
87 changes: 87 additions & 0 deletions src/dragdrop/dd-utils.ts
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;
}
}
2 changes: 1 addition & 1 deletion src/gridstack-dd.ts
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/
Expand Down
2 changes: 1 addition & 1 deletion src/gridstack-engine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// gridstack-engine.ts 2.0.1-dev @preserve
// gridstack-engine.ts 2.0.2 @preserve

/**
* https://gridstackjs.com/
Expand Down
2 changes: 1 addition & 1 deletion src/gridstack.ts
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/
Expand Down
2 changes: 1 addition & 1 deletion src/jq/gridstack-dd-jqueryui.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// gridstack-dd-jqueryui.ts 2.0.1-dev @preserve
// gridstack-dd-jqueryui.ts 2.0.2 @preserve

/** JQuery UI Drag&Drop plugin
* https://gridstackjs.com/
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
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/
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
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/
Expand Down

0 comments on commit a858509

Please sign in to comment.