1
0
mirror of https://github.com/24eme/signaturepdf.git synced 2023-08-25 09:33:08 +02:00

Cursor copy présent dés le clique sur un svg à ajouter pour que

l'interface soit plus intuitive
This commit is contained in:
Vincent LAURENT 2021-10-29 21:24:11 +02:00
parent b6b39a0703
commit 8e634a4b92
2 changed files with 22 additions and 2 deletions

View File

@ -91,8 +91,22 @@ loadingTask.promise.then(function(pdf) {
stateAddLock(false); 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) { canvasEditions.forEach(function(canvasEdition, index) {
var input_selected = document.querySelector('input[name="svg_2_add"]:checked');
if(input_selected) { if(input_selected) {
canvasEdition.defaultCursor = 'copy'; canvasEdition.defaultCursor = 'copy';
} else { } else {
@ -140,7 +154,7 @@ loadingTask.promise.then(function(pdf) {
var svgImg = document.createElement('img'); var svgImg = document.createElement('img');
svgImg.src = svg.svg; svgImg.src = svg.svg;
svgImg.draggable = false; svgImg.draggable = false;
svgImg.style = "max-width: 180px;max-height: 70px;cursor: grab;"; svgImg.style = "max-width: 180px;max-height: 70px;";
svgButton.appendChild(svgImg); svgButton.appendChild(svgImg);
var svgContainer = document.createElement('div'); var svgContainer = document.createElement('div');
svgContainer.classList.add('d-grid'); svgContainer.classList.add('d-grid');

View File

@ -79,8 +79,14 @@ describe("Signature d'un pdf", () => {
}); });
it("Ajout d'une seconde signature", async () => { it("Ajout d'une seconde signature", async () => {
await page.click("#label_svg_0"); 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.waitForTimeout(100);
await page.mouse.click(originX + 50, originY + 50); 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 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].getScaledHeight())})).toBe(150);
expect(await page.evaluate(() => { return Math.round(canvasEditions[0].getObjects()[1].getScaledWidth())})).toBe(150); expect(await page.evaluate(() => { return Math.round(canvasEditions[0].getObjects()[1].getScaledWidth())})).toBe(150);