sticky.js 725 Bytes
/**
 *  Module: sticky
 *  Desc: 滚动固定
 *  @author: xuan.chen@yoho.cn
 */

'use strict';

var Sticky = function(elem, options) {
    this.options = $.extend({}, Sticky.DEAFAULT, options);
    this.$elem = $(elem);
    this.$holder = $('<div></div>').height(this.$elem.height());
    this.$target = $(this.options.target)
        .on('scroll.yoho.sticky', $.proxy(this.checkPosition, this));

    this.$elem.wrapper(this.$holder);

    this.checkPosition();
};

Sticky.DEAFAULT = {
    top: 0,     // offset top, 距离附着元素的位移
    target: window  // 附着元素
};

Sticky.prototype.checkPosition = function() {
    if (!this.$elem.is('::visible')) {
        return;
    }
};



module.exports = Sticky;