如何正确使用鼠标进行旋转 - 可拖动

时间:2016-01-05 18:48:23

标签: jquery jquery-ui-draggable jquery-ui-droppable

http://jsfiddle.net/avPf6/1056/

代码正在运行,但旋转混乱,并且没有正确跟随鼠标:

CREATE FUNCTION categorize (
     @id VARCHAR(5),
     @var1_low INT,
     @var1_high INT,
     @var2_low DECIMAL(18,6),
     @var2_high DECIMAL(18,6)
    )
RETURNS TABLE
AS RETURN
    (SELECT
        year,
        id,
        COUNT(id) AS totalnum,
        SUM(score) AS var1_sum
     FROM
        database1
     WHERE
        studentid = @id
        AND Score >= @var1_low
        AND Score <= @var1_high
        AND time >= @var2_low
        AND time <= @var2_high
     GROUP BY
        year
     ORDER BY
        year
    )

如何旋转正确?

1 个答案:

答案 0 :(得分:1)

我建议使用rotatable.js script来实现这一目标。它将预先形成正确旋转元素所需的所有计算。

Updated Example

这样做,您实际上可以将jQuery简化为以下内容。以下是使用您提供的HTML / CSS的基本示例:

&#13;
&#13;
$('.draggable').draggable().rotatable({
  handle: $('.draggable .handle')
});
&#13;
.parent {
  width: 300px;
  height: 300px;
  border: 1px solid red;
}
.draggable {
  width: 100px;
  height: 100px;
  border: 1px solid blue;
}
.draggable .handle {
  position: absolute;
  bottom: 5px;
  right: 5px;
  height: 10px;
  width: 10px;
  background: orange;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery.ui.rotatable/1.0.1/jquery.ui.rotatable.min.js"></script>
<div class="parent">
  <div class="draggable">
    <div class="handle"></div>
  </div>
</div>
&#13;
&#13;
&#13;