同窗帮帮 h5 刮刮卡组件:Txbb.Scratch

同窗帮帮 h5 刮刮卡组件,简洁、无依赖,支持 globals 和 amd 两种调用方式。html

暂时只能用在移动端git

使用方法

<div id="J-Scratch"></div>
var scratchInstance = Txbb.Scratch.attach(element, options);

element

须要初始化的 容器 元素,canvas 元素会被添加进去。github

var scratchInstance = Txbb.Scratch.attach(document.querySelector('#J-Scratch'), options);

options

  • bg(type: String): canvas 所在容器的背景颜色
  • fg(type: String): canvas 元素的颜色,即刮刮卡的颜色
  • middle(type: String): 刮完奖以后显示的元素,能够是 html 也能够是纯字符串
  • size(type: Number): 默认 20, 刮一下的半径
  • onEnd(type: Function): 刮完奖的回调函数

实例方法

  • reset:scratchInstance.reset(options)重置刮刮卡,重置方法传入options能够改变实例化时的options

项目主页:http://www.open-open.com/lib/view/home/1442817103123canvas

相关文章
相关标签/搜索