【问题标题】:Assigning touch events to elements within canvas - iPad将触摸事件分配给画布中的元素 - iPad
【发布时间】:2011-03-14 21:23:31
【问题描述】:

我正在为 iPad 创建一个网络应用程序,并尝试将触摸事件分配给画布中的元素。我是这样设置的:

函数初始化(){ touch_element = 新图像(); touch_element.src = 'img/image.png' touch_element.onload = 函数(){ canvas.drawImage(足球, 50, 50, 184, 120); touch_element.addEventListener('touchstart', touch_start, false); touch_element.addEventListener('touchmove', touch_move, false); touch_element.addEventListener('touchend', touch_end, false); } }

我没有返回任何错误,并且图像加载正常。唯一的问题是触摸事件没有触发。是否可以在画布中执行此操作?

【问题讨论】:

    标签: javascript iphone ipad html canvas


    【解决方案1】:

    您不能将触摸事件分配给image 对象。唯一有效的属性是 onerroronloadsrcvalidate

    相关话题:Bind event to shape on canvas

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-27
      • 1970-01-01
      • 2011-08-24
      • 1970-01-01
      • 2017-05-15
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      相关资源
      最近更新 更多