From 3f4aaa5e96673fbb16b933be7e89d0c13e9c0d95 Mon Sep 17 00:00:00 2001 From: Martin Schwier Date: Thu, 4 Aug 2016 15:55:21 +0200 Subject: [PATCH] util/scrollTo.js: add option to scroll selected item to the top of scrollParent --- src/util/scrollTo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/scrollTo.js b/src/util/scrollTo.js index 3105a03..03028fb 100644 --- a/src/util/scrollTo.js +++ b/src/util/scrollTo.js @@ -6,7 +6,7 @@ var getOffset = require('../query/offset') , raf = require('./requestAnimationFrame') , getWindow = require('../query/isWindow') -module.exports = function scrollTo( selected, scrollParent ) { +module.exports = function scrollTo( selected, scrollParent, scrollToTop = false ) { var offset = getOffset(selected) , poff = { top: 0, left: 0 } , list, listScrollTop, selectedTop, isWin @@ -34,7 +34,7 @@ module.exports = function scrollTo( selected, scrollParent ) { selectedHeight = offset.height selectedTop = offset.top + (isWin ? 0 : listScrollTop) - bottom = selectedTop + selectedHeight + bottom = scrollToTop ? selectedTop + listHeight : selectedTop + selectedHeight; listScrollTop = listScrollTop > selectedTop ? selectedTop