我正在尝试从这个网站复制滚动功能(视频和文本),但我的视频是一个长乐透文件。

我使用以下框架:Nextjs、React、Tailwind

多次尝试失败后出现以下代码。我无法固定乐透,让它看起来像一个连续的动画。当位置粘滞/固定时,由于某种原因,它不会在滚动上设置动画。非常感谢你的帮助。非常感谢。

The code below is after many failed attempts. I'm unable to keep the lottie fixed and make it look like one continuous animation. When the position is sticky/fixed it isn't animated on scroll for some reason. Would really appreciate some help. Thank you.

`import Head from 'next/head'
import backgroundImage from '@/images/background-faqs.jpg'
import Image from 'next/future/image'

import { CallToAction } from '@/components/CallToAction'
import { Faqs } from '@/components/Faqs'
import { Footer } from '@/components/Footer'
import { Header } from '@/components/Header'
import { Hero } from '@/components/Hero'
import { Pricing } from '@/components/Pricing'
import { PrimaryFeatures } from '@/components/PrimaryFeatures'
import { SecondaryFeatures } from '@/components/SecondaryFeatures'
import { testimonials } from '@/components/testimonials'
import React, { useState } from 'react'

import { useLottie, useLottieInteractivity } from 'lottie-react'
import likeButton from '../images/lottie.json'

const options = {
  animationData: likeButton,
}

const LottieAnimation = () => {
  const lottieObj = useLottie(options)
  const Animation = useLottieInteractivity({
    lottieObj,
    mode: 'scroll',
    container: 'lottie_container',
    actions: [
      {
        visibility: [0, 0.3],
        type: 'stop',
        frames: [0],
      },
      {
        visibility: [0.3, 0.7],
        type: 'seek',
        frames: [0, 100],
      },
      {
        visibility: [0.7, 1.0],
        type: 'stop',
        frames: [100],
      },
    ],
  })

  return Animation
}

const LottieAnimation2 = () => {
  const lottieObj = useLottie(options)
  const Animation = useLottieInteractivity({
    lottieObj,
    mode: 'scroll',
    container: 'lottie_container',
    actions: [
      {
        visibility: [0, 0.3],
        type: 'stop',
        frames: [100],
      },
      {
        visibility: [0.3, 0.7],
        type: 'seek',
        frames: [100, 107],
      },
      {
        visibility: [0.7, 1.0],
        type: 'stop',
        frames: [107],
      },
    ],
  })

  return Animation
}

const LottieAnimation3 = () => {
  const lottieObj = useLottie(options)
  const Animation = useLottieInteractivity({
    lottieObj,
    mode: 'scroll',
    container: 'lottie_container',
    actions: [
      {
        visibility: [0, 0.3],
        type: 'stop',
        frames: [107],
      },
      {
        visibility: [0.4, 0.6],
        type: 'seek',
        frames: [107, 115],
      },
      {
        visibility: [0.7, 1.0],
        type: 'stop',
        frames: [115],
      },
    ],
  })

  return Animation
}

const LottieAnimation4 = () => {
  const lottieObj = useLottie(options)
  const Animation = useLottieInteractivity({
    lottieObj,
    mode: 'scroll',
    container: 'lottie_container',
    actions: [
      {
        visibility: [0, 0.3],
        type: 'stop',
        frames: [0],
      },
      {
        visibility: [0.4, 0.6],
        type: 'seek',
        frames: [0, 100],
      },
      {
        visibility: [0.7, 1.0],
        type: 'seek',
        frames: [100, 0],
      },
    ],
  })

  return Animation
}

const LottieAnimation5 = () => {
  const lottieObj = useLottie(options)
  const Animation = useLottieInteractivity({
    lottieObj,
    mode: 'scroll',
    container: 'lottie_container',
    actions: [
      {
        visibility: [0, 0.3],
        type: 'stop',
        frames: [0],
      },
      {
        visibility: [0.4, 0.6],
        type: 'seek',
        frames: [0, 100],
      },
      {
        visibility: [0.7, 1.0],
        type: 'seek',
        frames: [100, 0],
      },
    ],
  })

  return Animation
}

export default function Home() {
  return (
    <>
      <div class="absolute inset-x-0 top-[-10rem] -z-10 transform-gpu overflow-hidden blur-3xl sm:top-[-20rem]">
        <svg
          class="relative left-[calc(50%-11rem)] -z-10 h-[21.1875rem] max-w-none -translate-x-1/2 rotate-[30deg] sm:left-[calc(50%-30rem)] sm:h-[42.375rem]"
          viewBox="0 0 1155 678"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            fill="url(#45de2b6b-92d5-4d68-a6a0-9b9b2abad533)"
            fill-opacity=".25"
            d="M317.219 518.975L203.852 678 0 438.341l317.219 80.634 204.172-286.402c1.307 132.337 45.083 346.658 209.733 145.248C936.936 126.058 882.053-94.234 1031.02 41.331c119.18 108.451 130.68 295.337 121.53 375.223L855 299l21.173 362.054-558.954-142.079z"
          />
          <defs>
            <linearGradient
              id="45de2b6b-92d5-4d68-a6a0-9b9b2abad533"
              x1="1155.49"
              x2="-78.208"
              y1=".177"
              y2="474.645"
              gradientUnits="userSpaceOnUse"
            >
              <stop stop-color="#9089FC"></stop>
              <stop offset="1" stop-color="#FF80B5"></stop>
            </linearGradient>
          </defs>
        </svg>
      </div>
      <Head>
        <title>Machinery Analytics</title>
        <meta name="description" content="need to fill" />
      </Head>
      <Header />
      <main>
        <div>
          <Hero />
          <div class="absolute inset-x-0 top-[calc(100%-13rem)] -z-10 transform-gpu overflow-hidden blur-3xl sm:top-[calc(100%-30rem)]">
            <svg
              class="relative left-[calc(50%+3rem)] h-[21.1875rem] max-w-none -translate-x-1/2 sm:left-[calc(50%+36rem)] sm:h-[42.375rem]"
              viewBox="0 0 1155 678"
              xmlns="http://www.w3.org/2000/svg"
            >
              <path
                fill="url(#ecb5b0c9-546c-4772-8c71-4d3f06d544bc)"
                fill-opacity=".3"
                d="M317.219 518.975L203.852 678 0 438.341l317.219 80.634 204.172-286.402c1.307 132.337 45.083 346.658 209.733 145.248C936.936 126.058 882.053-94.234 1031.02 41.331c119.18 108.451 130.68 295.337 121.53 375.223L855 299l21.173 362.054-558.954-142.079z"
              />
              <defs>
                <linearGradient
                  id="ecb5b0c9-546c-4772-8c71-4d3f06d544bc"
                  x1="1155.49"
                  x2="-78.208"
                  y1=".177"
                  y2="474.645"
                  gradientUnits="userSpaceOnUse"
                >
                  <stop stop-color="#9089FC"></stop>
                  <stop offset="1" stop-color="#FF80B5"></stop>
                </linearGradient>
              </defs>
            </svg>
          </div>
        </div>

        <div id="lottie_container" class="flex scroll-smooth">
          <div class="ml-auto inline-block w-full md:w-5/12">
            <div class="flex h-screen flex-col items-center justify-center">
              <LottieAnimation />
            </div>
            <div class="flex h-screen flex-col items-center justify-center">
              <LottieAnimation2 />
            </div>
            <div class="flex h-screen flex-col items-center justify-center">
              <LottieAnimation3 />
            </div>
            <div class="flex h-screen flex-col items-center justify-center">
              <LottieAnimation4 />
            </div>
            <div class="flex h-screen flex-col items-center justify-center">
              <LottieAnimation5 />
            </div>
          </div>
          <div class="ml-auto inline-block w-full md:w-5/12">
            <div class="flex h-screen flex-col items-center justify-center">
              <h2 class="mb-5 text-4xl">Animation 1</h2>
              <p class="mb-5">description</p>
            </div>
            <div class="flex h-screen flex-col items-center justify-center">
              <h2 class="mb-5 text-4xl">Animation 2</h2>
              <p class="mb-5">description</p>
            </div>
            <div class="flex h-screen flex-col items-center justify-center">
              <h2 class="mb-5 text-4xl">Animation 3</h2>
              <p class="mb-5">description</p>
            </div>
            <div class="flex h-screen flex-col items-center justify-center">
              <h2 class="mb-5 text-4xl">Animation 4</h2>
              <p class="mb-5">description</p>
            </div>
            <div class="flex h-screen flex-col items-center justify-center">
              <h2 class="mb-5 text-4xl">Animation 5</h2>
              <p class="mb-5">description</p>
            </div>
          </div>
        </div>

        <PrimaryFeatures />
        <SecondaryFeatures />
        <CallToAction />
        <testimonials />
        <Pricing />
        <Faqs />
      </main>
      <Footer />
    </>
  )
}

{
  /* <div id="lottie_container" class="flex h-[1200px]">
          <div class="ml-auto inline-block w-full md:w-5/12">
            <div class="flex h-screen flex-col items-center justify-center">
              <div class="mb-5">
                <LottieAnimation />
              </div>
            </div>
          </div>
          <div class="ml-auto inline-block w-full md:w-5/12">
            <div class="flex h-screen flex-col items-center justify-center">
              <h2 class="mb-5 text-4xl">Title 1</h2>
              <p class="mb-5">Description 1</p>
            </div>
            <div class="flex h-screen flex-col items-center justify-center">
              <h2 class="mb-5 text-4xl">Meet Benny</h2>
              <p class="mb-5">I was born 20 May 2020</p>
            </div>
            <div class="flex h-screen flex-col items-center justify-center">
              <h2 class="mb-5 text-4xl">Meet Benny</h2>
              <p class="mb-5">I was born 20 May 2020</p>
            </div>
          </div>
        </div> */
}
`

