jQuery slide is jumpy

前端 未结 27 1870
悲&欢浪女
悲&欢浪女 2020-12-07 16:52

I tried to slide in and out a DIV with the toggle function of jQuery but the result is always jumpy at the start and/or end of the animation. Here\'s the js code that I use:

27条回答
  •  感动是毒
    2020-12-07 17:42

    I've ran into this problem today. I did notice however that disabling all CSS fixed the problem. Also I knew it worked fine before so it must have been recent changes that caused the issue.

    It turned out I used transitions in CSS to ease in and out of hovers.

    Once these transitions were removed from the elements I was adding everything was fine.

    So if you have the same issue, just add these lines to the elements you're adding:

    -webkit-transition: none;
    -moz-transition: none;
    -o-transition: none;
    -ms-transition: none;
    transition: none;
    

    (I might have abused transitions a bit by not just adding them to the elements I want to have transitions for, but using them for the entire website.)

提交回复
热议问题