From ef5464fecaf819b7cdf9f385ad8c482027f59f18 Mon Sep 17 00:00:00 2001 From: Maira Bello Date: Fri, 16 May 2014 15:16:59 -0300 Subject: [PATCH] Fix #1816: ScrollViewPaginator partial transition This is fixing the issue described in #1816, which causes diagonal flicks to change the paginator's index even though the image showing up is not updated. To fix this I'm just adding one more check to _beforeHostFlick to ignore flicks that don't happen in the specified flick axis. This is the default behavior of scrollview-base, but paginator-plugin prevents it and runs its own code, so we need the check there as well. --- src/scrollview/HISTORY.md | 4 +++- src/scrollview/js/paginator-plugin.js | 7 ++++++- .../unit/assets/scrollview-paginator-unit-tests.js | 14 +++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/scrollview/HISTORY.md b/src/scrollview/HISTORY.md index e054859d001..639025628d4 100644 --- a/src/scrollview/HISTORY.md +++ b/src/scrollview/HISTORY.md @@ -4,7 +4,9 @@ ScrollView Change History @VERSION@ ------ -* No changes. +* [#1816][]: ScrollViewPaginator partial transition (@mairatma) + +[#1816]: https://github.com/yui/yui3/issues/1816 3.16.0 ------ diff --git a/src/scrollview/js/paginator-plugin.js b/src/scrollview/js/paginator-plugin.js index 01e9bae9769..746b8770415 100644 --- a/src/scrollview/js/paginator-plugin.js +++ b/src/scrollview/js/paginator-plugin.js @@ -349,8 +349,13 @@ Y.extend(PaginatorPlugin, Y.Plugin.Base, { canScroll = paginatorAxis[flickAxis], rtl = host.rtl; - // Store the flick data in the this._host._gesture object so it knows this was a flick if (gesture) { + // The gesture axis is not the flick axis, so do nothing + if (gesture.axis !== flickAxis) { + return new Y.Do.Prevent(); + } + + // Store the flick data in the this._host._gesture object so it knows this was a flick gesture.flick = flick; } diff --git a/src/scrollview/tests/unit/assets/scrollview-paginator-unit-tests.js b/src/scrollview/tests/unit/assets/scrollview-paginator-unit-tests.js index 3c48a2911b6..e519fd3d13f 100644 --- a/src/scrollview/tests/unit/assets/scrollview-paginator-unit-tests.js +++ b/src/scrollview/tests/unit/assets/scrollview-paginator-unit-tests.js @@ -258,6 +258,18 @@ YUI.add('scrollview-paginator-unit-tests', function (Y, NAME) { Y.Assert.isInstanceOf(Y.Do.Prevent, response); }, + "Flicks on the opposite axis should be prevented": function() { + var Test = this, + scrollview = this.scrollview, + paginator = scrollview.pages, + mockEvent = this.mockEvent, + response; + + scrollview._gesture = {axis: 'y'}; + response = paginator._beforeHostFlick(mockEvent); + Y.Assert.isInstanceOf(Y.Do.Prevent, response); + }, + "Flick right should advance the page" : function () { var Test = this, scrollview = this.scrollview, @@ -265,7 +277,7 @@ YUI.add('scrollview-paginator-unit-tests', function (Y, NAME) { mockEvent = this.mockEvent, response; - scrollview._gesture = true; + scrollview._gesture = {axis: 'x'}; response = paginator._beforeHostFlick(mockEvent); Y.Assert.areEqual(1, paginator.get('index'));