在容器中的固定位置滚动乐透动画,直到乐透完成,然后相对的更多相关文章

  1. Next.js实现react服务器端渲染的方法示例

    这篇文章主要介绍了Next.js实现react服务器端渲染的方法示例,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

  2. react框架next.js学习之API 路由篇详解

    这篇文章主要为大家介绍了react框架next.js学习之API 路由篇详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪

  3. Android 第三方库lottie、mmkv的使用详解

    lottie是Airbnb开源的一个面向 iOS、Android、React Native 的动画库,能实现精美、复杂的动画效果,本文通过实例代码给大家介绍Android 第三方库lottie、mmkv的使用,感兴趣的的朋友一起看看吧

  4. React Native项目中使用Lottie动画的方法

    这篇文章主要介绍了React Native 实现Lottie动画的相关知识,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  5. ReactJs快速入门教程(精华版)

    React 起源于 Facebook 的内部项目,因为该公司对市场上所有 JavaScript MVC 框架,都不满意,就决定自己写一套,用来架设 Instagram 的网站.这篇文章主要介绍了ReactJs快速入门教程(精华版)的相关资料,需要的朋友可以参考下

  6. 再次谈论React.js实现原生js拖拽效果引起的一系列问题

    React 起源于 Facebook 的内部项目,因为该公司对市场上所有 JavaScript MVC 框架,都不满意,就决定自己写一套,用来架设 Instagram 的网站.本文给大家介绍React.js实现原生js拖拽效果,需要的朋友一起学习吧

  7. next.js初始化参数设置getServerSideProps应用学习

    这篇文章主要为大家介绍了next.js初始化参数设置getServerSideProps的应用示例学习,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪

  8. 详解使用webpack+electron+reactJs开发windows桌面应用

    这篇文章主要介绍了详解使用webpack+electron+reactJs开发windows桌面应用,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

  9. Reactjs + Nodejs + Mongodb 实现文件上传功能实例详解

    今天是使用 Reactjs + Nodejs + Mongodb 实现文件上传功能,前端我们使用 Reactjs + Axios 来搭建前端上传文件应用,后端我们使用 Node.js + Express + Multer + Mongodb 来搭建后端上传文件处理应用,本文通过实例代码给大家介绍的非常详细,需要的朋友参考下吧

  10. React.js入门实例教程之创建hello world 的5种方式

    React 是近期非常热门的一个前端开发框架。应用非常广泛,接下来通过本文给大家介绍React.js入门实例教程之创建hello world 的5种方式 ,需要的朋友参考下吧

