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

Skip to content

Commit 6f2fce4

Browse files
authored
Merge pull request #2822 from adumesny/master
convert code to const
2 parents 5f2673e + 408af25 commit 6f2fce4

7 files changed

+192
-191
lines changed

src/dd-draggable.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
176176
/** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */
177177
protected _mouseMove(e: DragEvent): boolean {
178178
// console.log(`${count++} move ${e.x},${e.y}`)
179-
let s = this.mouseDownEvent;
179+
const s = this.mouseDownEvent;
180180
this.lastDrag = e;
181181

182182
if (this.dragging) {
@@ -196,7 +196,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
196196
this.dragging = true;
197197
DDManager.dragElement = this;
198198
// if we're dragging an actual grid item, set the current drop as the grid (to detect enter/leave)
199-
let grid = this.el.gridstackNode?.grid;
199+
const grid = this.el.gridstackNode?.grid;
200200
if (grid) {
201201
DDManager.dropElement = (grid.el as DDElementHost).ddElement.ddDroppable;
202202
} else {
@@ -330,16 +330,16 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
330330
/** @internal restore back the original style before dragging */
331331
protected _removeHelperStyle(): DDDraggable {
332332
this.helper.classList.remove('ui-draggable-dragging');
333-
let node = (this.helper as GridItemHTMLElement)?.gridstackNode;
333+
const node = (this.helper as GridItemHTMLElement)?.gridstackNode;
334334
// don't bother restoring styles if we're gonna remove anyway...
335335
if (!node?._isAboutToRemove && this.dragElementOriginStyle) {
336-
let helper = this.helper;
336+
const helper = this.helper;
337337
// don't animate, otherwise we animate offseted when switching back to 'absolute' from 'fixed'.
338338
// TODO: this also removes resizing animation which doesn't have this issue, but others.
339339
// Ideally both would animate ('move' would immediately restore 'absolute' and adjust coordinate to match,
340340
// then trigger a delay (repaint) to restore to final dest with animate) but then we need to make sure 'resizestop'
341341
// is called AFTER 'transitionend' event is received (see https://github.com/gridstack/gridstack.js/issues/2033)
342-
let transition = this.dragElementOriginStyle['transition'] || null;
342+
const transition = this.dragElementOriginStyle['transition'] || null;
343343
helper.style.transition = this.dragElementOriginStyle['transition'] = 'none'; // can't be NULL #1973
344344
DDDraggable.originStyleProp.forEach(prop => helper.style[prop] = this.dragElementOriginStyle[prop] || null);
345345
setTimeout(() => helper.style.transition = transition, 50); // recover animation from saved vars after a pause (0 isn't enough #1973)
@@ -350,7 +350,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
350350

351351
/** @internal updates the top/left position to follow the mouse */
352352
protected _dragFollow(e: DragEvent): void {
353-
let containmentRect = { left: 0, top: 0 };
353+
const containmentRect = { left: 0, top: 0 };
354354
// if (this.helper.style.position === 'absolute') { // we use 'fixed'
355355
// const { left, top } = this.helperContainment.getBoundingClientRect();
356356
// containmentRect = { left, top };

src/dd-gridstack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ export class DDGridStack {
150150

151151
/** @internal returns a list of DD elements, creating them on the fly by default */
152152
protected _getDDElements(els: GridStackElement, create = true): DDElement[] {
153-
let hosts = Utils.getElements(els) as DDElementHost[];
153+
const hosts = Utils.getElements(els) as DDElementHost[];
154154
if (!hosts.length) return [];
155-
let list = hosts.map(e => e.ddElement || (create ? DDElement.init(e) : null));
155+
const list = hosts.map(e => e.ddElement || (create ? DDElement.init(e) : null));
156156
if (!create) { list.filter(d => d); } // remove nulls
157157
return list;
158158
}

src/dd-resizable-handle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class DDResizableHandle {
7878

7979
/** @internal */
8080
protected _mouseMove(e: MouseEvent): void {
81-
let s = this.mouseDownEvent;
81+
const s = this.mouseDownEvent;
8282
if (this.moving) {
8383
this._triggerEvent('move', e);
8484
} else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 2) {

src/dd-resizable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
9696
}
9797

9898
public updateOption(opts: DDResizableOpt): DDResizable {
99-
let updateHandles = (opts.handles && opts.handles !== this.option.handles);
100-
let updateAutoHide = (opts.autoHide && opts.autoHide !== this.option.autoHide);
99+
const updateHandles = (opts.handles && opts.handles !== this.option.handles);
100+
const updateAutoHide = (opts.autoHide && opts.autoHide !== this.option.autoHide);
101101
Object.keys(opts).forEach(key => this.option[key] = opts[key]);
102102
if (updateHandles) {
103103
this._removeHandlers();

0 commit comments

Comments
 (0)