Skip to content

Commit

Permalink
BugFix: wrong event target was used
Browse files Browse the repository at this point in the history
  • Loading branch information
knee-cola committed Jan 4, 2018
1 parent 2f46159 commit a55448e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
14 changes: 10 additions & 4 deletions README.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@

This is an ES6 re-implementation of [jQuery-menu-aim](https://github.com/kamens/jQuery-menu-aim) by [Ben Kamens](https://github.com/kamens).

It has been written so that it can be used/imported as a regular ES6 module ... like so:
It has been written so that it can be used/imported as a regular ES6 module ... like so (a more detailed example can be found at the end of this document):

```javascript
import { MenuAim } from 'es6-menu-aim';

let menuRoot = document.getElementById('menuRoot');
let menu_root = document.getElementById('menuRoot');

let menu_aim_config = {
clickRow:function (mouseEvent, targetRow) {
console.log('menu item was clicked!');
}
};

let menu_aim = new MenuAim(menuRoot);
let menu_aim = new MenuAim(menuRoot, menu_aim_config);
```

Unlike the original *jQuery-menu-aim*, this one doesn't use jQuery ... in fact it has no dependencies.
Unlike the original **jQuery-menu-aim**, this one doesn't use jQuery ... in fact it has no dependencies.

## Why would I want use this?

Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@

This is an ES6 re-implementation of [jQuery-menu-aim](https://github.com/kamens/jQuery-menu-aim) by [Ben Kamens](https://github.com/kamens).

It has been written so that it can be used/imported as a regular ES6 module ... like so:
It has been written so that it can be used/imported as a regular ES6 module ... like so (a more detailed example can be found at the end of this document):

```javascript
import { MenuAim } from 'es6-menu-aim';

let menuRoot = document.getElementById('menuRoot');
let menu_root = document.getElementById('menuRoot');

let menu_aim_config = {
clickRow:function (mouseEvent, targetRow) {
console.log('menu item was clicked!');
}
};

let menu_aim = new MenuAim(menuRoot);
let menu_aim = new MenuAim(menuRoot, menu_aim_config);
```

Unlike the original *jQuery-menu-aim*, this one doesn't use jQuery ... in fact it has no dependencies.
Unlike the original **jQuery-menu-aim**, this one doesn't use jQuery ... in fact it has no dependencies.

## Why would I want use this?

Expand Down
12 changes: 6 additions & 6 deletions lib/es6-menu-aim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ class MenuAim {
this.timeoutId = null;
}

this.options.enter(ev.target);
this.options.enter(ev.currentTarget);

this.possiblyActivate(<HTMLElement>ev.target);
this.possiblyActivate(<HTMLElement>ev.currentTarget);
}


mouseleaveRow(ev:MouseEvent):void {
this.options.exit(ev.target);
this.options.exit(ev.currentTarget);
}

/**
Expand All @@ -176,11 +176,11 @@ class MenuAim {
*/
clickRow(ev:MouseEvent):void {

if(ev.target !== this.activeRow) {
this.activate(<HTMLElement>ev.target);
if(ev.currentTarget !== this.activeRow) {
this.activate(<HTMLElement>ev.currentTarget);
}

this.options.clickRow(ev, ev.target); // pozovi registrirani event handler
this.options.clickRow(ev, ev.currentTarget); // pozovi registrirani event handler
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "es6-menu-aim",
"version": "1.0.1",
"version": "1.0.2",
"description": "ES6 re-implementation of jQuery-menu-aim",
"main": "dist/es6-menu-aim.js",
"types": "dist/es6-menu-aim.d.ts",
Expand Down

0 comments on commit a55448e

Please sign in to comment.