Skip to content

Commit a5b330f

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

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
@@ -145,23 +145,25 @@ export class NgxSmartModalComponent implements OnInit, OnDestroy, AfterViewInit
145145
* @param posX position X
146146
* @param posY position Y
147147
*/
148-
public setPosition(posX: number, posY: number) {
148+
public setPosition(posX: number, posY: number): NgxSmartModalComponent {
149149
this.positionX = posX;
150150
this.positionY = posY;
151+
152+
return this;
151153
}
152154

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

167169
/**
@@ -171,7 +173,7 @@ export class NgxSmartModalComponent implements OnInit, OnDestroy, AfterViewInit
171173
@HostListener('document:mousedown', ['$event'])
172174
private startDrag(e: MouseEvent) {
173175
if (!this.nsmContent.length || !this.draggable) {
174-
return false;
176+
return;
175177
}
176178

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

185-
return true;
187+
return;
186188
}
187189
}
188-
189-
return false;
190190
}
191191

192192
/**
@@ -196,8 +196,9 @@ export class NgxSmartModalComponent implements OnInit, OnDestroy, AfterViewInit
196196
@HostListener('document:mousemove', ['$event'])
197197
private elementDrag(e: MouseEvent) {
198198
if (!this.dragging || !this.nsmDialog.length) {
199-
return false;
199+
return;
200200
}
201+
201202
e.preventDefault();
202203

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

208209
this.setPosition(e.clientX, e.clientY);
209-
210-
return true;
211210
}
212211

213212
/**

0 commit comments

Comments
 (0)