All Projects → alanchenchen → lottery-rotate

alanchenchen / lottery-rotate

Licence: other
适配移动端rem布局的canvas大转盘抽奖插件

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to lottery-rotate

Rough
Create graphics with a hand-drawn, sketchy, appearance
Stars: ✭ 16,472 (+109713.33%)
Mutual labels:  canvas
shoot game
🎮 It is a game using HTML5 Canvas and Vanilla JavaScript.
Stars: ✭ 35 (+133.33%)
Mutual labels:  canvas
idraw
A simple JavaScript framework for Drawing on the web.(一个面向Web绘图的JavaScript框架)
Stars: ✭ 436 (+2806.67%)
Mutual labels:  canvas
Three.js
JavaScript 3D Library.
Stars: ✭ 78,237 (+521480%)
Mutual labels:  canvas
canvas2video
canvas2video is a backend solution for creating and rendering dynamic videos.
Stars: ✭ 194 (+1193.33%)
Mutual labels:  canvas
NightSky
A way to avoid paying 50 bucks by using some js to generate an image of the night sky at specific time and location. 🌑
Stars: ✭ 49 (+226.67%)
Mutual labels:  canvas
Clchart
A fast, simple and cross-platform(html5 react-native weex wechat-applet) stock chart library created using canvas.
Stars: ✭ 250 (+1566.67%)
Mutual labels:  canvas
empathy-map
チームでお互いのことを知り、ゴールや目的を共有する。
Stars: ✭ 15 (+0%)
Mutual labels:  canvas
radiaSlider
circular/linear knob-style slider
Stars: ✭ 18 (+20%)
Mutual labels:  canvas
SubmiBot
Plugin do Eclipse para automatização do processo de submissão de tarefas na disciplina de LP2 - Computação@UFCG
Stars: ✭ 16 (+6.67%)
Mutual labels:  canvas
flappy-bird
🐦 A clone of a famous game, the Flappy Bird, made in Javascript and HTML Canvas API.
Stars: ✭ 37 (+146.67%)
Mutual labels:  canvas
fabricjs-image-editor-origin
fabric.js javascript image editor
Stars: ✭ 52 (+246.67%)
Mutual labels:  canvas
snake-game-p5
The Snake Game made with p5.js 🐍🎮.
Stars: ✭ 18 (+20%)
Mutual labels:  canvas
Chart.js
Simple HTML5 Charts using the <canvas> tag
Stars: ✭ 55,646 (+370873.33%)
Mutual labels:  canvas
canvas-constructor
An ES6 utility for canvas with built-in functions and chained methods.
Stars: ✭ 96 (+540%)
Mutual labels:  canvas
Disintegrate
A small JS library to break DOM elements into animated Canvas particles.
Stars: ✭ 251 (+1573.33%)
Mutual labels:  canvas
canvas-cast
Cast any <canvas> element to an LED Matrix over WebSockets with an Arduino/ESP8266.
Stars: ✭ 39 (+160%)
Mutual labels:  canvas
turkeyvisited
Mark the cities you have visited in Turkey and share the map!
Stars: ✭ 82 (+446.67%)
Mutual labels:  canvas
drawing-board
canvas-drawing-board
Stars: ✭ 23 (+53.33%)
Mutual labels:  canvas
canvas-merge-video-in-vue
canvas+vue 实现视频碎片合并 比较粗陋,欢迎fork 升级++
Stars: ✭ 21 (+40%)
Mutual labels:  canvas

lottery-rotate

适配移动端rem布局的canvas大转盘抽奖插件

Author:Alan Chen E-mail: [email protected]

* 使用说明

  • 1.目前给出了ES5和ES6两种语法的版本,有后缀名es5为es5版本,可以直接用script标签引入,es6版本必须使用import引入,因为插件使用了export导出模块。
  • 2.使用该插件十分简单,无需导入其余css,不依赖任何插件,只需先初始化一个实例,es5版本构造函数名必须为LotteryRotate,例如: new LotteryRotate() 而es6版本可以根据import引入模块自定义命名,因为插件是export default导出。

* 配置项 Object

  • 构造器传入的是一个对象,所有参数都作为对象的键值对。
  • objDOM】必选 大转盘最外层盒子,插件挂载的dom结构,例如: document.querySelector('.lottery_box')
  • eTypeString】必选 抽奖按钮的事件类型,不需要加前缀on,例如: touchstart
  • rotateTimeNumber】必选 抽奖一次的总时间,单位是毫秒,例如: 3000
  • preRotateNumber】必选 中奖前预旋转的圈数,提高用户体验,必须是正整数,例如: 6
  • chanceNumber】必选 抽奖次数,次数不足再触发事件会弹窗提示,必须是正整数,例如: 1
  • remNumber】必选 canvas的宽和高,此处传入的是rem布局中的rem值,例如: 4.05
  • areaColor颜色】可选 canvas绘制扇形区域的填充颜色,默认是#cde59d
  • btnDOM】必选 抽奖按钮的dom结构,例如: document.querySelector('.btn')
  • listContArray | String】必选 奖品名称,奖品必须是字符串,写入数组里,例如: ['1元话费','2元话费','3元话费','4元话费','5元话费','6元话费']

* 方法调用 Object

  • 插件提供了一个方法 rotate,而且必须在实例初始化之后调用,函数里传入的是一个对象,所有参数作为对象的键值对。
    • ajax(list) Function 可选 。请求后台的回调函数,用来获取中奖的奖项,必须return一个数字,数字和数组中的索引对应,默认有一个参数 listlist 是奖品数组 listCont,如果不传入ajax回调函数,插件默认会调用随机数抽奖
    • success(award) Function 可选。抽奖成功的回调函数,默认有一个参数 awardaward` 是奖品名称
    • failed() Function 可选。当抽奖次数为0抽奖结束的回调函数,如果不写此函数,则默认 alert('您抽奖次数已用完')`

* 使用案例 demo

let Lottery=new LotteryRotate({
	obj:document.querySelector('.lottery_box'),
	eType:'touchstart',
	rotateTime:3000,//抽奖一次总旋转时间
	preRotate:6,//预旋转圈数
	chance:1,//可抽奖次数
	rem:4.05,
	areaColor:'#ffe462',
	btn:document.querySelector('.btn'),
	listCont:['10元话费','2元话费','1元话费','10元话费','2元话费','1元话费']
});
Lottery.rotate({
	//请求后台的函数,必须return一个数字,数字和奖品数组中的索引对应,list是奖品数组listCont
	ajax:(list)=>list.indexOf('1元话费'),
	//抽奖成功的函数,award为中奖后的奖品名称,是字符串
	success:(award)=>alert(`恭喜你获得${award}`),
	failed:()=>{console.log('你已经没有机会咯')}
});
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].