fix(ags players): block inputs when sliding away

This commit is contained in:
matt1432 2023-11-01 13:12:43 -04:00
parent 65946cb794
commit 2221f9bff3

View file

@ -36,15 +36,19 @@ export default ({
const playerBox = overlay.list().at(-1); const playerBox = overlay.list().at(-1);
if (offset >= 0) { if (offset >= 0) {
playerBox.setStyle(`margin-left: ${offset}px; playerBox.setStyle(`
margin-right: -${offset}px; margin-left: ${offset}px;
${playerBox._bgStyle}`); margin-right: -${offset}px;
${playerBox._bgStyle}
`);
} }
else { else {
const newOffset = Math.abs(offset); const newOffset = Math.abs(offset);
playerBox.setStyle(`margin-left: -${newOffset}px; playerBox.setStyle(`
margin-right: ${newOffset}px; margin-left: -${newOffset}px;
${playerBox._bgStyle}`); margin-right: ${newOffset}px;
${playerBox._bgStyle}
`);
} }
overlay._selected = playerBox; overlay._selected = playerBox;
}, 'drag-update'], }, 'drag-update'],
@ -59,24 +63,27 @@ export default ({
const playerBox = overlay.list().at(-1); const playerBox = overlay.list().at(-1);
if (Math.abs(offset) > MAX_OFFSET) { if (Math.abs(offset) > MAX_OFFSET) {
widget.sensitive = false;
if (offset >= 0) { if (offset >= 0) {
playerBox.setStyle(`${TRANSITION} playerBox.setStyle(`
margin-left: ${OFFSCREEN}px; ${TRANSITION}
margin-right: -${OFFSCREEN}px; margin-left: ${OFFSCREEN}px;
opacity: 0; margin-right: -${OFFSCREEN}px;
${playerBox._bgStyle}`); opacity: 0; ${playerBox._bgStyle}
`);
} }
else { else {
playerBox.setStyle(`${TRANSITION} playerBox.setStyle(`
margin-left: -${OFFSCREEN}px; ${TRANSITION}
margin-right: ${OFFSCREEN}px; margin-left: -${OFFSCREEN}px;
opacity: 0; margin-right: ${OFFSCREEN}px;
${playerBox._bgStyle}`); opacity: 0; ${playerBox._bgStyle}`);
} }
timeout(500, () => { timeout(500, () => {
overlay.reorder_overlay(playerBox, 0); overlay.reorder_overlay(playerBox, 0);
playerBox.setStyle(playerBox._bgStyle); playerBox.setStyle(playerBox._bgStyle);
overlay._selected = overlay.list().at(-1); overlay._selected = overlay.list().at(-1);
widget.sensitive = true;
}); });
} }
else { else {