From 730411688e98b07aa4bb463da397728ef4323b7b Mon Sep 17 00:00:00 2001 From: Digitroinc Date: Fri, 9 Mar 2018 04:20:50 -0500 Subject: [PATCH 1/2] Implements issue #2069 Adds smooth scrolling option to scrollBehavior position --- src/util/scroll.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/util/scroll.js b/src/util/scroll.js index cceb03640..1fab10e66 100644 --- a/src/util/scroll.js +++ b/src/util/scroll.js @@ -124,6 +124,14 @@ function scrollToPosition (shouldScroll, position) { } if (position) { - window.scrollTo(position.x, position.y) + if (isObject && shouldScroll.smooth === true) { + window.scrollTo({ + top: position.x, + left: position.y, + behavior: 'smooth' + }) + } else { + window.scrollTo(position.x, position.y) + } } } From 4f2fa4627095c66b33bbafff5f7ed3fbbd34f11b Mon Sep 17 00:00:00 2001 From: Digitroinc Date: Fri, 9 Mar 2018 05:21:14 -0500 Subject: [PATCH 2/2] Allows user to pass behaviour string with fallback --- src/util/scroll.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/util/scroll.js b/src/util/scroll.js index 1fab10e66..61375c93b 100644 --- a/src/util/scroll.js +++ b/src/util/scroll.js @@ -124,12 +124,9 @@ function scrollToPosition (shouldScroll, position) { } if (position) { - if (isObject && shouldScroll.smooth === true) { - window.scrollTo({ - top: position.x, - left: position.y, - behavior: 'smooth' - }) + const docEl: any = document.documentElement + if ('scrollBehavior' in docEl.style) { + window.scrollTo({ top: position.y, left: position.x, behavior: isObject && typeof shouldScroll.behavior === 'string' ? shouldScroll.behavior : 'auto' }) } else { window.scrollTo(position.x, position.y) }