From d6d54b9d950a575610ef97d92272ae73702de170 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Fri, 21 May 2021 13:15:19 +0300 Subject: [PATCH] merge value checks --- js/src/util/scrollbar.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/js/src/util/scrollbar.js b/js/src/util/scrollbar.js index bcb4a9d436dd..a51b427e0c70 100644 --- a/js/src/util/scrollbar.js +++ b/js/src/util/scrollbar.js @@ -34,11 +34,7 @@ class ScrollBarHelper { } _disableOverFlow() { - const actualValue = this._element.style.overflow - if (actualValue) { - Manipulator.setDataAttribute(this._element, 'overflow', actualValue) - } - + this._saveInitialAttribute(this._element, 'overflow') this._element.style.overflow = 'hidden' } @@ -49,11 +45,7 @@ class ScrollBarHelper { return } - const actualValue = element.style[styleProp] - if (actualValue) { - Manipulator.setDataAttribute(element, styleProp, actualValue) - } - + this._saveInitialAttribute(element, styleProp) const calculatedValue = window.getComputedStyle(element)[styleProp] element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px` } @@ -68,6 +60,13 @@ class ScrollBarHelper { this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight') } + _saveInitialAttribute(element, styleProp) { + const actualValue = element.style[styleProp] + if (actualValue) { + Manipulator.setDataAttribute(element, styleProp, actualValue) + } + } + _resetElementAttributes(selector, styleProp) { const manipulationCallBack = element => { const value = Manipulator.getDataAttribute(element, styleProp)