【问题标题】:Unable to turn off animation in jquery masonry + waypoint无法在 jquery masonry + waypoint 中关闭动画
【发布时间】:2014-11-14 15:06:45
【问题描述】:

滚动效果很好,但我想摆脱动画。

我尝试了所有推荐的解决方案,例如这里提到了一个http://desandro.github.io/masonry/docs/animating.html,但没有任何效果。

砌体代码:

<script src="{{asset('js/vendor/masonry.pkgd.min.js')}}"></script>
<script src="{{asset('js/vendor/waypoints.min.js')}}"></script>
<script src="{{asset('js/vendor/waypoints-infinite.js')}}"></script>
<script>
    $(window).load(function () {
        /*var container = $('.infinite-container');*/
        var container = $('.infinite-container').masonry({
            // options...
            itemSelector: '.wish-box',
            isAnimated: false,
            animated: false,
          });

        $('.infinite-container').waypoint('infinite', {
            container: 'auto',
            items: '.wish-box',
            more: '.infinite-more-link',
            offset: 'bottom-in-view',
            loadingClass: 'infinite-loading',
            onBeforePageLoad: $.noop,
            animate: false,
            onAfterPageLoad: function () {
                try {
                    container.masonry('reloadItems');
                    container.masonry('layout');
                } catch (err) {
                    alert(err.message);
                }
            }
        });
    });
</script>

waypoints-infinite.js 的代码:

// Generated by CoffeeScript 1.6.2
/*
Infinite Scroll Shortcut for jQuery Waypoints - v2.0.5
Copyright (c) 2011-2014 Caleb Troughton
Licensed under the MIT license.
https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
*/

var current_uri = window.location.pathname;

(function() {
  (function(root, factory) {
    if (typeof define === 'function' && define.amd) {
      return define(['jquery', 'waypoints'], factory);
    } else {
      return factory(root.jQuery);
    }
  })(window, function($) {
    var defaults;

    defaults = {
      container: 'auto',
      items: '.infinite-item',
      more: '.infinite-more-link',
      offset: 'bottom-in-view',
      loadingClass: 'infinite-loading',
      onBeforePageLoad: $.noop,
      onAfterPageLoad: $.noop
    };
    return $.waypoints('extendFn', 'infinite', function(options) {
      var $container, opts;

      opts = $.extend({}, $.fn.waypoint.defaults, defaults, options);
      if ($(opts.more).length === 0) {
        return this;
      }
      $container = opts.container === 'auto' ? this : $(opts.container);
      opts.handler = function(direction) {
        var $this;

        if (direction === 'down' || direction === 'right') {
          $this = $(this);
          opts.onBeforePageLoad();
          $this.waypoint('destroy');
          $container.addClass(opts.loadingClass);
          return $.get($(opts.more).attr('href'), function(data) {
            var $data, $more, $newMore, fn;

            $data = $($.parseHTML(data));
            $more = $(opts.more);
            $newMore = $data.find(opts.more);
            //append for wishes and prepend for messages
            if(current_uri.indexOf("messages") !== -1) {
                $container.prepend($data.find(opts.items));
            } else {
                $container.append($data.find(opts.items));
            }
            $container.removeClass(opts.loadingClass);
            if ($newMore.length) {
              $more.replaceWith($newMore);
              fn = function() {
                return $this.waypoint(opts);
              };
              setTimeout(fn, 0);
            } else {
              $more.remove();
            }
            return opts.onAfterPageLoad();
          });
        }
      };
      return this.waypoint(opts);
    });
  });

}).call(this);

【问题讨论】:

  • 请在此处发布相关代码,以便此页面独立。一旦该链接不再可用,那么这个问题对其他人来说就毫无用处。
  • @Archer 谢谢,代码现在在那里。
  • 什么版本的砌体?

标签: javascript jquery jquery-masonry infinite-scroll jquery-waypoints


【解决方案1】:

看起来您使用的 Masonry v3 删除了动画选项,所以 isAnimated: false, 动画:false 不相关。你可以使用这个:

   var container = $('.infinite-container').masonry({
        // options...
        itemSelector: '.wish-box',
       transitionDuration: 0
      });

【讨论】:

  • 谢谢,我可以从您找到此解决方案的地方获得参考。
  • 这里是:transitionduration
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多