[fix] ScrollView animated scrollTo

Rely on web's native smooth scrolling mechanism when implemented in the
browser: https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior

Fix #593
This commit is contained in:
Nicolas Gallagher
2017-12-19 15:52:30 +00:00
parent 66cf45b90b
commit 556dc8926e

View File

@@ -354,7 +354,7 @@ const ScrollResponderMixin = {
},
/**
* A helper function to scroll to a specific point in the scrollview.
* A helper function to scroll to a specific point in the scrollview.
* This is currently used to help focus on child textviews, but can also
* be used to quickly scroll to any element we want to focus. Syntax:
*
@@ -377,6 +377,7 @@ const ScrollResponderMixin = {
({ x, y, animated } = x || emptyObject);
}
const node = this.scrollResponderGetScrollableNode();
UIManager.updateView(node, { style: { scrollBehavior: !animated ? 'auto' : 'smooth' } }, this);
node.scrollLeft = x || 0;
node.scrollTop = y || 0;
},