变换,过渡和模糊在Instagram Instagram In-App浏览器(动画)中被延迟

发布于 2025-01-31 07:32:38 字数 2837 浏览 2 评论 0原文

我正在尝试在与JavaScript的React中建立一个财富网站,但是我在Instagram的iOS内应用程序内浏览器中显示动画时遇到了一个问题。它在其他地方工作 - 在Chrome和Safari的iOS和Android设备上 - 以及Facebook的应用程序内浏览器。但是在Instagram上,应用程序内浏览器动画大约延迟了3秒钟(当我在故事中发布链接或在Bio中具有链接时)。

我已经检查了Instagram正在使用WebKit,因此这是目标。我尝试了所有可以在网上找到的建议。添加:

-webkit-transform: translate3d(0,0,0),
-webkit-transform: translateX(-100%);,
-webkit-backface-visibility: hidden,
-webkit-perspective: 1000;

后面和透视图确实在Facebook的应用程序内浏览器中解决了故障错误 - 但在Instagram上没有解决。我还尝试使用“ Will-Change”。

我唯一要工作的是添加:

wheel.style.webkitTransitionDelay = "-3.2s"

如果我切断动画的开始,它可以立即开始。但这也切断了便利性 - 并且还可以消除平稳的易感性。我研究了300毫秒延迟的WebView-但我认为这不是问题。立即检测到单击按钮 - 我使用旋转轮的音频,该音频立即开始。这只是动画的问题。

这不仅在变换​​和过渡方面 - 我还对密钥帧应用了模糊,而且这种模糊延迟了相同的数量。这意味着模糊和过渡仅实际显示6秒 - 因为前3秒没有显示。

有人对如何解决这个问题有任何想法吗?如果我可以保持延迟,我可以使用延迟来忍受。

.blur {
  animation: blur 9s;
}

@keyframes blur {
  0% {
    filter: blur(0px);
  }
  15% {
    filter: blur(1.5px);
  }
  80% {
    filter: blur(1.5px);
  }
  100% {
    filter: blur(0px);
  }
}
  function start() {
    const startButton = document.querySelector(".button");
    const wheel = document.querySelector(".wheel");
    const audio = document.getElementById("sound");
    audio.play();
    startButton.classList.add("disabled");
    startButton.style.pointerEvents = "none";

    deg = Math.floor(5000 + Math.random() * 5000);
   
    wheel.style.transition = "all 9s ease-in-out";
    wheel.style.webkitTransition = "all 9s ease-in-out";

    wheel.style.transform = `rotate(${deg}deg)`;
    wheel.style.webkitTransform = `rotate(${deg}deg)`;

    // Apply the blur
    wheel.classList.add("blur");

    wheel.addEventListener("transitionend", doSomething);
    wheel.addEventListener("webkitTransitionEnd", doSomething);
  }



  return (
    <>
      <audio id="sound" src="/wheel.mp3" preload="auto">
        Your browser does not support the <code>audio</code> element.
      </audio>
      <div id="outer">
        <div id="app">
          <img className="foot" style={{ pointerEvents: "none" }} src="foot.png" />
          <img className="wheel" style={{ pointerEvents: "none" }} src="wheel.png" />
          <img className="marker" style={{ pointerEvents: "none" }} src="marker.png" />
          <img
            onClick={() => start()}
            className="button"
            src="button.png"
          />
        </div>
        <div id="web-cam">
          <video ref={videoRef} playsInline id="video" muted>
            <source src={currentVideo} id="source" type="video/mp4" />
          </video>
          <div className="shadow"></div>
        </div>
      </div>
    </>
  );
}


I am trying to make a wheel of fortune website in React with JavaScript, but I'm having an issue displaying the animations inside of Instagram's iOS in-app browser. It works everywhere else - on iOS and Android devices in Chrome and Safari - and also in Facebook's in-app browser. But on Instagrams in-app browser animations are delayed around 3 seconds (when I post a link in a story or have a link in the bio).

I have checked that Instagram is using webkit, so this is the one to target. I tried all the suggestions I could find online. Adding:

-webkit-transform: translate3d(0,0,0),
-webkit-transform: translateX(-100%);,
-webkit-backface-visibility: hidden,
-webkit-perspective: 1000;

backface and perspective did fix a glitch error in Facebook's in-app browser - but not on Instagram. I also tried using "will-change".

The only thing that I got to work was to add:

wheel.style.webkitTransitionDelay = "-3.2s"

So it can start right away - if I cut off the beginning of the animation. But this also cuts off the ease-in - and it also removes the smooth ease-out. I looked into the Webview 300 ms delay - but I don't think this is the issue. The click on the button is detected straight away - and I use audio of a spinning wheel, which starts instantly. It is only an issue with animations.

It's also not only in regard to transform and transition - I also apply a blur with keyframes, and this blur is delayed the same amount. This means that both blur and transitions are only actually displayed for 6 seconds - because the first 3 seconds are not being shown.

Does anybody have any ideas on how to fix this? I could live with using the delay if I could keep the ease in and out.

.blur {
  animation: blur 9s;
}

@keyframes blur {
  0% {
    filter: blur(0px);
  }
  15% {
    filter: blur(1.5px);
  }
  80% {
    filter: blur(1.5px);
  }
  100% {
    filter: blur(0px);
  }
}
  function start() {
    const startButton = document.querySelector(".button");
    const wheel = document.querySelector(".wheel");
    const audio = document.getElementById("sound");
    audio.play();
    startButton.classList.add("disabled");
    startButton.style.pointerEvents = "none";

    deg = Math.floor(5000 + Math.random() * 5000);
   
    wheel.style.transition = "all 9s ease-in-out";
    wheel.style.webkitTransition = "all 9s ease-in-out";

    wheel.style.transform = `rotate(${deg}deg)`;
    wheel.style.webkitTransform = `rotate(${deg}deg)`;

    // Apply the blur
    wheel.classList.add("blur");

    wheel.addEventListener("transitionend", doSomething);
    wheel.addEventListener("webkitTransitionEnd", doSomething);
  }



  return (
    <>
      <audio id="sound" src="/wheel.mp3" preload="auto">
        Your browser does not support the <code>audio</code> element.
      </audio>
      <div id="outer">
        <div id="app">
          <img className="foot" style={{ pointerEvents: "none" }} src="foot.png" />
          <img className="wheel" style={{ pointerEvents: "none" }} src="wheel.png" />
          <img className="marker" style={{ pointerEvents: "none" }} src="marker.png" />
          <img
            onClick={() => start()}
            className="button"
            src="button.png"
          />
        </div>
        <div id="web-cam">
          <video ref={videoRef} playsInline id="video" muted>
            <source src={currentVideo} id="source" type="video/mp4" />
          </video>
          <div className="shadow"></div>
        </div>
      </div>
    </>
  );
}


如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文