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

      <small id='3fEDo'></small><noframes id='3fEDo'>

    1. <tfoot id='3fEDo'></tfoot>
          <bdo id='3fEDo'></bdo><ul id='3fEDo'></ul>

        jQuery - CSS - 通过拖动鼠标事件旋转 Div

        时间:2023-10-13

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

          • <legend id='wdTTj'><style id='wdTTj'><dir id='wdTTj'><q id='wdTTj'></q></dir></style></legend>
              <bdo id='wdTTj'></bdo><ul id='wdTTj'></ul>

                <tbody id='wdTTj'></tbody>

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

                1. 本文介绍了jQuery - CSS - 通过拖动鼠标事件旋转 Div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我搜索了几天没有真正的结果,也许有人可以在这里帮助我.

                  I'm searching since a few day without real result, maybe someone can help me here.

                  我的页面上有一个 div(可以包含图像、文本区域等),它是可拖动且可调整大小的(感谢 jQuery UI),我想让它可旋转",并带有一个句柄使用 css 变换 (-wekbit-transform, moz-transform) 拖动和旋转角

                  I've a div on my page (can containt an image, a text area, other), it's draggable and resizable (thanks to jQuery UI), and i want to make it "rotatable", with a handle in a corner to drag and rotate it using css transform (-wekbit-transform, moz-transform)

                  有可能吗?使用 jQuery 或其他 Javascript 吗?

                  Is it possible ? with jQuery or other Javascript ?

                  其实我并不关心与 IE 的兼容性.

                  Actually i don't care of compatibility with IE.

                  提前致谢,问候

                  推荐答案

                  使用jQuery UI原有的拖动事件:

                  Using jQuery UI's original drag events:

                  $('selector').draggable({
                    drag: function(event, ui){
                      var rotateCSS = 'rotate(' + ui.position.left + 'deg)';
                  
                      $(this).css({
                        '-moz-transform': rotateCSS,
                        '-webkit-transform': rotateCSS
                      });
                    }
                  });
                  

                  问题是您的问题有点不清楚如何处理由此产生的两种行为(当您拖动对象同时旋转移动)的冲突.这个只是让鼠标的左右移动来决定旋转多少,而默认的拖动行为(移动)仍然存在.

                  The problem is that your question is slightly unclear about how the conflict about the two behaviors (when you drag the object both rotates and moves around) that arise from this is handled. This one just let the left-right movement of the mouse determine how much to rotate, while the default drag behavior (movement) still exists.

                  我想这有点骇人听闻,但它会起作用:

                  I suppose this is a little hackish but it will work:

                  // Your original element
                  var ele = $('#selector');
                  
                  // Create handle dynamically
                  $('<div></div>').appendTo(ele).attr('id','handle').css({
                      'position': 'absolute',
                      'bottom': 5,
                      'right': 5,
                      'height': 10,
                      'width': 10,
                      'background-color': 'orange'
                  });
                  
                  ele.css('position', 'relative');
                  
                  $('#handle').draggable({
                      handle: '#handle',
                      opacity: 0.01, 
                      helper: 'clone',
                      drag: function(event, ui){
                          var rotateCSS = 'rotate(' + ui.position.left + 'deg)';
                  
                          $(this).parent().css({
                              '-moz-transform': rotateCSS,
                              '-webkit-transform': rotateCSS
                          });
                      }
                  });
                  

                  这篇关于jQuery - CSS - 通过拖动鼠标事件旋转 Div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:CSS 相对于参考点的旋转 下一篇:三个 JS 从 matrixWorld 获取(世界)旋转

                  相关文章

                  最新文章

                  <small id='0piUd'></small><noframes id='0piUd'>

                  • <bdo id='0piUd'></bdo><ul id='0piUd'></ul>

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

                      <legend id='0piUd'><style id='0piUd'><dir id='0piUd'><q id='0piUd'></q></dir></style></legend>