From f60b608979352ef678845cae5313e021091372eb Mon Sep 17 00:00:00 2001 From: iota <980751937@qq.com> Date: Sat, 12 Jan 2019 17:16:41 +0800 Subject: [PATCH] optimized code There's unnecessary else after return. ```js if (containerElement && containerElement !== document && containerElement !== document.body) { return Math.max( containerElement.scrollHeight, containerElement.offsetHeight, containerElement.clientHeight ); } else { let body = document.body; let html = document.documentElement; return Math.max( body.scrollHeight, body.offsetHeight, htmlEl.clientHeight, htmlEl.scrollHeight, htmlEl.offsetHeight ); } ``` --- modules/mixins/animate-scroll.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/mixins/animate-scroll.js b/modules/mixins/animate-scroll.js index e93555c5..552f4e4d 100644 --- a/modules/mixins/animate-scroll.js +++ b/modules/mixins/animate-scroll.js @@ -61,24 +61,24 @@ const currentPositionY = (options) => { const scrollContainerHeight = (options) => { const containerElement = options.data.containerElement; + const body = document.body; + const htmlEl = document.documentElement; + if (containerElement && containerElement !== document && containerElement !== document.body) { return Math.max( containerElement.scrollHeight, containerElement.offsetHeight, containerElement.clientHeight ); - } else { - let body = document.body; - let html = document.documentElement; - - return Math.max( - body.scrollHeight, - body.offsetHeight, - html.clientHeight, - html.scrollHeight, - html.offsetHeight - ); } + + return Math.max( + body.scrollHeight, + body.offsetHeight, + htmlEl.clientHeight, + htmlEl.scrollHeight, + htmlEl.offsetHeight + ); }; const animateScroll = (easing, options, timestamp) => { @@ -210,4 +210,4 @@ export default { scrollToBottom, scrollTo, scrollMore, -}; \ No newline at end of file +};