Skip to content

Commit

Permalink
fix: prevent text from being selected when resizing an element
Browse files Browse the repository at this point in the history
Closes #22
  • Loading branch information
Matt Lewis committed Oct 29, 2016
1 parent ac10a14 commit 5571069
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion demo/demo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {ResizeEvent} from './../src';
position: absolute;
bottom: 10px;
right: 10px;
-webkit-user-drag: none;
}
`],
template: `
Expand Down
14 changes: 8 additions & 6 deletions src/resizable.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,11 @@ export class Resizable implements OnInit, AfterViewInit {
}
};

this.mousemove.subscribe(({mouseX, mouseY}) => {
this.mousemove.subscribe(({mouseX, mouseY, event}) => {

if (currentResize) {
event.preventDefault();
}

const resizeEdges: Edges = getResizeEdges({mouseX, mouseY, elm: this.elm, allowedEdges: this.resizeEdges});
const cursor: string = getResizeCursor(resizeEdges);
Expand Down Expand Up @@ -436,8 +440,6 @@ export class Resizable implements OnInit, AfterViewInit {
this.renderer.setElementStyle(currentResize.clonedNode, 'position', 'fixed');
this.renderer.setElementStyle(currentResize.clonedNode, 'left', `${currentResize.startingRect.left}px`);
this.renderer.setElementStyle(currentResize.clonedNode, 'top', `${currentResize.startingRect.top}px`);
this.renderer.setElementStyle(currentResize.clonedNode, 'user-drag', 'none');
this.renderer.setElementStyle(currentResize.clonedNode, '-webkit-user-drag', 'none');
}
this.resizeStart.emit({
edges: getEdgesDiff({edges, initialRectangle: startingRect, newRectangle: startingRect}),
Expand Down Expand Up @@ -490,9 +492,9 @@ export class Resizable implements OnInit, AfterViewInit {
/**
* @private
*/
@HostListener('document:mousemove', ['$event.clientX', '$event.clientY'])
private onMousemove(mouseX: number, mouseY: number): void {
this.mousemove.next({mouseX, mouseY});
@HostListener('document:mousemove', ['$event'])
private onMousemove(event: MouseEvent): void {
this.mousemove.next({mouseX: event.clientX, mouseY: event.clientY, event});
}

}

0 comments on commit 5571069

Please sign in to comment.