Gamehow JavaScript 微调器找不到 Value
Gameshow JavaScript spinner can't find Value
我正在尝试获取微调器的结果。经过 6 个小时的调试和各种数学尝试,我似乎无法找到如何在每次旋转时获得微调器的值。它降落在什么DIV上?!
http://codepen.io/anon/pen/OMrOPe
最初我认为以下算法会起作用。
total_rotations = Get Total Degrees in rotations (including what was done historically.
total_rotations / 360 = _total_rotations_of_a_circle
value_to_subtract = Take the absolute value of _total_rotations_of_a_circle * 360
left_over_value_in_Degree = total_rotations - value_to_subtract
left_over_value_in_Degree/60 = result.
此算法仅在有时有效。我只是不确定如何做到这一点,任何提示都会有所帮助。
aoY 变量是由原始开发人员提出的,但我不知道如何使用该值来查找它指向的实际div。我在这里需要什么数学?
$('#wheel .sec').each(function(){
var t = $(this);
var noY = 0;
var c = 0;
var n = 700;
var interval = setInterval(function () {
c++;
if (c === n) {
clearInterval(interval);
}
var aoY = t.offset().top;
$("#txt").html(aoY);
console.log(aoY);
/*23.7 is the minumum offset number that
each section can get, in a 30 angle degree.
So, if the offset reaches 23.7, then we know
that it has a 30 degree angle and therefore,
exactly aligned with the spin btn*/
if(aoY < 23.89){
console.log('<<<<<<<<');
$('#spin').addClass('spin');
setTimeout(function () {
$('#spin').removeClass('spin');
}, 100);
}
}, 10);
$('#inner-wheel').css({
'transform' : 'rotate(' + totalDegree + 'deg)'
});
noY = t.offset().top;
});
});
RobG 提出的公式是正确的:
Math.ceil((( totalDegree + 30 ) % 360) / 60)
您还必须考虑的事实是,每次连续播放的偏移量都会发生变化。为了解决这个问题,您可以简单地使用此公式:
offset = extraDegree MOD 60
然后,您可以将函数中的数字 30 替换为偏移变量:
Math.ceil((( totalDegree + offset ) % 360) / 60)
看到这个小提琴
相关文章:
- 气质的“nestRemoting()”有时可以'找不到关系
- 错误405:向Java控制器(Ajax)发送JSON时找不到POST方法
- 找不到模块捆绑包
- for循环中的javascript if语句找不到==
- 为什么JavaScript可以'找不到给定的InnerHTML并返回Cannot set property
- 失败:等待Protractor与页面同步时出错:“”;在窗口上找不到角度”;
- Babel编译错误:找不到模块核心js/library/fn/get迭代器
- [Vue warn]:找不到元素
- ngRoute找不到模板
- 未能加载,因为找不到支持的源.当播放HTML5音频元素时
- 因果报应-找不到模块:错误:无法解析模块'scs'
- Angular 2:在本地.json文件上找不到文件
- module.js在运行iron节点时找不到模块
- 放大弹出生成“;找不到文件”;YouTube视频的错误
- 我发现了一些只在移动设备上可见的垃圾邮件链接,我可以'找不到包含此垃圾邮件链接的脚本的位置
- Web 地址虚拟目录会断开外部 JavaScript 链接,因此找不到文件
- Meteor.js可以'找不到语义:ui包
- 找不到容器:goog.Disposable.instances _在为javascript工具使用泄漏查找器时出错
- 错误:找不到模块'/lib/cli'
- Gamehow JavaScript 微调器找不到 Value