1. <i id='HoXxf'><tr id='HoXxf'><dt id='HoXxf'><q id='HoXxf'><span id='HoXxf'><b id='HoXxf'><form id='HoXxf'><ins id='HoXxf'></ins><ul id='HoXxf'></ul><sub id='HoXxf'></sub></form><legend id='HoXxf'></legend><bdo id='HoXxf'><pre id='HoXxf'><center id='HoXxf'></center></pre></bdo></b><th id='HoXxf'></th></span></q></dt></tr></i><div id='HoXxf'><tfoot id='HoXxf'></tfoot><dl id='HoXxf'><fieldset id='HoXxf'></fieldset></dl></div>
  2. <legend id='HoXxf'><style id='HoXxf'><dir id='HoXxf'><q id='HoXxf'></q></dir></style></legend>
    • <bdo id='HoXxf'></bdo><ul id='HoXxf'></ul>
    <tfoot id='HoXxf'></tfoot>

    1. <small id='HoXxf'></small><noframes id='HoXxf'>

      jQuery 圆形滑块

      时间:2024-04-19
      • <legend id='qegXA'><style id='qegXA'><dir id='qegXA'><q id='qegXA'></q></dir></style></legend>
          <tfoot id='qegXA'></tfoot>

              <tbody id='qegXA'></tbody>

          • <small id='qegXA'></small><noframes id='qegXA'>

            <i id='qegXA'><tr id='qegXA'><dt id='qegXA'><q id='qegXA'><span id='qegXA'><b id='qegXA'><form id='qegXA'><ins id='qegXA'></ins><ul id='qegXA'></ul><sub id='qegXA'></sub></form><legend id='qegXA'></legend><bdo id='qegXA'><pre id='qegXA'><center id='qegXA'></center></pre></bdo></b><th id='qegXA'></th></span></q></dt></tr></i><div id='qegXA'><tfoot id='qegXA'></tfoot><dl id='qegXA'><fieldset id='qegXA'></fieldset></dl></div>

                <bdo id='qegXA'></bdo><ul id='qegXA'></ul>
                本文介绍了jQuery 圆形滑块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想做一个如下图所示的圆形滑块.jQuery 能做到这一点吗?

                我知道直线滑块的工作原理,但我想制作一个 HTML5 圆形滑块.这是我在网上找到的

                $(function () {var $circle = $('#circle'),$handler = $('#handler'),$p = $('#test'),handlerW2 = $handler.width()/2,弧度 = $circle.width()/2,offs = $circle.offset(),elPos = {x:offs.left, y:offs.top},mHold = 0,PI2 = 数学.PI/180;$handler.mousedown(function() { mHold = 1; });$(文档).mousemove(函数(e) {如果(mHold){var mPos = {x:e.pageX-elPos.x, y:e.pageY-elPos.y},atan = Math.atan2(mPos.x-rad, mPos.y-rad),度 = -atan/PI2+180,perc = (度*100/360)|0,X = Math.round(rad* Math.sin(deg*PI2)),Y = Math.round(rad* -Math.cos(deg*PI2));$handler.css({left:X+rad-handlerW2, top:Y+rad-handlerW2, transform:'rotate('+deg+'deg)'});}}).mouseup(function() { mHold = 0; });});

                I would like to do a rounded slider like the image below. Is jQuery able to do this?

                I know how a straight slider works but I would like to make a HTML5 rounded slider. Here is what I found online http://jsfiddle.net/XdvNg/1/ - but I dont know how to get the slider value one the user lets go

                解决方案

                Here is what I came up with:

                jsBin demo

                $(function () {
                    var $circle = $('#circle'),
                        $handler = $('#handler'),
                        $p = $('#test'),
                        handlerW2 = $handler.width()/2,
                        rad = $circle.width()/2,
                        offs = $circle.offset(),
                        elPos = {x:offs.left, y:offs.top},
                        mHold = 0,
                        PI2 = Math.PI/180;
                    $handler.mousedown(function() { mHold = 1; });
                    $(document).mousemove(function(e) {
                        if (mHold) {
                            var mPos = {x:e.pageX-elPos.x, y:e.pageY-elPos.y},
                                atan = Math.atan2(mPos.x-rad, mPos.y-rad),
                                deg  = -atan/PI2+180,
                                perc = (deg*100/360)|0,
                                X = Math.round(rad*  Math.sin(deg*PI2)),    
                                Y = Math.round(rad* -Math.cos(deg*PI2));
                            $handler.css({left:X+rad-handlerW2, top:Y+rad-handlerW2, transform:'rotate('+deg+'deg)'});
                        }
                    }).mouseup(function() { mHold = 0; });
                });
                

                这篇关于jQuery 圆形滑块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:尝试使用 id==valores0 注册小部件,但该 id 已注册 下一篇:jQuery Slick Slider 过滤多个条件

                相关文章

              • <legend id='z343K'><style id='z343K'><dir id='z343K'><q id='z343K'></q></dir></style></legend>

                1. <tfoot id='z343K'></tfoot>
                  <i id='z343K'><tr id='z343K'><dt id='z343K'><q id='z343K'><span id='z343K'><b id='z343K'><form id='z343K'><ins id='z343K'></ins><ul id='z343K'></ul><sub id='z343K'></sub></form><legend id='z343K'></legend><bdo id='z343K'><pre id='z343K'><center id='z343K'></center></pre></bdo></b><th id='z343K'></th></span></q></dt></tr></i><div id='z343K'><tfoot id='z343K'></tfoot><dl id='z343K'><fieldset id='z343K'></fieldset></dl></div>
                    <bdo id='z343K'></bdo><ul id='z343K'></ul>

                  <small id='z343K'></small><noframes id='z343K'>