25 lines
784 B
JavaScript
25 lines
784 B
JavaScript
|
const getChangeHeader = () => getClassNameElementsArray('change-header')[0]
|
||
|
|
||
|
const getFileElements = () => getClassNameElementsArray('file')
|
||
|
|
||
|
const getSelectedFile = () => getClassNameElementsArray('file-selected')[0]
|
||
|
|
||
|
const changeFile = e => {
|
||
|
const up = e.wheelDelta ? e.wheelDelta > 0 : e.deltaY < 0
|
||
|
const selectedFile = getSelectedFile()
|
||
|
const fileElements = getFileElements()
|
||
|
const index = fileElements.indexOf(selectedFile)
|
||
|
const nextElement =
|
||
|
(up && index > 0) ? fileElements[index - 1] :
|
||
|
(!up && index < (fileElements.length - 1)) ? fileElements[index + 1] :
|
||
|
null
|
||
|
nextElement?.focus()
|
||
|
nextElement?.click()
|
||
|
}
|
||
|
|
||
|
addFix(() => {
|
||
|
const header = getChangeHeader()
|
||
|
console.log({ header })
|
||
|
header.onwheel = changeFile
|
||
|
})
|