forked from deblan/side_menu
refactoring of alwaysDisplayed function
This commit is contained in:
parent
a074d747c1
commit
5d93d02960
|
@ -1,21 +1,19 @@
|
|||
var alwaysDisplayed = function() {
|
||||
var elements = querySelectorAll('*')
|
||||
var fixedElements = []
|
||||
|
||||
for (var i in elements) {
|
||||
var element = elements[i]
|
||||
const alwaysDisplayed = function() {
|
||||
const elements = querySelectorAll('*')
|
||||
const fixedElements = []
|
||||
|
||||
for (var element of elements) {
|
||||
if (typeof element !== 'object') {
|
||||
continue
|
||||
}
|
||||
|
||||
var position = window.getComputedStyle(element, null).getPropertyValue('position');
|
||||
const position = window.getComputedStyle(element, null).getPropertyValue('position');
|
||||
|
||||
if (position !== 'fixed') {
|
||||
continue
|
||||
}
|
||||
|
||||
var id = element.getAttribute('id')
|
||||
const id = element.getAttribute('id')
|
||||
|
||||
if (id === 'header' || id === 'side-menu' || id === 'side-menu-loader') {
|
||||
continue
|
||||
|
@ -47,19 +45,19 @@ var alwaysDisplayed = function() {
|
|||
}
|
||||
|
||||
for (var i in fixedElements) {
|
||||
var element = fixedElements[i]
|
||||
var computedStyle = window.getComputedStyle(element, null)
|
||||
var left = computedStyle.getPropertyValue('left')
|
||||
var right = computedStyle.getPropertyValue('right')
|
||||
const element = fixedElements[i]
|
||||
const computedStyle = window.getComputedStyle(element, null)
|
||||
const left = computedStyle.getPropertyValue('left')
|
||||
const right = computedStyle.getPropertyValue('right')
|
||||
|
||||
if (right !== '0px') {
|
||||
var intValue = parseInt(left.replace('px', ''))
|
||||
element.style.setProperty('transform', 'translateX(' + (intValue + 50) + 'px)')
|
||||
const intValue = parseInt(left.replace('px', '')) + 50
|
||||
element.style.setProperty('transform', 'translateX(' + intValue.toString() + 'px)')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let content = document.getElementById('content')
|
||||
const content = querySelector('#content')
|
||||
|
||||
if (content && content.classList.contains('app-settings')) {
|
||||
let loaded = false
|
||||
|
|
Loading…
Reference in a new issue