From 8e634a4b92306d34a7fbe33b34aaf0b275d38ac1 Mon Sep 17 00:00:00 2001 From: Vincent LAURENT Date: Fri, 29 Oct 2021 21:24:11 +0200 Subject: [PATCH] =?UTF-8?q?Cursor=20copy=20pr=C3=A9sent=20d=C3=A9s=20le=20?= =?UTF-8?q?clique=20sur=20un=20svg=20=C3=A0=20ajouter=20pour=20que=20l'int?= =?UTF-8?q?erface=20soit=20plus=20intuitive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/app.js | 18 ++++++++++++++++-- tests/signature.test.js | 6 ++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index ef0ffd2..2fb01aa 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -91,8 +91,22 @@ loadingTask.promise.then(function(pdf) { stateAddLock(false); + + var input_selected = document.querySelector('input[name="svg_2_add"]:checked'); + if(input_selected) { + document.body.style.setProperty('cursor', 'copy'); + } else { + document.body.style.removeProperty('cursor'); + } + document.querySelectorAll('.btn-svg').forEach(function(item) { + if(input_selected && item.htmlFor == input_selected.id) { + item.style.setProperty('cursor', 'copy'); + } else { + item.style.removeProperty('cursor'); + } + }); + canvasEditions.forEach(function(canvasEdition, index) { - var input_selected = document.querySelector('input[name="svg_2_add"]:checked'); if(input_selected) { canvasEdition.defaultCursor = 'copy'; } else { @@ -140,7 +154,7 @@ loadingTask.promise.then(function(pdf) { var svgImg = document.createElement('img'); svgImg.src = svg.svg; svgImg.draggable = false; - svgImg.style = "max-width: 180px;max-height: 70px;cursor: grab;"; + svgImg.style = "max-width: 180px;max-height: 70px;"; svgButton.appendChild(svgImg); var svgContainer = document.createElement('div'); svgContainer.classList.add('d-grid'); diff --git a/tests/signature.test.js b/tests/signature.test.js index 0e771cf..f6283c5 100644 --- a/tests/signature.test.js +++ b/tests/signature.test.js @@ -79,8 +79,14 @@ describe("Signature d'un pdf", () => { }); it("Ajout d'une seconde signature", async () => { await page.click("#label_svg_0"); + expect(await page.evaluate(() => { return document.body.style.cursor; })).toBe("copy"); + expect(await page.evaluate(() => { return document.querySelector('#label_svg_0').style.cursor; })).toBe("copy"); + expect(await page.evaluate(() => { return canvasEditions[0].defaultCursor; })).toBe('copy'); await page.waitForTimeout(100); await page.mouse.click(originX + 50, originY + 50); + expect(await page.evaluate(() => { return document.body.style.cursor; })).toBe(""); + expect(await page.evaluate(() => { return document.querySelector('#label_svg_0').style.cursor; })).toBe(""); + expect(await page.evaluate(() => { return canvasEditions[0].defaultCursor; })).toBe('default'); expect(await page.evaluate(() => { return canvasEditions[0].getObjects().length; })).toBe(2); expect(await page.evaluate(() => { return Math.round(canvasEditions[0].getObjects()[1].getScaledHeight())})).toBe(150); expect(await page.evaluate(() => { return Math.round(canvasEditions[0].getObjects()[1].getScaledWidth())})).toBe(150);