diff options
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/windowActions.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/helpers/windowActions.js b/helpers/windowActions.js index 8ff361b..b6d86b6 100644 --- a/helpers/windowActions.js +++ b/helpers/windowActions.js @@ -1,4 +1,4 @@ -export const close = (appName, setApps) => {setApps(apps => apps.filter(a => a.name !== appName))} +export const close = (appName, setApps) => {setApps(apps => apps.filter(a => a && a.name !== appName))} export const open = ({appName, buttons, height, width}, setApps) => { setApps(apps => ( @@ -38,19 +38,19 @@ export const toggleMax = (appName, setApps) => setApps(apps => ([ ])) -export const move = (appName, winRef, setApps) => { +export const move = (app, winRef, setApps) => { winRef.current.onmousedown = (event) => { - if (event.target.classList && event.target.classList.contains('window__title')) { + if (!app.max && event.target.classList && event.target.classList.contains('window__title')) { const shiftX = event.clientX - winRef.current.getBoundingClientRect().left const shiftY = event.clientY - winRef.current.getBoundingClientRect().top winRef.current.classList.add('moving') - focus(appName, setApps) + focus(app.name, setApps) function moveAt(pageX, pageY) { const x = pageX - shiftX const y = pageY - shiftY - 32 - setApps(apps => ([...apps.map(a => a.name === appName + setApps(apps => ([...apps.map(a => a.name === app.name ? {...a, pos: [x + 'px', y < 0 ? 0 : y + 'px']} : a )])) |