javascript 中的 webkit 转换语法?
我正在寻找 webkitTransition 对象引用在这里
function spawnAnimation(what){
//sets the moving element
var moveingEl = document.getElementById(what);
//gives temp transition property
moveingEl.style.WebkitTransition = "left 2s";
// moveingEl.style.webkitTransition = "top 500ms";
var cLeft = moveingEl.style.left
var cleft = Number(cLeft.slice(0, -2));
var cTop = moveingEl.style.top
var cTop = Number(cTop.slice(0, -2));
moveingEl.style.left = cLeft+200 + "px";
}
这不起作用。我想给元素一个过渡属性,然后让它移动到右侧。当调用此代码时,它会立即向右移动,没有动画。真糟糕:(。我不想在CSS中预定义它,我想动态添加它然后删除它。
I'm looking for the webkitTransition object reference here
function spawnAnimation(what){
//sets the moving element
var moveingEl = document.getElementById(what);
//gives temp transition property
moveingEl.style.WebkitTransition = "left 2s";
// moveingEl.style.webkitTransition = "top 500ms";
var cLeft = moveingEl.style.left
var cleft = Number(cLeft.slice(0, -2));
var cTop = moveingEl.style.top
var cTop = Number(cTop.slice(0, -2));
moveingEl.style.left = cLeft+200 + "px";
}
This does not work.I would like to give the element a transition property, then make it move to the right. When this code is called it just immediately moves to the right with no animation. bummer :(. I don't want to predefine it in CSS, I would like to dynamically add it and then remove it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用 style.setProperty 修改任何属性使用其 CSS 名称作为字符串,包括
-moz-*
和-webkit-*
属性。You can use style.setProperty to modify any property using its CSS name as string, including
-moz-*
and-webkit-*
properties.允许渲染者等待 1 毫秒以恢复线程。
Allow 1ms for the rendered to get the thread back.
您可以使用:
element.style.webkitTransition =“在此处设置过渡”
You can use:
element.style.webkitTransition = "set your transition up here"
我知道这是一个解决方法,但是你能使用 jQuery 吗?
I know it's a workaround, but can you use jQuery?