aboutsummaryrefslogtreecommitdiffstats
path: root/helpers/windowActions.js
diff options
context:
space:
mode:
authorGravatar piotrruss <mail@pruss.it> 2021-09-04 21:55:21 +0200
committerGravatar piotrruss <mail@pruss.it> 2021-09-04 21:55:21 +0200
commit1e14a1101933dcfec3f357c590a455649db375ff (patch)
tree1edf1f49adc1ce3fc107ac5bba86589efac60983 /helpers/windowActions.js
parent6c54c9d57d5fa4c52aa454ed3ca09060b0674ad3 (diff)
downloadmy_apps-1e14a1101933dcfec3f357c590a455649db375ff.tar.gz
my_apps-1e14a1101933dcfec3f357c590a455649db375ff.tar.bz2
my_apps-1e14a1101933dcfec3f357c590a455649db375ff.zip
add mobile styles
Diffstat (limited to 'helpers/windowActions.js')
-rw-r--r--helpers/windowActions.js10
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
)]))