Velocity.js绕中心轴旋转
Velocity.js Rotation Around Center Axis
我正试图使齿轮绕z轴旋转。它按预期工作,但在5000持续时间后发生逆转。如何阻止它倒车,只让它前进?
感谢
var gear_width = $('.gear').width();
var gear_height = $('.gear').height();
$('.gear').velocity({ rotateZ:-360 }, { duration: 5000, easing: "linear", loop: true,});
这是Velocity中的一个已知错误,Julian说他会修复它,但据我所知,还没有已知的发布日期:
https://github.com/julianshapiro/velocity/issues/453(旋转负值顺时针旋转回来)
由于顺时针方向的循环确实有效,因此在修复错误之前,快速绕过逆时针方向的无限循环是这样的:
Fiddle:https://jsfiddle.net/znyLtfaf/2/
HTML:
<div class="gear gearRight">rotate right</div>
<div class="gear gearLeft">rotate left</div>
CSS:
.gear {
width: 100px;
height: 100px;
position: absolute;
background: red;
}
.gearRight {
top: 100px;
left: 100px;
}
.gearLeft {
top: 300px;
left: 100px;
}
JS:
$('.gearRight').velocity({ rotateZ: "+=360" }, { duration: 5000, easing: "linear", loop: true});
loopMeLeft();
function loopMeLeft () {
$('.gearLeft').velocity({ rotateZ: "-=360" }, { duration: 5000, easing: "linear", complete: loopMeLeft});
}
这里有一个更复杂的例子,动态地加速和减速齿轮,尽管边缘有点粗糙,但总体思路是存在的。
Fiddle:https://jsfiddle.net/AtheistP3ace/znyLtfaf/4/
相关文章:
- 旋转按钮[HTML][JS]
- 在JS中围绕旋转对象旋转对象
- HTML5、CSS3和/或JS中旋转CD上的音频播放器
- 使用tween.js围绕世界轴旋转对象
- JS/CSS旋转的DIVS在任何屏幕的中间相遇
- 三个js键盘旋转
- JS下拉菜单显示在图像旋转器上
- 三.js轨道控制.js可以改变反Y轴旋转吗?
- jquery 图像旋转器(仅在 JS 中传递图像)
- Don't限制OrbitControls.js中的旋转
- 恢复旋转三.js
- 如何旋转相机,使其面向/高于球体上的点(Three.js)
- 单击three.js中的链接旋转球体
- JS with SVG:围绕其中心旋转SVG元素
- 使用D3.js旋转外部SVG文件
- 无中心旋转的Matter.js机身
- Three.js如何使用四元数旋转相机
- Three.js TrackballControls.js在z中旋转;仅x轴
- 在HTML5画布中旋转JS对象时Y轴出现问题
- 如何围绕织物中的一个指定点旋转.js