/**
* Customizable container template. Add your own classes for styling and sizing.
* @option
- * @example '<div data-sticky-container class="small-6 columns"></div>'
+ * @example '<div data-sticky-container class="small-6 columns"></div>'
*/
container: '<div data-sticky-container></div>',
/**
this.scrollCount = this.options.checkEvery;
this.isStuck = false;
- // console.log(this.options.anchor, this.options.topAnchor);
- if(this.options.topAnchor !== ''){
- this._parsePoints();
- // console.log(this.points[0]);
+
+ if(this.options.anchor !== ''){
+ this.$anchor = $('#' + this.options.anchor);
}else{
- this.$anchor = this.options.anchor ? $('#' + this.options.anchor) : $(document.body);
+ this._parsePoints();
}
-
+ console.log(this.points);
this._setSizes(function(){
_this._calc(false);
});
btm = this.options.btmAnchor,
pts = [top, btm],
breaks = {};
- for(var i = 0, len = pts.length; i < len && pts[i]; i++){
- var pt;
- if(typeof pts[i] === 'number'){
- pt = pts[i];
- }else{
- var place = pts[i].split(':'),
- anchor = $('#' + place[0]);
-
- pt = anchor.offset().top;
- if(place[1] && place[1].toLowerCase() === 'bottom'){
- pt += anchor[0].getBoundingClientRect().height;
+ if(top && btm){
+
+ for(var i = 0, len = pts.length; i < len && pts[i]; i++){
+ var pt;
+ if(typeof pts[i] === 'number'){
+ pt = pts[i];
+ }else{
+ var place = pts[i].split(':'),
+ anchor = $('#' + place[0]);
+
+ pt = anchor.offset().top;
+ if(place[1] && place[1].toLowerCase() === 'bottom'){
+ pt += anchor[0].getBoundingClientRect().height;
+ }
}
+ breaks[i] = pt;
}
- breaks[i] = pt;
+ }else{
+ breaks = {0: 1, 1: document.documentElement.scrollHeight};
}
// console.log(breaks);
this.points = breaks;
if(this.isOn){ return; }
if(this.canStick){
this.isOn = true;
- // this.$anchor.off('change.zf.sticky')
- // .on('change.zf.sticky', function(){
- // _this._setSizes(function(){
- // _this._calc(false);
- // });
- // });
-
$(window).off(scrollListener)
.on(scrollListener, function(e){
if(_this.scrollCount === 0){