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-left: ${offset}px;
margin-right: -${offset}px; margin-right: -${offset}px;
${playerBox._bgStyle}`); ${playerBox._bgStyle}
`);
} }
else { else {
const newOffset = Math.abs(offset); const newOffset = Math.abs(offset);
playerBox.setStyle(`margin-left: -${newOffset}px; playerBox.setStyle(`
margin-left: -${newOffset}px;
margin-right: ${newOffset}px; margin-right: ${newOffset}px;
${playerBox._bgStyle}`); ${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(`
${TRANSITION}
margin-left: ${OFFSCREEN}px; margin-left: ${OFFSCREEN}px;
margin-right: -${OFFSCREEN}px; margin-right: -${OFFSCREEN}px;
opacity: 0; opacity: 0; ${playerBox._bgStyle}
${playerBox._bgStyle}`); `);
} }
else { else {
playerBox.setStyle(`${TRANSITION} playerBox.setStyle(`
${TRANSITION}
margin-left: -${OFFSCREEN}px; margin-left: -${OFFSCREEN}px;
margin-right: ${OFFSCREEN}px; margin-right: ${OFFSCREEN}px;
opacity: 0; opacity: 0; ${playerBox._bgStyle}`);
${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 {