0

我使用以下插件来浮动左侧菜单,如下我已经启动它,

$('.float-menu').galleryFloatMenu({duration: 800, topPosition: 68});

问题和行如下所示。

(function($){
  $.galleryFloatMenu = function(el, options) {
    var base = this;
    base.$el = $(el);
    base.el = el;
    base.$el.data('galleryFloatMenu', base);

    base.init = function() {
      base.options = $.extend({}, $.galleryFloatMenu.defaultOptions, options);

      var $parent          = base.$el.parent();
      var parentPaddingTop = parseInt($parent.css('padding-top'));
      var startOffset      = $parent.offset().top;

      recalcHeight($parent);
      var calculatedOptions = { 
        startOffset: startOffset, 
        offsetY: parentPaddingTop
      }
      base.options = $.extend(calculatedOptions, base.options);
      base.$el.css({ position: 'absolute' });
      base.enableScroll();
    };

    base.scroll = function() {
      base.$el.stop(); 

      var pastStartOffset      = $(document).scrollTop() > base.options.startOffset; 
      var objFartherThanTopPos = base.$el.offset().top > base.options.startOffset;
      var objBiggerThanWindow  = base.$el.outerHeight() < $(window).height();
      var doScroll = (pastStartOffset || objFartherThanTopPos) && objBiggerThanWindow;
      var docScrollTop = $(document).scrollTop();

      if( doScroll ){
        var newpos = (docScrollTop - base.options.startOffset + base.options.offsetY );
        if ( newpos > base.options.bottomPos )
          newpos = base.options.bottomPos;
        if ( docScrollTop < base.options.startOffset ) {
          newpos = base.options.offsetY;
        }
        base.$el.animate({ top: newpos+options.topPosition }, base.options.duration, 'easeOutCirc' );
      }
    };

    base.enableScroll = function() {
      $(window).bind('scroll', base.scroll);
    }

    base.disableScroll = function() {
      $(window).unbind('scroll', base.scroll);
    }

    base.init();
  };

  $.galleryFloatMenu.defaultOptions = { duration: 1200, paused: false, topPosition: 0 }

  $.fn.galleryFloatMenu = function(options) {
    return this.each(function() {
      (new $.galleryFloatMenu(this, options));
    });
  };

  // PRIVATE FUNCTIONS
  function recalcHeight($obj) {
    //$obj.css({ height: $obj.parent().height() - $obj.height()})
  };
})(jQuery);


  var calculatedOptions = { 
    startOffset: startOffset, 
    offsetY: parentPaddingTop
  }

IE7 错误:预期的标识符、字符串或数字

相同的脚本适用于所有其他浏览器

4

0 回答 0