【问题标题】:css transform + css transition = skipped frames [Google Chrome]css 变换 + css 过渡 = 跳帧 [Google Chrome]
【发布时间】:2015-11-16 15:38:48
【问题描述】:

当我点击场景时,盒子会掉下来。当我再次单击时,框会立起来。动画很流畅,但是当我在不同的位置多次点击时,有时动画会跳帧。

我在 Google Chrome 的 OS X 上遇到了这个错误。在 Opera 中测试 — 一切正常,没有错误。

http://jsfiddle.net/nw78myhn/1/

有人知道如何解决这个问题吗?

<div class="scene">
  <div class="box"></div>
</div>
.scene {
  width: 500px;
  height: 500px;
  position: absolute;
  background: #efefef;
}

.box {
  position: absolute;
  left: 250px;
  top: 100px;
  width: 70px;
  height: 140px;
  background: #000;
  transform: rotate(0deg);
  transform-origin: bottom left;
  transition: transform 600ms linear;
}

.box-transform {
  transform: rotate(-96deg);
}
$('.scene').on('click', function() {
  $('.box').toggleClass('box-transform');
});

更新:

我注意到如果将transform-origin 设置为.box-transform 而不是.box,则不会跳帧:

http://jsfiddle.net/nw78myhn/2/

但在这种情况下,原点在视觉上并不位于bottom left。而且我真的不明白为什么。

更新 2 [2016 年 2 月 16 日]: 此错误已在较新版本的 Google Chrome 中修复。无法在 Chrome 48.0.2564.109 中重现

【问题讨论】:

  • 您好,我使用的是 MAC OS X 和 google chrome,无法重现您的问题。
  • 嗨,尝试点击场景的不同点
  • @imkost 嗨,它甚至可以在具有 Windows 8 的 chrome 上复制

标签: css google-chrome css-transitions css-transforms


【解决方案1】:

似乎是与转换单个属性相关的 Chrome 错误。

为了使您的第二个示例满足您的需求,您可以添加一个愚蠢的过渡

$('.scene').on('click', function() {
  $('.box').toggleClass('box-transform');
});
.scene {
  width: 500px;
  height: 500px;
  position: absolute;
  background: #efefef;
}

.box {
  position: absolute;
  left: 250px;
  top: 100px;
  width: 70px;
  height: 140px;
  background: #000;
  transform: rotate(0deg);
  transform-origin: bottom left;
    perspective: 1000px;
    transition-property: transform perspective;
    transition-duration: 600ms;
    transition-timing-function: linear;
    transition-delay: initial;
}

.box-transform {
  transform: rotate(-90deg);
    perspective: 1001px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="scene">
  <div class="box"></div>
</div>

【讨论】:

  • 哇,伙计,它确实有效!我向 Google Chrome 报告了一个问题。
  • StackOverflow 说,我需要等待 15 个小时才能获得赏金。
  • 别担心!很高兴它有帮助:-)
  • @imkost 你能把错误报告的链接贴在这里吗?
  • @Rowno,抱歉,我不知道如何获取链接。我只是这样做了:“Chrome -> 帮助和关于 -> 报告问题......”顺便说一句,我仍然没有来自谷歌的回复。可能我必须找到 Chrome 的错误跟踪网站并在那里发布。
猜你喜欢
  • 1970-01-01
  • 2015-10-19
  • 2018-09-09
  • 1970-01-01
  • 2020-02-09
  • 1970-01-01
  • 1970-01-01
  • 2016-10-01
  • 1970-01-01
相关资源
最近更新 更多