Fix bringToFront function
This commit is contained in:
parent
624bd3255c
commit
93dcea8b21
@ -210,29 +210,25 @@ var getJSON = function(url, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class WindowsCompositor{
|
class WindowsCompositor{
|
||||||
windowLayer = undefined
|
static windowsLayer
|
||||||
movingElement = null
|
|
||||||
|
|
||||||
//TODO refactor this to dynamic add/remove listeners
|
|
||||||
constructor(){
|
constructor(){
|
||||||
this.windowLayer = document.body.querySelector('#windows-layer')
|
this.windowLayer = document.body.querySelector('#windows-layer')
|
||||||
|
WindowsCompositor.windowsLayer = document.body.querySelector('#windows-layer')
|
||||||
if (!WebDesktopEnvironment.isMobile) {
|
if (!WebDesktopEnvironment.isMobile) {
|
||||||
let startDrag = function(event) {
|
let startDrag = function(event) {
|
||||||
|
let window = event.target.closest('.WindowFrame')
|
||||||
|
WindowsCompositor.bringWindowToFront(window)
|
||||||
let targetClasses = event.target.className.split(' ')
|
let targetClasses = event.target.className.split(' ')
|
||||||
if (targetClasses[targetClasses.length - 1] != 'DragArea'){
|
if (targetClasses[targetClasses.length - 1] != 'DragArea'){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// if (event.target.event.target.className != "DragArea"){}
|
|
||||||
let xPosInit = event.offsetX
|
let xPosInit = event.offsetX
|
||||||
let yPosInit = event.offsetY
|
let yPosInit = event.offsetY
|
||||||
let window = event.target.closest('.WindowFrame')
|
|
||||||
let dragWindow = function(event){
|
let dragWindow = function(event){
|
||||||
// console.log(window)
|
|
||||||
// console.log(event.clientX)
|
|
||||||
// console.log(event.clientX - xPosInit, event.clientY - yPosInit)
|
|
||||||
window.style.left = `${event.clientX - xPosInit}px`
|
window.style.left = `${event.clientX - xPosInit}px`
|
||||||
window.style.top = `${event.clientY - yPosInit}px`
|
window.style.top = `${event.clientY - yPosInit}px`
|
||||||
// WindowsCompositor.dragElement(window,event.clientX - xPosInit, event.clientY - yPosInit)
|
|
||||||
}
|
}
|
||||||
let stopDrag = function(){
|
let stopDrag = function(){
|
||||||
removeEventListener('mousemove', dragWindow)
|
removeEventListener('mousemove', dragWindow)
|
||||||
@ -241,18 +237,19 @@ class WindowsCompositor{
|
|||||||
|
|
||||||
addEventListener('mousemove', dragWindow)
|
addEventListener('mousemove', dragWindow)
|
||||||
addEventListener('mouseup', stopDrag)
|
addEventListener('mouseup', stopDrag)
|
||||||
// console.log(event)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.windowLayer.addEventListener('mousedown', startDrag)
|
WindowsCompositor.windowsLayer.addEventListener('mousedown', startDrag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {HTMLElement} window
|
* @param {HTMLElement} window
|
||||||
*/
|
*/
|
||||||
bringWindowToFront(window){ //FIXME
|
static bringWindowToFront(window){ //FIXME
|
||||||
this.windowLayer.insertBefore(this.windowLayer.lastChild, window)
|
if (window != WindowsCompositor.windowsLayer.lastChild ){
|
||||||
|
WindowsCompositor.windowsLayer.insertBefore(WindowsCompositor.windowsLayer.lastChild, window)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user