Skip to content

Commit

Permalink
off listener issue fixed #11
Browse files Browse the repository at this point in the history
issue:
the issue was that the bind method returns a new function, when the off method is called with
'removeListeners' it can not find a matching function

fix:
the release event type is checked and the correct event config object is selected passed
on its value

other changes:
* changelog
* version number in package.json
  • Loading branch information
httpete-ire committed Aug 11, 2015
1 parent b9369bd commit 6619904
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ set the start position of the revealer in percentage (default : 50)

# Change log

#### 0.1.2
* fix release listener issue [#11](/../../issues/11)

#### 0.1.1
* fix offset issue #6
* updated gulp task to output to a single destination
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": "revealer",
"version": "0.1.1",
"version": "0.1.2",
"description": "An Angular directive that overlays an image on another",
"main": "dist/revealer.min.js",
"scripts": {
Expand Down
7 changes: 5 additions & 2 deletions src/revealer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

// when the release action is triggered unbind
// event listerners on drag an elements
$document.on(eventConfig.release, removeListeners.bind(null, eventConfig));
$document.on(eventConfig.release, removeListeners);
});

});
Expand Down Expand Up @@ -130,7 +130,10 @@
* @param {Object} config
* @param {Event object} e
*/
function removeListeners(config, e) {
function removeListeners(e) {
var configIndex = (e.type === multipleEvents[0].release) ? 0 : 1;
var config = multipleEvents[configIndex];

handle.removeClass(handleClass);
$document.off(config.move, handleDrag);
$document.off(config.release, removeListeners);
Expand Down

0 comments on commit 6619904

Please sign in to comment.