summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-12-14 18:12:12 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-12-14 21:42:39 +0100
commitde4028336aca79ab243fc0d1ad3a904d4cc72299 (patch)
tree7e02339ad33929ddeba957c5499a9b934f285441 /core/js
parenta5db0d2825424f505f9139af6d439108b9e07782 (diff)
downloadnextcloud-server-de4028336aca79ab243fc0d1ad3a904d4cc72299.tar.gz
nextcloud-server-de4028336aca79ab243fc0d1ad3a904d4cc72299.zip
Force the drag to end when the navigation bar Snap is disabled by an app
When a Snap was disabled it stopped listening to the events, but if a drag gesture was being performed it was kept as active. Thus, when the Snap was enabled again move events were handled as if the Snap had never been disabled, causing the gesture handling to continue where it was left. When the Snap for the navigation bar is disabled by an app it could be as a result of a different gesture being recognized by the app (for example, a vertical swipe) once both gestures have started. In that case when the other gesture ends and the Snap is enabled again any pointer movement will cause the navigation bar to slide until an "up" event is triggered again (obviously not the desired behaviour). Due to all this now when the Snap for the navigation bar is disabled by an app the current drag gesture for the navigation bar is ended. Note that this was added as a parameter to "Snap.disable()" instead of done unconditionally to keep back-compatibility with the previous behaviour (probably not really needed as it is unlikely that any app is using the Snap library relying on that behaviour... but just in case). Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'core/js')
-rw-r--r--core/js/js.js3
-rw-r--r--core/js/tests/specs/coreSpec.js5
2 files changed, 7 insertions, 1 deletions
diff --git a/core/js/js.js b/core/js/js.js
index c9427bf533d..a9180663405 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1631,7 +1631,8 @@ function initCore() {
navigationBarSlideGestureAllowed = false;
if (navigationBarSlideGestureEnabled) {
- snapper.disable();
+ var endCurrentDrag = true;
+ snapper.disable(endCurrentDrag);
navigationBarSlideGestureEnabled = false;
navigationBarSlideGestureEnablePending = true;
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index d2bb2a504e9..b6c617303cf 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -1175,6 +1175,7 @@ describe('Core base tests', function() {
expect(snapperStub.enable.calledOnce).toBe(true);
expect(snapperStub.disable.calledOnce).toBe(true);
+ expect(snapperStub.disable.alwaysCalledWithExactly(true)).toBe(true);
expect(snapperStub.close.called).toBe(false);
});
it('is not disabled again when disallowing the gesture twice on a narrow screen', function() {
@@ -1190,6 +1191,7 @@ describe('Core base tests', function() {
expect(snapperStub.enable.calledOnce).toBe(true);
expect(snapperStub.disable.calledOnce).toBe(true);
+ expect(snapperStub.disable.alwaysCalledWithExactly(true)).toBe(true);
expect(snapperStub.close.called).toBe(false);
OC.disallowNavigationBarSlideGesture();
@@ -1211,6 +1213,7 @@ describe('Core base tests', function() {
expect(snapperStub.enable.calledOnce).toBe(true);
expect(snapperStub.disable.calledOnce).toBe(true);
+ expect(snapperStub.disable.alwaysCalledWithExactly(true)).toBe(true);
expect(snapperStub.close.called).toBe(false);
OC.allowNavigationBarSlideGesture();
@@ -1232,6 +1235,7 @@ describe('Core base tests', function() {
expect(snapperStub.enable.calledOnce).toBe(true);
expect(snapperStub.disable.calledOnce).toBe(true);
+ expect(snapperStub.disable.alwaysCalledWithExactly(true)).toBe(true);
expect(snapperStub.close.called).toBe(false);
OC.allowNavigationBarSlideGesture();
@@ -1435,6 +1439,7 @@ describe('Core base tests', function() {
expect(snapperStub.enable.calledOnce).toBe(true);
expect(snapperStub.disable.calledTwice).toBe(true);
+ expect(snapperStub.disable.getCall(1).calledWithExactly(true)).toBe(true);
});
it('is disabled when resizing to a wide screen', function() {
viewport.set(480);