javascript - 使用航路点滚动动画

标签 javascript jquery css jquery-waypoints waypoint

一直在努力使用 waypoints.js 在滚动上复制 css 动画

这是动画:https://codepen.io/equinusocio/pen/KNYOxJ

<h1 class="reveal-text">
    I'm here.
</h1>


:root {
    --animation-delay: 0;
    --duration: 800ms;
    --iterations: 1;
}
/* ••·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•·•· */


.reveal-text,
.reveal-text::after {
    animation-delay: var(--animation-delay, 2s);
    animation-iteration-count: var(--iterations, 1);
    animation-duration: var(--duration, 800ms);
    animation-fill-mode: both;
    animation-timing-function: cubic-bezier(0.0, 0.0, 0.2, 1);
}

.reveal-text {
    position: relative;
    font-size: 10vw;
    animation-name: clip-text;
    color: #FFF;
    white-space: nowrap;
    cursor: default;

    &::after {
        content: "";
        position: absolute;
        z-index: 999;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #f2f98b;
        transform: scaleX(0);
        transform-origin: 0 50%;
        pointer-events: none;
        animation-name: text-revealer;
    }

}


@keyframes clip-text {
    from {
        clip-path: inset(0 100% 0 0);
    }
    to {
        clip-path: inset(0 0 0 0);
    }
}


@keyframes text-revealer {

    0%, 50% {
        transform-origin: 0 50%;
    }

    60%, 100% {
        transform-origin: 100% 50%;     
    }


    60% {
        transform: scaleX(1);
    }

    100% {
        transform: scaleX(0);
    }
}

这是我尝试将它与路标一起使用的尝试..

 .test {
  display: flex;
  margin: 15px;
  margin-top: 5em;
  display: flex;
  align-self: center;
  justify-content: center;
  align-content: center;
  text-align: center;
  opacity: 0;
  position: relative;
    animation-name: clip-text;
    color: $grey;
    white-space: nowrap;
  cursor: default;
}

.js-dipper-animate {
  opacity: 1;
  animation-name: text-revealer;
  content: "";
        z-index: 999;
        background-color: $grey;
        transform: scaleX(0);
        transform-origin: 0 50%;
    pointer-events: none;
}

这是输出的 gif:https://imgur.com/waCcprF 如您所见,动画播放但没有文本。它应该显示“测试”。动画播放后,我希望能够看到文本,例如显示的 gif 中的“技能”

最佳答案

现在开始工作,解决方案贴在下面

`.test,
.test::after {
    animation-delay: 0ms;
    animation-iteration-count: var(--iterations, 1);
    animation-duration: var(--duration, 800ms);
    animation-fill-mode: both;
    animation-timing-function: cubic-bezier(0.0, 0.0, 0.2, 1);
}

.test {
  display: flex;
  margin: 15px;
  margin-top: 5em;
  display: flex;
  align-self: center;
  justify-content: center;
  align-content: center;
  text-align: center;
  opacity: 0;
  position: relative;
    color: $grey;
    white-space: nowrap;
  cursor: default;
}

.js-dipper-animate {
  position: relative;
    animation-name: clip-text;
    color: $grey;
    white-space: nowrap;
  cursor: default;
  opacity: 1;

  &::after {
        content: "";
        position: absolute;
        z-index: 999;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: $grey;
        transform: scaleX(0);
        transform-origin: 0 50%;
        pointer-events: none;
    animation-name: text-revealer;
    opacity: 1;
    }
}`

关于javascript - 使用航路点滚动动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56436157/

相关文章:

javascript - “Thinking in AngularJS”,如果我有jQuery背景?

javascript - 访问删除请求 Mongoose 返回的结果

javascript - 多维数组显示

jquery - 尝试使用 jQuery 为 Zend Framework 找到 AJAX 文件上传解决方案

javascript - 如何使用serviceWorker缓存ajax响应

html - 神秘的缩进元素视频

HTML5/CSS3 - 无法更改@media 上的字体大小

html - 居中导航列表并删除默认间距?

javascript - Canvas : Restore Image after removing object on it

javascript - D3 双指缩放在 v5 中不起作用,但在 v4 中有效