在 iPad 上使用 javascript 更改 webkit 转换持续时间?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4167878/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing webkit transition duration using javascript on iPad?
提问by Tarek
I am using web-kit transitions in an iPad app. They work great. But I was wondering what I would do to change the values of my transition using javascript.
我在 iPad 应用程序中使用 web-kit 转换。他们工作得很好。但我想知道如何使用 javascript 更改过渡值。
#container {
-webkit-transition-property: -webkit-transform;
-webkit-transition-duration: 1s;
-webkit-transition-timing-function: ease-out;
}
What I would like to do:
我想做什么:
<script>
function func() {
document.getElemeentById('container').transition.duration = 500;
}
</script>
Is this possible?
这可能吗?
回答by Jakub Hampl
Can be done with:
可以通过以下方式完成:
document.getElementById('container').style['-webkit-transition-duration'] = '500s';
回答by Josh from Qaribou
Jakub's answer was good, but to update it, you can now set the transition duration directly as the transitionDurationproperty on an element's style. Tested and working on iOS Safari, OSX Safari, Chrome and Firefox. e.g.
Jakub 的回答很好,但要更新它,您现在可以直接将过渡持续时间设置为transitionDuration元素的style. 在 iOS Safari、OSX Safari、Chrome 和 Firefox 上测试和工作。例如
document.getElementById('container').style.transitionDuration = '500s';

