javascript - 将 360 jQuery 轮限制为 300

标签 javascript jquery rotation

我的播放器页面上有一个 360 度旋转轮,它最终充当音量按钮。

我需要将其功能限制为 270 度而不是 360 度(从 7 点钟到 5 点钟),以便它可以具有最小到最大的效果。

如何使用附加的代码实现此目的?

The Player Page

         $('#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/

相关文章:

javascript - 无法更改 body 元素的 html

javascript - str.replace(/[^0-9]/g, "") 删除我的整个字符串,而不是仅仅删除非数字字符。如何使其正常工作?

javascript - php ajax mysql从另一个文件发出警报

用于重新创建 Apple 2011 产品浏览器的 JQuery - 重复使用后出错

javascript - 这是一个伪装成工厂的 AngularJS 服务吗?

jquery - 如何在我的 Flot 图表周围放置一个方框?

javascript - 动画 - jQuery - 带有延迟的 fadeInUp

rotation - 旋转 iPhone 6 Plus 会导致灰色细节 View Controller ?

ios - 当应用程序处于纵向模式时旋转 MPMovies PlayerViewController

css - 使用 CSS 旋转鼠标光标图标