From 5345e638a0906e8008feeb4be87dee1a4797dda8 Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Mon, 22 Jun 2020 15:32:38 +0200 Subject: [PATCH] Rotate signature block around the center Fixes #24 --- src/vpu-pdf-preview.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/vpu-pdf-preview.js b/src/vpu-pdf-preview.js index 423319a..edf26f5 100644 --- a/src/vpu-pdf-preview.js +++ b/src/vpu-pdf-preview.js @@ -109,7 +109,7 @@ export class PdfPreview extends ScopedElementsMixin(VPULitElement) { // add signature image fabric.Image.fromURL(this.placeholder, function(image) { // add a red border around the signature placeholder - image.set({stroke: "#e4154b", strokeWidth: that.border_width, strokeUniform: true}); + image.set({stroke: "#e4154b", strokeWidth: that.border_width, strokeUniform: true, centeredRotation: true}); // disable controls, we currently don't want resizing and do rotation with a button image.hasControls = false; @@ -400,13 +400,8 @@ export class PdfPreview extends ScopedElementsMixin(VPULitElement) { */ async rotateSignature() { let signature = this.getSignatureRect(); - let angel = signature.get("angle") + 90; - - if (angel >= 360) { - angel = 0; - } - - signature.set({ angle: angel }); + let angle = (signature.get("angle") + 90) % 360; + signature.rotate(angle); signature.setCoords(); this.enforceCanvasBoundaries(signature); -- GitLab