Skip to content

Commit

Permalink
release: v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Oct 15, 2019
1 parent 1bb3a30 commit 1d040b0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
## v1.0.1 (15 Oct 2019)

* fix: use clientXY instead of pageXY

## v1.0.0 (15 Oct 2019)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eruda-touches",
"version": "1.0.0",
"version": "1.0.1",
"main": "eruda-touches.js",
"scripts": {
"dev": "webpack-dev-server --host 0.0.0.0",
Expand Down
16 changes: 10 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports = function(eruda) {
const changedTouches = toArr(e.changedTouches)
each(e.touches, touch => {
touches.push({
pageX: touch.pageX,
pageY: touch.pageY,
clientX: touch.clientX,
clientY: touch.clientY,
changed: contain(changedTouches, touch)
})
})
Expand Down Expand Up @@ -84,15 +84,19 @@ module.exports = function(eruda) {
ctx.font = 'bold 50px Helvetica,Arial,sans-serif'

each(touches, touch => {
const { pageX, pageY, changed } = touch
const x = (pageX / innerWidth) * width
const y = (pageY / innerHeight) * height
const { clientX, clientY, changed } = touch
const x = (clientX / innerWidth) * width
const y = (clientY / innerHeight) * height
if (changed) {
ctx.fillStyle = '#f44336'
} else {
ctx.fillStyle = '#2196f3'
}
ctx.fillText(`${Math.round(pageX)}, ${Math.round(pageY)}`, x + 50, y)
ctx.fillText(
`${Math.round(clientX)}, ${Math.round(clientY)}`,
x + 50,
y
)
ctx.beginPath()
ctx.arc(x, y, 25, 0, Math.PI * 2, true)
ctx.closePath()
Expand Down

0 comments on commit 1d040b0

Please sign in to comment.