]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
cleans up variable declaration in sticky._unstick and fixes an issue where namespaced...
authorzurbchris <chris@zurb.com>
Wed, 25 Nov 2015 01:16:20 +0000 (17:16 -0800)
committerzurbchris <chris@zurb.com>
Wed, 25 Nov 2015 01:16:20 +0000 (17:16 -0800)
js/foundation.sticky.js

index e80328a2ee5b1b4241a34b15580c5d7da2ce2c48..b3166ee0f53212e72c5793a5636e0d53fa49f6f8 100644 (file)
     }
       // console.log(breaks);
     this.points = breaks;
-    // console.log(this.points);
     return;
   };
 
   Sticky.prototype._removeSticky = function(isTop){
     var stickTo = this.options.stickTo,
         stickToTop = stickTo === 'top',
-        css = {}, mrgn, notStuckTo,
-        anchorPt = (this.points ? this.points[1] - this.points[0] : this.anchorHeight) - this.elemHeight;
-        mrgn = stickToTop ? 'marginTop' : 'marginBottom';
-        notStuckTo = stickToTop ? 'bottom' : 'top';
-      css[mrgn] = 0;
+        css = {},
+        anchorPt = (this.points ? this.points[1] - this.points[0] : this.anchorHeight) - this.elemHeight,
+        mrgn = stickToTop ? 'marginTop' : 'marginBottom',
+        notStuckTo = stickToTop ? 'bottom' : 'top',
+        topOrBottom = isTop ? 'top' : 'bottom';
+
+    css[mrgn] = 0;
+
     if((isTop && !stickToTop) || (stickToTop && !isTop)){
       css[stickTo] = anchorPt;
       css[notStuckTo] = 0;
       css[stickTo] = 0;
       css[notStuckTo] = anchorPt;
     }
+    
     css['left'] = '';
     this.isStuck = false;
     this.$element.removeClass('is-stuck is-at-' + stickTo)
-                 .addClass('is-anchored is-at-' + (isTop ? 'top' : 'bottom'))
+                 .addClass('is-anchored is-at-' + topOrBottom)
                  .css(css)
                  /**
                   * Fires when the $element has become anchored.
                   * Namespaced to `top` or `bottom`.
                   * @event Sticky#unstuckfrom
                   */
-                 .trigger('sticky.zf.unstuckfrom:' + isTop ? 'top' : 'bottom');
+                 .trigger('sticky.zf.unstuckfrom:' + topOrBottom);
   };
 
   /**