From 4a15227bf80ebdb1509dfc1f8fffe920d1616968 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Mon, 31 Oct 2022 21:43:17 -0500 Subject: [PATCH] fix: fix zoom (#673) --- .github/workflows/test.yml | 4 +++- rollup.config.js | 2 +- src/signature_pad.ts | 10 ++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 53659e41..2deb9e18 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -73,6 +73,8 @@ jobs: run: yarn - name: Build 🗜️ run: | + SEMANTIC_RELEASE_NEXT_VERSION=$(npx semantic-release --no-ci --dry-run | grep -oP 'The next release version is \K[0-9]+\.[0-9]+\.[0-9]+') + echo "$SEMANTIC_RELEASE_NEXT_VERSION" yarn run build if ! git diff --quiet; then git config --global user.email "<>" @@ -85,4 +87,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npx semantic-release + run: echo npx semantic-release diff --git a/rollup.config.js b/rollup.config.js index 879a966c..d01eede0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -4,7 +4,7 @@ const pkg = require('./package.json'); const banner = '/*!\n' + - ` * Signature Pad v${pkg.version} | ${pkg.homepage}\n` + + ` * Signature Pad v${process.env.SEMANTIC_RELEASE_NEXT_VERSION || pkg.version} | ${pkg.homepage}\n` + ` * (c) ${new Date().getFullYear()} ${ pkg.author.name } | Released under the MIT license\n` + diff --git a/src/signature_pad.ts b/src/signature_pad.ts index b8a5893c..915d8b8c 100644 --- a/src/signature_pad.ts +++ b/src/signature_pad.ts @@ -437,9 +437,15 @@ export default class SignaturePad extends SignatureEventTarget { private _createPoint(x: number, y: number, pressure: number): Point { const rect = this.canvas.getBoundingClientRect(); + const dpr = Math.max(window.devicePixelRatio || 1, 1); + const zoom = + this.canvas.width && rect.width + ? this.canvas.width / rect.width / dpr + : 1; + return new Point( - x - rect.left, - y - rect.top, + x - rect.left * zoom, + y - rect.top * zoom, pressure, new Date().getTime(), );