Skip to content

Commit

Permalink
Scrollbar.js regression - remove margin/padding properties properly
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoSot committed Dec 9, 2021
1 parent 4fd5539 commit 1888104
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions js/src/util/scrollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { isElement } from './index'

const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'
const SELECTOR_STICKY_CONTENT = '.sticky-top'
const PROPERTY_PADDING = 'paddingRight'
const PROPERTY_MARGIN = 'marginRight'
const PROPERTY_PADDING = 'padding-right'
const PROPERTY_MARGIN = 'margin-right'

/**
* Class definition
Expand Down Expand Up @@ -69,15 +69,15 @@ class ScrollBarHelper {
}

this._saveInitialAttribute(element, styleProp)
const calculatedValue = window.getComputedStyle(element)[styleProp]
element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`
const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProp)
element.style.setProperty(styleProp, `${callback(Number.parseFloat(calculatedValue))}px`)
}

this._applyManipulationCallback(selector, manipulationCallBack)
}

_saveInitialAttribute(element, styleProp) {
const actualValue = element.style[styleProp]
const actualValue = element.style.getPropertyValue(styleProp)
if (actualValue) {
Manipulator.setDataAttribute(element, styleProp, actualValue)
}
Expand All @@ -86,13 +86,13 @@ class ScrollBarHelper {
_resetElementAttributes(selector, styleProp) {
const manipulationCallBack = element => {
const value = Manipulator.getDataAttribute(element, styleProp)
if (typeof value === 'undefined') {
if (!value) {
element.style.removeProperty(styleProp)
return
}

Manipulator.removeDataAttribute(element, styleProp)
element.style[styleProp] = value
element.style.setProperty(styleProp, value)
}

this._applyManipulationCallback(selector, manipulationCallBack)
Expand Down

0 comments on commit 1888104

Please sign in to comment.