光标的关键帧动画在Safari中不起作用

发布于 2025-01-29 07:48:00 字数 1793 浏览 3 评论 0原文

我有一个转换为图像的gif。用户单击屏幕后,将使用钥匙帧对光标进行动画。除Safari以外,它在每个浏览器中都可以正常工作。我尝试了几乎所有事情,我在做什么错?

CSS

@keyframes cursor {
  0% {
    cursor: url("./images/frames/1.gif"), auto;
  }
  20% {
    cursor: url("./images/frames/2.gif"), auto;
  }
  40% {
    cursor: url("./images/frames/3.gif"), auto;
  }
  60% {
    cursor: url("./images/frames/4.gif"), auto;
  }
  80% {
    cursor: url("./images/frames/5.gif"), auto;
  }
  100% {
    cursor: url("./images/frames/6.gif"), auto;
  }
}

@-webkit-keyframes cursor {
  0% {
    cursor: url("./images/frames/1.gif"), auto;
  }
  20% {
    cursor: url("./images/frames/2.gif"), auto;
  }
  40% {
    cursor: url("./images/frames/3.gif"), auto;
  }
  60% {
    cursor: url("./images/frames/4.gif"), auto;
  }
  80% {
    cursor: url("./images/frames/5.gif"), auto;
  }
  100% {
    cursor: url("./images/frames/6.gif"), auto;
  }
}



JS

const productPage = document.querySelector('.product-page')

      if (!this.state.done) {

        productPage.style.animation = "cursor 0.2s linear"
        productPage.style.webkitAnimation = "cursor 0.2s linear"

        setTimeout(() => {
          productPage.style.animation = "none"
        }, 210);
        
      }

我什至尝试使用Pure JS而不是KeyFrames,

const productPage = document.querySelector('.product-page')

      if (!this.state.done) {

        let gifNumber = 1

        const cursorInterval = setInterval(() => {

          discountPage.style.cursor = `url("./images/frames/${gifNumber}.gif") 37 37, auto`

          gifNumber++

          if (gifNumber > 5) {
            clearInterval(cursorInterval)
          }

        }, 1);

      }
 

这也可以在其他浏览器中使用,但在Safari中也不起作用。我想不可能动态更改Safari中的光标

I have a gif that I converted into an images. After the user clicks on the screen, the cursor is animated with keyframes. It works perfectly in every browser except Safari. I tried almost everything, what am I doing wrong?

CSS

@keyframes cursor {
  0% {
    cursor: url("./images/frames/1.gif"), auto;
  }
  20% {
    cursor: url("./images/frames/2.gif"), auto;
  }
  40% {
    cursor: url("./images/frames/3.gif"), auto;
  }
  60% {
    cursor: url("./images/frames/4.gif"), auto;
  }
  80% {
    cursor: url("./images/frames/5.gif"), auto;
  }
  100% {
    cursor: url("./images/frames/6.gif"), auto;
  }
}

@-webkit-keyframes cursor {
  0% {
    cursor: url("./images/frames/1.gif"), auto;
  }
  20% {
    cursor: url("./images/frames/2.gif"), auto;
  }
  40% {
    cursor: url("./images/frames/3.gif"), auto;
  }
  60% {
    cursor: url("./images/frames/4.gif"), auto;
  }
  80% {
    cursor: url("./images/frames/5.gif"), auto;
  }
  100% {
    cursor: url("./images/frames/6.gif"), auto;
  }
}

JS

const productPage = document.querySelector('.product-page')

      if (!this.state.done) {

        productPage.style.animation = "cursor 0.2s linear"
        productPage.style.webkitAnimation = "cursor 0.2s linear"

        setTimeout(() => {
          productPage.style.animation = "none"
        }, 210);
        
      }

I even tried to use pure JS instead of keyframes

const productPage = document.querySelector('.product-page')

      if (!this.state.done) {

        let gifNumber = 1

        const cursorInterval = setInterval(() => {

          discountPage.style.cursor = `url("./images/frames/${gifNumber}.gif") 37 37, auto`

          gifNumber++

          if (gifNumber > 5) {
            clearInterval(cursorInterval)
          }

        }, 1);

      }
 

this one also worked in other browsers but not in Safari. I guess it's not possible to dynamically change the cursor in Safari

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

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

发布评论

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