Giter Site home page Giter Site logo

lottery's Introduction

#Lottery.js
#html5移动端大转盘抽奖插件, 简单、易用、无依赖。

##step 1: 引入资源
<canvas id="lottery" width="300" height="300"></canvas>
<button id="handler">开始抽奖</button>

<!-- Lottery Javascript file -->
<script src="Lottery.js"></script>

##step 2: 调用Lottery

new Lottery(document.getElementById('lottery'), {
	handler: document.getElementById('handler'),
	handlerCallback: function(_interface){
		/*ajax获取中奖结果*/
		_ajax(function(response){
			/*指定停止的位置:索引*/
			_interface.stop(response.index, function(){
				console.log('恭喜你中得:' + response.name)
			});
		});
	},
	products: [
		{
			text: '小米电视',
			imgUrl: 'http://www.host.com/img1.png'
		},
		{
			text: '华为手机',
			imgUrl: 'http://www.host.com/img2.png'
		}
		...
	]
});

##构造函数 Lottery 的全部配置项.

var _lottery = new Lottery(document.getElementById('lottery'),{
    /*点击抽奖元素*/
    handler: '',
    /*点击抽奖的回调*/
    handlerCallback: function(_interface){},
    outerRadius: '',
    innerRadius: 0,
    /*循环填充数组颜色*/
    fillStyle: ['#ffdf8a', '#fffdc9'],
    /*重复触发的间距时间*/
    interval: 1000,
    /*速度越大越快*/
    speed: 12,
    /*运动最少持续时间*/
    duration: 3000,
    /*字体位置与样式*/
    /*画布显示缩放比例,值为1 安卓模糊*/
    scale: this.ua.isIos ? 1 : 4,
    /*字体样式,浅拷贝 需整个font对象传入*/
    font: {
        y: '50%',
        color: '#ee6500',
        style: 'normal',
        weight: 500,
        size: '12px',
        lineHeight: 1,
        family: 'Arail'
    },
    /*图片位置与尺寸*/
    images: {
        y: '88%',
        width: 32,
        height: 32
    },
    /*打断文字换行*/
    breakText: ['金币', '红包'],
    /*礼物*/
    products: [
        /*{
            imgUrl: 'http://',
            text: '苹果手机',
        }*/
    ]
});

/*指定停止位置, index为索引 0-products.length */
_lottery.stop(index, function(){

});

lottery's People

Contributors

xiaohai18 avatar

Stargazers

 avatar  avatar l_w avatar Ye Jiaqi avatar jinzaizhichi avatar  avatar Alex avatar Fahsa avatar  avatar  avatar  avatar 赵金海 avatar Peter avatar Todd Hill avatar  avatar 石头 avatar Fly avatar  avatar TangTangWan avatar So avatar zhiyuan avatar shimuhuayunzi avatar Frank avatar 雷雷雷_Ray avatar  avatar

Watchers

James Cloos avatar  avatar

lottery's Issues

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.