Skip to content

Commit 0cdc1f7

Browse files
author
Maxime Lafarie
committed
Fix code regression on mouse behavior (text selection) #229
1 parent 90576a9 commit 0cdc1f7

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
@@ -147,23 +147,25 @@ export class NgxSmartModalComponent implements OnInit, OnDestroy, AfterViewInit
147147
* @param posX position X
148148
* @param posY position Y
149149
*/
150-
public setPosition(posX: number, posY: number) {
150+
public setPosition(posX: number, posY: number): NgxSmartModalComponent {
151151
this.positionX = posX;
152152
this.positionY = posY;
153+
154+
return this;
153155
}
154156

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

169171
/**
@@ -173,7 +175,7 @@ export class NgxSmartModalComponent implements OnInit, OnDestroy, AfterViewInit
173175
@HostListener('document:mousedown', ['$event'])
174176
private startDrag(e: MouseEvent) {
175177
if (!this.nsmContent.length || !this.draggable) {
176-
return false;
178+
return;
177179
}
178180

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

187-
return true;
189+
return;
188190
}
189191
}
190-
191-
return false;
192192
}
193193

194194
/**
@@ -198,8 +198,9 @@ export class NgxSmartModalComponent implements OnInit, OnDestroy, AfterViewInit
198198
@HostListener('document:mousemove', ['$event'])
199199
private elementDrag(e: MouseEvent) {
200200
if (!this.dragging || !this.nsmDialog.length) {
201-
return false;
201+
return;
202202
}
203+
203204
e.preventDefault();
204205

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

210211
this.setPosition(e.clientX, e.clientY);
211-
212-
return true;
213212
}
214213

215214
/**

0 commit comments

Comments
 (0)