Code Monkey home page Code Monkey logo

gb-canvas-turntable's Introduction

GB-canvas-turntable


简介

适用于移动端的Canvas绘制可配置的转盘抽奖

使用

Browser

	<link rel="stylesheet" href="css/GB-canvas-turntable.css">
	<script src="js/GB-canvas-turntable.js"></script>

普通

	gbTurntable.init({
        id: 'turntable',
        config: function(callback){
            // 获取奖品信息
            // 奖项 text 属性不能为空,用于显示或抽中奖品提示
            // img 为奖品图片地址,如果不为空则转盘奖品按图片方式显示
            callback && callback([{
              text: '1元红包',
              img: 'images/redpacket.png'
            }, {
              text: '2元红包'
            }, {
              text: '3元红包'
            }, {
              text: '显示器',
              img: 'images/display.png'
            }, {
              text: '5元红宝'
            }, {
              text: '6元红宝'
            }])
        },
        getPrize: function(callback) {
            // 获取中奖信息
            var num = Math.random() * 6 >>> 0,   //奖品ID
                chances = num;  // 可抽奖次数
                callback && callback([num, chances]);   
        },
        gotBack: function(data) {
            alert('恭喜抽中' + data);
        }
    });

感谢他们

演示网页排版来自: https://github.com/sofish/typo.css

License

MIT © 2016 givebest

gb-canvas-turntable's People

Contributors

givebest avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.