mirror of
https://github.com/nextcloud/server.git
synced 2024-09-08 06:43:02 +02:00
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>
This commit is contained in:
parent
a5db0d2825
commit
de4028336a
@ -1631,7 +1631,8 @@ function initCore() {
|
||||
navigationBarSlideGestureAllowed = false;
|
||||
|
||||
if (navigationBarSlideGestureEnabled) {
|
||||
snapper.disable();
|
||||
var endCurrentDrag = true;
|
||||
snapper.disable(endCurrentDrag);
|
||||
|
||||
navigationBarSlideGestureEnabled = false;
|
||||
navigationBarSlideGestureEnablePending = true;
|
||||
|
@ -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);
|
||||
|
6
core/vendor/core.js
vendored
6
core/vendor/core.js
vendored
@ -6704,9 +6704,13 @@ dav.Client.prototype = {
|
||||
|
||||
/**
|
||||
* Disables Snap.js events
|
||||
* @param {Boolean} endCurrentDrag Whether to end the current drag (if any) or not.
|
||||
*/
|
||||
disable: function() {
|
||||
disable: function(endCurrentDrag) {
|
||||
utils.dispatchEvent('disable');
|
||||
if (endCurrentDrag) {
|
||||
this.action.drag.endDrag();
|
||||
}
|
||||
this.action.drag.stopListening();
|
||||
},
|
||||
|
||||
|
6
core/vendor/snapjs/dist/latest/snap.js
vendored
6
core/vendor/snapjs/dist/latest/snap.js
vendored
@ -744,9 +744,13 @@
|
||||
|
||||
/**
|
||||
* Disables Snap.js events
|
||||
* @param {Boolean} endCurrentDrag Whether to end the current drag (if any) or not.
|
||||
*/
|
||||
disable: function() {
|
||||
disable: function(endCurrentDrag) {
|
||||
utils.dispatchEvent('disable');
|
||||
if (endCurrentDrag) {
|
||||
this.action.drag.endDrag();
|
||||
}
|
||||
this.action.drag.stopListening();
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user