Skip to content

Commit 621898b

Browse files
author
Maxime Lafarie
committed
Fix code regression on mouse behavior (text selection) #229
1 parent 9c1602f commit 621898b

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/ngx-smart-modal/src/components/ngx-smart-modal.component.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,23 +146,25 @@ export class NgxSmartModalComponent implements OnInit, OnDestroy, AfterViewInit
146146
* @param posX position X
147147
* @param posY position Y
148148
*/
149-
public setPosition(posX: number, posY: number) {
149+
public setPosition(posX: number, posY: number): NgxSmartModalComponent {
150150
this.positionX = posX;
151151
this.positionY = posY;
152+
153+
return this;
152154
}
153155

154156
/**
155157
* Moves dialog by changing top and left style of modal dialog by offset
156158
* @param offsetX modal's left offset
157159
* @param offsetY modal's top offset
158160
*/
159-
public moveDialog(offsetX: number, offsetY: number) {
160-
if (!this.nsmDialog.length) {
161-
return false;
161+
public moveDialog(offsetX: number, offsetY: number): NgxSmartModalComponent {
162+
if (this.nsmDialog.length) {
163+
this.nsmDialog.last.nativeElement.style.top = (this.nsmDialog.last.nativeElement.offsetTop - offsetY) + 'px';
164+
this.nsmDialog.last.nativeElement.style.left = (this.nsmDialog.last.nativeElement.offsetLeft - offsetX) + 'px';
162165
}
163-
this.nsmDialog.last.nativeElement.style.top = (this.nsmDialog.last.nativeElement.offsetTop - offsetY) + 'px';
164-
this.nsmDialog.last.nativeElement.style.left = (this.nsmDialog.last.nativeElement.offsetLeft - offsetX) + 'px';
165-
return true;
166+
167+
return this;
166168
}
167169

168170
/**
@@ -172,7 +174,7 @@ export class NgxSmartModalComponent implements OnInit, OnDestroy, AfterViewInit
172174
@HostListener('document:mousedown', ['$event'])
173175
private startDrag(e: MouseEvent) {
174176
if (!this.nsmContent.length || !this.draggable) {
175-
return false;
177+
return;
176178
}
177179

178180
const src = e.srcElement as HTMLElement;
@@ -183,11 +185,9 @@ export class NgxSmartModalComponent implements OnInit, OnDestroy, AfterViewInit
183185
this.dragging = true;
184186
this.setPosition(e.clientX, e.clientY);
185187

186-
return true;
188+
return;
187189
}
188190
}
189-
190-
return false;
191191
}
192192

193193
/**
@@ -197,8 +197,9 @@ export class NgxSmartModalComponent implements OnInit, OnDestroy, AfterViewInit
197197
@HostListener('document:mousemove', ['$event'])
198198
private elementDrag(e: MouseEvent) {
199199
if (!this.dragging || !this.nsmDialog.length) {
200-
return false;
200+
return;
201201
}
202+
202203
e.preventDefault();
203204

204205
const offsetX = this.positionX - e.clientX;
@@ -207,8 +208,6 @@ export class NgxSmartModalComponent implements OnInit, OnDestroy, AfterViewInit
207208
this.moveDialog(offsetX, offsetY);
208209

209210
this.setPosition(e.clientX, e.clientY);
210-
211-
return true;
212211
}
213212

214213
/**

0 commit comments

Comments
 (0)