From 60fb02f387db4bd92dc7495c4312d0fed7e33027 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 19 Jan 2018 14:54:26 +0200 Subject: [PATCH] chore(dom) scrollIntoViewIfNeeded --- client/dom/index.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/client/dom/index.js b/client/dom/index.js index 07b6594e..cc3f75d5 100644 --- a/client/dom/index.js +++ b/client/dom/index.js @@ -1009,26 +1009,18 @@ function CmdProto() { * unified way to scrollIntoViewIfNeeded * (native suporte by webkit only) * @param element - * @param pCenter + * @param center - to scroll as small as possible param should be false */ - this.scrollIntoViewIfNeeded = function(element, center) { - var ret = element && element.scrollIntoViewIfNeeded; + this.scrollIntoViewIfNeeded = function(element, center = false) { + if (!element || !element.scrollIntoViewIfNeeded) + return; - /* for scroll as small as possible - * param should be false - */ - if (arguments.length === 1) - center = false; - - if (ret) - element.scrollIntoViewIfNeeded(center); - - return ret; + element.scrollIntoViewIfNeeded(center); }; - /* scroll on one page*/ - this.scrollByPages = (element, pPages) => { - var ret = element && element.scrollByPages && pPages; + /* scroll on one page */ + this.scrollByPages = (element, pPages) => { + const ret = element && element.scrollByPages && pPages; if (ret) element.scrollByPages(pPages);