Skip to content

Commit 40d11e1

Browse files
author
Michael Bleigh
committed
Make compatible with touch devices.
1 parent 8db64e3 commit 40d11e1

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/sketch.coffee

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,19 @@
6363
@startPainting()
6464
when 'mouseup', 'mouseout', 'mouseleave', 'touchend', 'touchcancel'
6565
@stopPainting()
66-
66+
6767
if @painting
68-
if e.targetTouches && e.targetTouches.length > 1
68+
if e.originalEvent.targetTouches && e.originalEvent.targetTouches.length > 1
6969
@stopPainting()
7070
return
71-
mouseX = if e.targetTouches then e.targetTouches[0].pageX else e.pageX
72-
mouseY = if e.targetTouches then e.targetTouches[0].pageY else e.pageY
71+
mouseX = if e.originalEvent.targetTouches then e.originalEvent.targetTouches[0].pageX else e.pageX
72+
mouseY = if e.originalEvent.targetTouches then e.originalEvent.targetTouches[0].pageY else e.pageY
7373

7474
@action.events.push
7575
x: mouseX - @canvas.offset().left
7676
y: mouseY - @canvas.offset().top
7777
event: e.type
78+
7879
@redraw()
7980

8081
redraw: ->

src/sketch.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)