Skip to content

Commit

Permalink
fix(events): trigger events with the correct id and not identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
yoannmoinet committed Oct 27, 2016
1 parent fbf6398 commit 17f0fe6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions src/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ Collection.prototype.bindNipple = function (nipple) {
var type;
// Bubble up identified events.
var handler = function (evt, data) {
// Identify the event type with the nipple's identifier.
type = evt.type + ' ' + evt.target.identifier + ':' + evt.type;
// Identify the event type with the nipple's id.
type = evt.type + ' ' + data.id + ':' + evt.type;
self.trigger(type, data);
};

Expand Down Expand Up @@ -256,7 +256,7 @@ Collection.prototype.processOnStart = function (evt) {
var process = function (nip) {
// Trigger the start.
nip.trigger('start', nip);
self.trigger('start ' + nip.identifier + ':start', nip);
self.trigger('start ' + nip.id + ':start', nip);

nip.show();
if (pressure > 0) {
Expand Down Expand Up @@ -387,7 +387,7 @@ Collection.prototype.processOnMove = function (evt) {

// Send everything to everyone.
nipple.trigger('move', toSend);
self.trigger('move ' + identifier + ':move', toSend);
self.trigger('move ' + nipple.id + ':move', toSend);
};

Collection.prototype.processOnEnd = function (evt) {
Expand All @@ -403,14 +403,14 @@ Collection.prototype.processOnEnd = function (evt) {

if (!opts.dataOnly) {
nipple.hide(function () {
if (opts.mode === 'dynamic') {
nipple.trigger('removed', nipple);
self.trigger('removed ' + identifier + ':removed', nipple);
self.manager.trigger('removed ' + identifier + ':removed',
nipple);
nipple.destroy();
}
});
if (opts.mode === 'dynamic') {
nipple.trigger('removed', nipple);
self.trigger('removed ' + nipple.id + ':removed', nipple);
self.manager
.trigger('removed ' + nipple.id + ':removed', nipple);
nipple.destroy();
}
});
}

// Clear the pressure interval reader
Expand All @@ -421,7 +421,7 @@ Collection.prototype.processOnEnd = function (evt) {
nipple.resetDirection();

nipple.trigger('end', nipple);
self.trigger('end ' + identifier + ':end', nipple);
self.trigger('end ' + nipple.id + ':end', nipple);

// Remove identifier from our bank.
if (self.ids.indexOf(identifier) >= 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Manager.prototype.bindCollection = function (collection) {
// Bubble up identified events.
var handler = function (evt, data) {
// Identify the event type with the nipple's identifier.
type = evt.type + ' ' + evt.target.id + ':' + evt.type;
type = evt.type + ' ' + data.id + ':' + evt.type;
self.trigger(type, data);
};

Expand Down

0 comments on commit 17f0fe6

Please sign in to comment.