qiaohhgz / bigwheel-miniapp Goto Github PK
View Code? Open in Web Editor NEW微信小程序大转盘
微信小程序大转盘
用起来还是有点卡顿。iPhone 7plus
你好 顺时针的时候 , 停止到的位置与显示的奖品不符
1、index.js在调用抽奖停止函数时传入奖品数组的长度
// 模拟后台返回数据
setTimeout(function () {
// 随机一个奖品
var prizeIndex = utils.getRandom(slicePrizes.length - 1);
// console.log(prizeIndex)
//奖品数量
var prizeCounts = slicePrizes.length;
// console.log(prizeCounts)
// 计算奖品角度
animation.stopTo(prizeIndex,prizeCounts);
}, 3000);
2、改变Animation.js的stopTo方法
Animation.prototype.stopTo = function (prizeIndex,prizeCounts) {
var wheel = this.circle;
var angle = wheel.angle;
var offset = (360/prizeCounts)/2; //应该是 (360/转盘奖品数量)/2
this.minAngle = prizeIndex * angle + offset;
this.maxAngle = prizeIndex * angle + angle;
this.prize = wheel.slicePrizes[prizeIndex];
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.