Home > php教程 > php手册 > 微信营销平台系统–刮刮乐的开发

微信营销平台系统–刮刮乐的开发

WBOY
Release: 2016-06-13 09:34:00
Original
1277 people have browsed it

下载 jquery扩展wScratchPad.js, 原站的页面打不开,我这里提供一个下载地址 wScratchPad-2.1.0.zip

然后(冷静),一些没节操的博主,直接转别人的文章,验证的过程都省了,应该坑了不是小白。我这里修正一下

在这个扩展里面,怎么才能过去用户的刮开的面积

复制代码 代码如下:


$("#wScratchPad3").wScratchPad({
 cursor:'',  //设置鼠标的样式
 color:'gray' ,  //设置覆盖物的颜色,跟image2功能相斥
 width:"300",
 height:"100",
 image: "" //顶部的图片
// 更多配置相关的选项请看源码
 scratchUp: function(e, percent){
 if(percent > 60)
 {
 alert("sss");
 }
 }
 });

从上面的代码,看的出来,这个跟网上所谓的教程不一样,这里获取刮开的范围用到函数不是

scratchMove()
而是
scratchUp()

为嘛?看源码

复制代码 代码如下:


scratchFunc: function(e, $this, event)
        {
            e.pageX = Math.floor(e.pageX - $this.canvas_offset.left);
            e.pageY = Math.floor(e.pageY - $this.canvas_offset.top);
            $this['scratch' + event](e, $this);
            if(this.settings.realtimePercent || event == "Up") {
                if($this.settings['scratch' + event]) $this.settings['scratch' + event].apply($this, [e, $this.scratchPercentage($this)]);
            }
        }

这里这个获取函数绑定的UP 而不是move

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template