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() {
|
const alwaysDisplayed = function() {
|
||||||
var elements = querySelectorAll('*')
|
const elements = querySelectorAll('*')
|
||||||
var fixedElements = []
|
const fixedElements = []
|
||||||
|
|
||||||
for (var i in elements) {
|
|
||||||
var element = elements[i]
|
|
||||||
|
|
||||||
|
for (var element of elements) {
|
||||||
if (typeof element !== 'object') {
|
if (typeof element !== 'object') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var position = window.getComputedStyle(element, null).getPropertyValue('position');
|
const position = window.getComputedStyle(element, null).getPropertyValue('position');
|
||||||
|
|
||||||
if (position !== 'fixed') {
|
if (position !== 'fixed') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var id = element.getAttribute('id')
|
const id = element.getAttribute('id')
|
||||||
|
|
||||||
if (id === 'header' || id === 'side-menu' || id === 'side-menu-loader') {
|
if (id === 'header' || id === 'side-menu' || id === 'side-menu-loader') {
|
||||||
continue
|
continue
|
||||||
|
@ -47,19 +45,19 @@ var alwaysDisplayed = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i in fixedElements) {
|
for (var i in fixedElements) {
|
||||||
var element = fixedElements[i]
|
const element = fixedElements[i]
|
||||||
var computedStyle = window.getComputedStyle(element, null)
|
const computedStyle = window.getComputedStyle(element, null)
|
||||||
var left = computedStyle.getPropertyValue('left')
|
const left = computedStyle.getPropertyValue('left')
|
||||||
var right = computedStyle.getPropertyValue('right')
|
const right = computedStyle.getPropertyValue('right')
|
||||||
|
|
||||||
if (right !== '0px') {
|
if (right !== '0px') {
|
||||||
var intValue = parseInt(left.replace('px', ''))
|
const intValue = parseInt(left.replace('px', '')) + 50
|
||||||
element.style.setProperty('transform', 'translateX(' + (intValue + 50) + 'px)')
|
element.style.setProperty('transform', 'translateX(' + intValue.toString() + 'px)')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let content = document.getElementById('content')
|
const content = querySelector('#content')
|
||||||
|
|
||||||
if (content && content.classList.contains('app-settings')) {
|
if (content && content.classList.contains('app-settings')) {
|
||||||
let loaded = false
|
let loaded = false
|
||||||
|
|
Loading…
Reference in a new issue