Skip to content

Commit

Permalink
Merge pull request #170 from TalkFusionDev/ignore-propagation
Browse files Browse the repository at this point in the history
Passes through events that begin on elementsWithInteraction instead of stoping propagation completely
  • Loading branch information
Anaphase committed Aug 30, 2015
2 parents 516a12a + 64c27eb commit 2598927
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/jquery.pep.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@
this.onStartEvent = function(ev){ self.handleStart(ev); };
this.$el.on(this.startTrigger, this.onStartEvent);

// Prevent start events from being gobbled by elements that should allow user interaction
this.onStartEventOnElementsWithInteraction = function(ev){ ev.stopPropagation(); };
// Add a flag to events that start on elements that should allow interaction
// so handleStart() can ignore them but allow them to bubble up through the DOM
this.onStartEventOnElementsWithInteraction = function(ev){ ev.ignorePropagation = true; };
this.$el.on(
this.startTrigger,
this.options.elementsWithInteraction,
Expand Down Expand Up @@ -190,6 +191,11 @@
// once this.startTrigger occurs, handle all of the logic
// that must go on. This is where Pep's heavy lifting is done.
Pep.prototype.handleStart = function(ev) {

// ignorePropagation is set to true if the event originates from an element
// listed in this.options.elementsWithInteraction
if (ev.ignorePropagation) return;

var self = this;

// only continue chugging if our start event is a valid move event.
Expand Down Expand Up @@ -317,7 +323,7 @@
this.$el.addClass('pep-start');
this.options.start.call(this, this.startEvent, this);
}

// Move before calculate position and fire events
this.doMoveTo(dx, dy);

Expand Down Expand Up @@ -518,7 +524,7 @@
ev.pep.x = ev.originalEvent.touches[0].pageX;
ev.pep.y = ev.originalEvent.touches[0].pageY;
ev.pep.type = ev.type;

}
else if ( this.isPointerEventCompatible() || !this.isTouch(ev) ) {

Expand All @@ -533,7 +539,7 @@
ev.pep.type = ev.type;

}

return ev;
};

Expand Down

0 comments on commit 2598927

Please sign in to comment.