我有一个简单的块,应该用translateX向左移动200 is。它将向左移动,位置向左移动。我似乎无法用translateX或translateY移动这个块。转换转换的CSS值将有效。使用翻译的原因是性能与位置的比较。我把剩下的位置都注释掉了,想让你知道我想要达到的目标。
var button = document.getElementById('button');
var adiv = document.getElementById('panel');
button.addEventListener('click', function(){
//Velocity(adiv, { left: '100' }, [ 500, 20 ]);
Velocity(adiv, {translateX: 200}, [ 500, 20 ]);
})#panel {
display: block;
position: absolute;
background: #ffffbd;
width: 100px;
height: 100px;
top: 0;
left: 0;
}
button {
top: 90%;
position: relative;
display: block;
}<script src="https://cdn.jsdelivr.net/npm/velocity-animate@2.0/velocity.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<body>
<div id="topbar"></div>
<div id="panel">
</div>
<button id="button">start</button>
</body>
发布于 2018-02-27 19:51:50
在V2中,不再有任何transform快捷方式,比如translateX --只要正确地使用css transform属性,它就能工作(不幸的是,在V1中尝试这样做有问题)。
Velocity(adiv, {transform:"translateX(200px)"}, [ 500, 20 ]);
如果没有强制喂食,它将从0的值动画。
发布于 2019-02-09 18:32:21
速度似乎随着VUE第3版的出现而加速。我强烈建议使用以下信息更新流速2.0文档:
在V2中,不再有任何转换快捷键,比如translateX --只要正确地使用css转换属性,它就能工作(不幸的是,在V1中尝试这样做有问题)。速度(adiv,{transform:“translateX(200 20 )”},500,20 );
或者向VUE团队伸出援手,因为他们仍然在使用速度1.x示例。
发布于 2019-06-13 12:01:18
使用jQuery的简单示例:
$('.box').on('click', function() {
$(this).velocity({
transform: ["translateX(100px)", "translateX(0px)"]
}, {duration: 1000});
});https://stackoverflow.com/questions/48964932
复制相似问题