Skip to content

Commit 096c08b

Browse files
committed
fix: handle coordinates via e.x, e.y or e.clientX, e.clientY - otherwise it causes issues
1 parent 572bfcf commit 096c08b

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
22
"name": "ng2-branchy",
3-
"version": "1.0.0",
4-
"description": "angular2 component for visualizing a tree",
3+
"version": "0.0.1",
4+
"description": "angular2 component for visualizing data that can be naturally represented as a tree",
55
"main": "ng2-branchy.js",
66
"scripts": {
7-
"preinstall": "rm -rf ./typings && typings install",
7+
"preinstall": "typings install",
88
"dev": "webpack-dev-server --inline --hot",
99
"build": "webpack"
1010
},
1111
"author": "rychko.georgiy@gmail.com",
12-
"license": "ISC",
12+
"license": "MIT",
1313
"dependencies": {
14-
"@angular/common": "2.0.0-rc.1",
15-
"@angular/compiler": "2.0.0-rc.1",
16-
"@angular/core": "2.0.0-rc.1",
17-
"@angular/platform-browser": "2.0.0-rc.1",
18-
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
14+
"@angular/common": "2.0.0-rc.2",
15+
"@angular/compiler": "2.0.0-rc.2",
16+
"@angular/core": "2.0.0-rc.2",
17+
"@angular/platform-browser": "2.0.0-rc.2",
18+
"@angular/platform-browser-dynamic": "2.0.0-rc.2",
1919
"es6-shim": "0.35.0",
2020
"file-loader": "0.8.5",
2121
"font-awesome": "4.6.1",

src/node-draggable.directive.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ export class NodeDraggableDirective implements OnDestroy {
5050

5151
private handleDragEnter(e: DragEvent): any {
5252
e.preventDefault();
53-
if (this.containsElementAt(e.pageX, e.pageY)) {
53+
if (this.containsElementAt(e)) {
5454
this.addClass('over-drop-target');
5555
}
5656
}
5757

5858
private handleDragLeave(e: DragEvent): any {
59-
if (!this.containsElementAt(e.pageX, e.pageY)) {
59+
if (!this.containsElementAt(e)) {
6060
this.removeClass('over-drop-target');
6161
}
6262
}
@@ -78,15 +78,18 @@ export class NodeDraggableDirective implements OnDestroy {
7878

7979
private isDropPossible(e: DragEvent) {
8080
const capturedNode = this.nodeDraggableService.getCapturedNode();
81-
return capturedNode && capturedNode.canBeDroppedAt(this.nodeDraggable) && this.containsElementAt(e.pageX, e.pageY);
81+
return capturedNode
82+
&& capturedNode.canBeDroppedAt(this.nodeDraggable)
83+
&& this.containsElementAt(e);
8284
}
8385

8486
private handleDragEnd(e: DragEvent): any {
8587
this.removeClass('over-drop-target');
8688
this.nodeDraggableService.releaseCapturedNode();
8789
}
8890

89-
private containsElementAt(x: number, y: number): boolean {
91+
private containsElementAt(e: DragEvent): boolean {
92+
const {x = e.clientX, y = e.clientY} = e;
9093
return this.nodeNativeElement.contains(document.elementFromPoint(x, y));
9194
}
9295

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ config.module = {
7474

7575
config.plugins = [
7676
new HtmlWebpackPlugin({
77-
title: 'ng2-tree',
77+
title: 'ng2-branchy',
7878
template: 'demo/index.ejs',
7979
inject: 'body'
8080
}),

0 commit comments

Comments
 (0)