[fix] ScrollView smooth scrolling

Rely on the `element.scroll()` programmatic API when available (or polyfilled).

Fix #1203
Fix #1173
Close #1208
This commit is contained in:
krister
2018-12-20 20:35:50 -03:00
committed by Nicolas Gallagher
parent f7e6b43422
commit 30d7c31b65

View File

@@ -375,9 +375,12 @@ 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;
if (typeof node.scroll === 'function') {
node.scroll({ top: y || 0, left: x || 0, behavior: !animated ? 'auto' : 'smooth' });
} else {
node.scrollLeft = x || 0;
node.scrollTop = y || 0;
}
},
/**