LoginSignup
5
3

More than 5 years have passed since last update.

[JavaScript]タッチイベントからoffsetXとoffsetXを取得する

Posted at

スマホのタッチイベントからoffsetX, offsetYを取得する手法。
忘れがちなのでメモ。

        const rect = event.target.getBoundingClientRect()
        const offsetX = (event.touches[0].clientX - window.pageXOffset - rect.left) 
        const offsetY = (event.touches[0].clientY - window.pageYOffset - rect.top)
5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3