Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1740: Scrollview scrolltoindex breaks after a click-drag down #1827

Open
wants to merge 1 commit into
base: dev-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/scrollview/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ ScrollView Change History
@VERSION@
------

* No changes.
* [#1740][]: Scrollview scrolltoindex breaks after a click-drag down (@mairatma)

[#1740]: https://github.com/yui/yui3/issues/1740

3.16.0
------
Expand Down
11 changes: 10 additions & 1 deletion src/scrollview/js/paginator-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ Y.extend(PaginatorPlugin, Y.Plugin.Base, {
pageNodes = paginator._getPageNodes(),
gestureAxis;

if (gesture) {
// Only look at the last gesture if we're not scrolling to a specific index.
if (gesture && !this._scrollingToIndex) {
gestureAxis = gesture.axis;

// Null the opposite axis so it won't be modified by host.scrollTo
Expand Down Expand Up @@ -599,11 +600,19 @@ Y.extend(PaginatorPlugin, Y.Plugin.Base, {
// Makes sure the viewport nodes are visible
paginator._showNodes(pageNode);

// Set the flag to indicate that we're scrolling to a specific index,
// so _beforeHostScrollTo will not try to adjust the coordinates according
// to the last gesture.
paginator._scrollingToIndex = true;

// Scroll to the offset
host.set(scrollAxis, scrollOffset, {
duration: duration,
easing: easing
});

// Reset the flag to the original value.
paginator._scrollingToIndex = false;
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,15 @@ YUI.add('scrollview-paginator-unit-tests', function (Y, NAME) {
Y.Assert.isNull(response.newArgs[0]);
},

'_beforeHostScrollTo through scrollToIndex should keep original values': function() {
var scrollview = this.scrollview = renderNewScrollview('x', 'x');

scrollview._gesture = { axis: 'y' };
Y.Assert.areEqual(0, scrollview.get('scrollX'));
scrollview.pages.scrollToIndex(1);
Y.Assert.areEqual(300, scrollview.get('scrollX'));
},

"Gestures against the grain should select the index page's node to transition" : function () {
var scrollview = this.scrollview = renderNewScrollview('y', 'y'),
paginator = this.scrollview.pages,
Expand Down