Skip to content

Commit

Permalink
Merge pull request #2822 from adumesny/master
Browse files Browse the repository at this point in the history
convert code to const
  • Loading branch information
adumesny authored Oct 15, 2024
2 parents 5f2673e + 408af25 commit 6f2fce4
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 191 deletions.
12 changes: 6 additions & 6 deletions src/dd-draggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
/** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */
protected _mouseMove(e: DragEvent): boolean {
// console.log(`${count++} move ${e.x},${e.y}`)
let s = this.mouseDownEvent;
const s = this.mouseDownEvent;
this.lastDrag = e;

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

/** @internal updates the top/left position to follow the mouse */
protected _dragFollow(e: DragEvent): void {
let containmentRect = { left: 0, top: 0 };
const containmentRect = { left: 0, top: 0 };
// if (this.helper.style.position === 'absolute') { // we use 'fixed'
// const { left, top } = this.helperContainment.getBoundingClientRect();
// containmentRect = { left, top };
Expand Down
4 changes: 2 additions & 2 deletions src/dd-gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ export class DDGridStack {

/** @internal returns a list of DD elements, creating them on the fly by default */
protected _getDDElements(els: GridStackElement, create = true): DDElement[] {
let hosts = Utils.getElements(els) as DDElementHost[];
const hosts = Utils.getElements(els) as DDElementHost[];
if (!hosts.length) return [];
let list = hosts.map(e => e.ddElement || (create ? DDElement.init(e) : null));
const list = hosts.map(e => e.ddElement || (create ? DDElement.init(e) : null));
if (!create) { list.filter(d => d); } // remove nulls
return list;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dd-resizable-handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class DDResizableHandle {

/** @internal */
protected _mouseMove(e: MouseEvent): void {
let s = this.mouseDownEvent;
const s = this.mouseDownEvent;
if (this.moving) {
this._triggerEvent('move', e);
} else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 2) {
Expand Down
4 changes: 2 additions & 2 deletions src/dd-resizable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
}

public updateOption(opts: DDResizableOpt): DDResizable {
let updateHandles = (opts.handles && opts.handles !== this.option.handles);
let updateAutoHide = (opts.autoHide && opts.autoHide !== this.option.autoHide);
const updateHandles = (opts.handles && opts.handles !== this.option.handles);
const updateAutoHide = (opts.autoHide && opts.autoHide !== this.option.autoHide);
Object.keys(opts).forEach(key => this.option[key] = opts[key]);
if (updateHandles) {
this._removeHandlers();
Expand Down
Loading

0 comments on commit 6f2fce4

Please sign in to comment.