Skip to content

Commit

Permalink
merge value checks
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoSot committed Jun 3, 2021
1 parent b7237ae commit 0d6e263
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions js/src/util/scrollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand All @@ -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`
}
Expand All @@ -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)
Expand Down

0 comments on commit 0d6e263

Please sign in to comment.