javascript - smoothstate.js 反转动画

标签 javascript jquery css

在 smoothstate.js 库中场景元素的反向动画有一些问题。 我在网站上工作:LINK

实际上“.is-exiting”类适用于 DOM 但动画没有发生 这是我的 CSS:

.animated .scene_element{
  -webkit-animation-duration: 1s;
          animation-duration: 1s;
  -webkit-animation-fill-mode: both;
          animation-fill-mode: both;

}

.animated.is-exiting .scene_element {
            -webkit-animation-direction: alternate-reverse;
            animation-direction: alternate-reverse; 
 }  

和 jquery

;(function ($) {
  'use strict';
  var $body    = $('html, body'), // Define jQuery collection 
      content  = $('#wrapper').smoothState({
        onStart : {
          duration: 500,
          render: function () {
            content.toggleAnimationClass('is-exiting');

            // Scroll user to the top
            $body.animate({ 'scrollTop': 0 });

          }
        }
      }).data('smoothState');
})(jQuery);

最佳答案

您在 css 中声明的动画持续时间比在 javascript 中声明的整体动画长。

1 秒与 0.5 秒

.animated .scene_element{
  -webkit-animation-duration: 1s;
          animation-duration: 1s;
onStart : {
          duration: 500,
          render: function () {

关于javascript - smoothstate.js 反转动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26329607/

相关文章:

javascript - 当部分 HTML 当前可见时,如何连续执行 Javascript 函数?

html - 网格元素不会垂直拉伸(stretch)

html - 固定背景的透明三 Angular 形

css - 在外部样式表中不显示背景图像

javascript - Web Audio API getFloatFrequencyData 函数将 Float32Array 参数数据设置为 -Infinity 值数组

javascript - 如何处理双夏令时浏览器兼容性问题

javascript - 删除包含重复属性的嵌套对象

javascript - 无法读取 React 容器中自定义 onTouch 函数中未定义的属性 'props'

php - 错误 405(不允许的方法)Laravel 5

javascript - 将函数作为事件处理程序的回调传递时,在我的 javascript 项目中获取不正确的值