随机推荐

  1. 如何扩展ATmega324PB微控制器的以下宏寄存器?

    我目前正在学习嵌入式,我有以下练习:展开以下宏寄存器:如果有人解决了这个问题,我将不胜感激,以便将来参考

  2. Python将ONNX运行时设置为返回张量而不是numpy数组

    在python中,我正在加载预定义的模型:然后我加载一些数据并运行它:到目前为止,它仍在正常工作,但我希望它默认返回Tensor列表,而不是numpy数组。我对ONNX和PyTorch都是新手,我觉得这是我在这里缺少的基本内容。这将使转换中的一些开销相同。

  3. 在macOS上的终端中使用Shell查找文件中的单词

    我有一个文本文件,其中有一行:我需要找到ID并将其提取到变量中。我想出了一个RexEx模式:但它似乎对我尝试过的任何东西都不起作用:grep、sed——不管怎样。我的一个尝试是:我为这样一个看似愚蠢的问题感到抱歉,但我在互联网上找不到任何东西:我在SO和SE上读了几十个类似的问题,并在谷歌上搜索了几个教程,但仍然无法找到答案。欢迎提供任何指导!

  4. react-chartjs-2甜甜圈图中只有标题未更新

    我正在使用react-chartjs-2在我的网站中实现甜甜圈图。下面是我用来呈现图表的代码。我将甜甜圈图的详细信息从父组件传递到子组件,所有道具都正确传递。当我在beforeDraw函数外部记录props.title时,它会记录正确的值,但当我在beforeDraw函数内部记录props.title时,它将记录标题的前一个值,从而呈现标题的前值。我在这里做错了什么?

  5. 如何在tkinter中使用Python生成器函数?

    生成器函数承诺使某些代码更易于编写。但我并不总是知道如何使用它们。假设我有一个斐波那契生成器函数fib(),我想要一个显示第一个结果的tkinter应用程序。当我点击“下一步”按钮时,它会显示第二个数字,依此类推。我如何构建应用程序来实现这一点?我可能需要在线程中运行生成器。但如何将其连接回GUI?

  6. 如何为每次提交将存储库历史记录拆分为一行?

    我正在尝试获取存储库的历史记录,但结果仅以单行文本的形式返回给我。

  7. 尝试在颤振项目上初始化Firebase时出错

    当尝试在我的颤振项目上初始化firebase时,我收到了这个错误有人知道我能做什么吗?应用程序分级Gradle插件Gradle项目颤振相关性我已经将firebase设置为Google文档已经在另一个模拟器上尝试过,已经尝试过创建一个全新的模拟器,已经在不同的设备上尝试过了,已经尝试了特定版本的firebase,已经尝试添加但没有任何效果,已经在youtube上看到了关于它的每一个视频,该应用程序在android和iOS两个平台上都抛出了这个错误

  8. 在unix中基于当前日期添加新列

    我试图在unix中基于时间戳列在最后一个单元格中添加一个状态列。我不确定如何继续。

  9. 麦克斯·蒙特利。我一直得到UncaughtReferenceError:当我在终端中写入node-v时,节点未定义

    如果这是您应该知道的,请确认:我已将所有shell更改为默认为zsh。当我在终端中写入node-v时,我一直收到“UncaughtReferenceError:nodeisnotdefined”。但它显示节点已安装。我是个新手,在这方面经验不足。

  10. 如何在前端单击按钮时调用后端中的函数?

    那么如何在后端添加一个新的端点,点击按钮调用这个函数。

返回
顶部