Panel: Do not close in response to a default-prevented swipe event #6947

Closed
wants to merge 3 commits into from

4 participants

@gabrielschulhof

Fixes gh-6925

Note: This fix requires #6946 even though the automated tests pass, because in the automated tests I trigger swipe manually, with .trigger( "swipeleft" ) instead of calculating it from mouse events using the swipe special event. #6946 ensures that the swipe special event triggers correctly.

@coveralls

Coverage Status

Coverage increased (+0.03%) when pulling 3045191 on 6925-panel-ignores-default-prevented-swipe into cfc1195 on master.

@Ruffio

Shouldn't this PR be closed as it has been merged into master?

@gabrielschulhof

@Ruffio this has not yet been merged into master, AFAIK.

@arschmitz arschmitz commented on an outdated diff Aug 22, 2014
js/widgets/panel.js
- // on swipe, close the panel
- if ( !!self.options.swipeClose ) {
- if ( self.options.position === "left" ) {
- area.on( "swipeleft.panel", function(/* e */) {
- self.close();
+ // close the panel on swipe if the swipe event's default is not prevented
@arschmitz
jQuery Foundation member

capital for first word in comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@arschmitz arschmitz commented on an outdated diff Aug 22, 2014
js/widgets/panel.js
- // on swipe, close the panel
- if ( !!self.options.swipeClose ) {
- if ( self.options.position === "left" ) {
- area.on( "swipeleft.panel", function(/* e */) {
- self.close();
+ // close the panel on swipe if the swipe event's default is not prevented
+ if ( !!this.options.swipeClose ) {
@arschmitz
jQuery Foundation member

this is a boolean option no need for double inversion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@coveralls

Coverage Status

Coverage increased (+0.11%) when pulling 2ce29a8 on 6925-panel-ignores-default-prevented-swipe into 2dd9cf4 on master.

@arschmitz arschmitz commented on an outdated diff Nov 6, 2014
js/widgets/panel.js
});
} else {
- area.on( "swiperight.panel", function(/* e */) {
- self.close();
+ this._on( area, {
+ swiperight: "_handleSwipe"
});
}
@arschmitz
jQuery Foundation member

This whole if...else can be simplified to

var event = {};

event[ "swipe" + this.options.position ] = "_handleSwipe";
this._on( area, event );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@arschmitz
jQuery Foundation member

👍

@gabrielschulhof gabrielschulhof deleted the 6925-panel-ignores-default-prevented-swipe branch Dec 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment