简体   繁体   English

Javascript / CSS3过渡问题

[英]Javascript / CSS3 transition problems

I've got a page with ajax links between pages, and I'm having some problems with the transition. 我有一个页面,页面之间具有Ajax链接,并且在过渡方面遇到一些问题。 I set up a demo page on jsfiddle to demonstrate. 我在jsfiddle上设置了一个演示页面进行演示。

http://jsfiddle.net/UVr4A/ http://jsfiddle.net/UVr4A/

The problem is, when the content changes height, the div will end up in the wrong position and cause a non-smooth transition. 问题是,当内容更改高度时,div最终将位于错误的位置并导致不平滑的过渡。 I tried a couple things to try and fix this. 我尝试了一些尝试来解决此问题。 My current solution is to remove the animate property from the div and then move it, but this doesn't always work. 我当前的解决方案是从div中删除animate属性,然后将其移动,但这并不总是有效。 In my code I commented the delay to demonstrate the issue. 在我的代码中,我评论了演示该问题的延迟。 Even with a 50ms delay it doesn't ways work properly (I think it's due to browser lag since it barely ever happens on this jsfiddle), so I'm looking for more elegant solution that doesn't cause the transition to take any longer. 即使有50毫秒的延迟,它也无法正常工作(我认为这是由于浏览器滞后造成的,因为它几乎不会在此jsfiddle中发生),因此,我正在寻找更优雅的解决方案,该解决方案不会使过渡花费更多时间。

I'm using css3 transitions rather than jquery because they tend to be much smoother. 我正在使用css3过渡而不是jquery,因为它们趋向于更加平滑。

I think the issue was the css transition. 我认为问题是CSS过渡。 Check this out: 看一下这个:

http://jsfiddle.net/UVr4A/2/ http://jsfiddle.net/UVr4A/2/

Well, it turns out the problem had nothing to do with what I thought it was. 好吧,事实证明这个问题与我认为的问题无关。 Part of it was that I over-simplified my question and ended up removing the problem. 部分原因是我过分简化了问题,并最终消除了问题。

On my long page there are images that end up loading mid-transition, which is what was causing the jumping. 在我的长页面上,有一些图像最终在过渡过程中加载,这正是导致跳跃的原因。 I fixed this with an onload events and a timeout. 我通过onload事件和超时解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM