mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-17 19:59:33 +01:00
fix(file-viewer): the resize grip only starts on the primary button
This commit is contained in:
1 parent
2cd0d82544
commit
e3c6f9f2c7
2 files changed
+8
-2
No files matched your search
@@ -4666,6 +4666,7 @@ Object.assign(CodemanApp.prototype, {
|
|||||||
const win = grip?.parentElement;
|
const win = grip?.parentElement;
|
||||||
if (!grip || !win) return;
|
if (!grip || !win) return;
|
||||||
grip.addEventListener('pointerdown', (ev) => {
|
grip.addEventListener('pointerdown', (ev) => {
|
||||||
|
if (ev.button !== 0) return; // a right-click on the grip must not start a resize
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
const startX = ev.clientX;
|
const startX = ev.clientX;
|
||||||
const startY = ev.clientY;
|
const startY = ev.clientY;
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ describe('file viewer Alt+arrow chord', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('file viewer resize grip', () => {
|
describe('file viewer resize grip', () => {
|
||||||
function drag(to: [number, number]) {
|
function drag(to: [number, number], button = 0) {
|
||||||
const { app, elements } = loadApp();
|
const { app, elements } = loadApp();
|
||||||
const listeners: Record<string, (e: unknown) => void> = {};
|
const listeners: Record<string, (e: unknown) => void> = {};
|
||||||
const win = { offsetWidth: 400, offsetHeight: 300, style: {} as Record<string, string> };
|
const win = { offsetWidth: 400, offsetHeight: 300, style: {} as Record<string, string> };
|
||||||
@@ -350,11 +350,16 @@ describe('file viewer resize grip', () => {
|
|||||||
removeEventListener: () => {},
|
removeEventListener: () => {},
|
||||||
};
|
};
|
||||||
app._bindFilePreviewResize();
|
app._bindFilePreviewResize();
|
||||||
listeners.pointerdown({ preventDefault: () => {}, clientX: 100, clientY: 100, pointerId: 1 });
|
listeners.pointerdown({ preventDefault: () => {}, clientX: 100, clientY: 100, pointerId: 1, button });
|
||||||
|
if (!listeners.pointermove) return win.style; // a refused pointerdown binds no move handler
|
||||||
listeners.pointermove({ clientX: 100 + to[0], clientY: 100 + to[1] });
|
listeners.pointermove({ clientX: 100 + to[0], clientY: 100 + to[1] });
|
||||||
return win.style;
|
return win.style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it('ignores a pointerdown that is not the primary button', () => {
|
||||||
|
expect(drag([100, 50], 2)).toEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
it('doubles the pointer delta, because the window is centred', () => {
|
it('doubles the pointer delta, because the window is centred', () => {
|
||||||
expect(drag([100, 50])).toMatchObject({ width: '600px', height: '400px' });
|
expect(drag([100, 50])).toMatchObject({ width: '600px', height: '400px' });
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user