我的播放器页面上有一个 360 度旋转轮,它最终充当音量按钮。
我需要将其功能限制为 270 度而不是 360 度(从 7 点钟到 5 点钟),以便它可以具有最小到最大的效果。
如何使用附加的代码实现此目的?
$('#metal .indicator-cw').bind('touchmove', function(event){
updateMetal();
});
$("#metal .indicator-cw").mousemove(updateMetal);
function updateMetal(){
var number = $("#metal .result-cw").text();
var Degrees = parseInt(number);
var vol = ((Degrees + 150) % 360) * (1/270);
$musicPlayer.jPlayer("volume", vol);
$("#rotateit").css({'transform':'rotate(' + (Degrees) + 'deg)', '-webkit-transform':'rotate(' + (Degrees) + 'deg)', '-o-transform':'rotate(' + (Degrees) + 'deg)', '-moz-transform':'rotate(' + (Degrees) + 'deg)', '-ms-transform':'rotate(' + (Degrees) + 'deg)' });
if (Degrees > 120 || Degrees < 210) return;
}
//js code for the metal style wheel - above
最佳答案
添加此内容以停止更新音量轮
if (Degrees > 150 && Degrees < 210) return;
您还需要稍微不同地计算体积
//This shifts the degrees from 210-120 to be 0-270 and then scales it to 0-1
var vol = ((Degrees + 150) % 360) * (1/300);
关于javascript - 将 360 jQuery 轮限制为 300,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14510726/