我正试图设置一个小小的 刮 </跨度> 纸牌游戏,有几个面板,你拖过或触摸(iPad,智能手机等) 刮 </跨度> 并揭示下面的图像。
我不是JS大师所以我已经广泛搜索并找到了我认为最好的脚本:
http://www.websanova.com/tutorials/jquery/html5-jquery- 刮 </跨度> -pad-插件使用canvas和jQuery。它还可以让你看到百分比
我不太多使用jQuery,所以不确定如何扩展jQuery扩展本身,但查看示例 github上的代码 您想要对这些行添加更改(110-140):
this.sp = $('<div></div>') .css({cursor: 'default', position: 'relative'}) .append( $(this.canvas) .attr('width', this.settings.width + 'px') .attr('height', this.settings.height + 'px') .css({cursor: 'default'}) .mousedown(function(e) { e.preventDefault(); e.stopPropagation(); $this.scratch = true; $this.scratchFunc(e, $this, 'Down'); }) ) $(document) .mousemove(function(e) { if($this.scratch) $this.scratchFunc(e, $this, 'Move'); }) .mouseup(function(e) { //make sure we are in draw mode otherwise this will fire on any mouse up. if($this.scratch) { $this.scratch = false; $this.scratchFunc(e, $this, 'Up'); } });
如果您修改或复制此块,并添加复制mousedown,mousemove和mouseup处理程序功能的touchevents,那么您应该大部分都在那里。