Skip to content

Commit

Permalink
fix: fix zoom (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Nov 1, 2022
1 parent 910d934 commit 4a15227
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<>"
Expand All @@ -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
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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` +
Expand Down
10 changes: 8 additions & 2 deletions src/signature_pad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
Expand Down

0 comments on commit 4a15227

Please sign in to comment.