]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Fix styling and non- case
authorKevin Ball <kmball11@gmail.com>
Wed, 25 Jan 2017 21:43:53 +0000 (13:43 -0800)
committerKevin Ball <kmball11@gmail.com>
Wed, 25 Jan 2017 21:43:53 +0000 (13:43 -0800)
js/foundation.sticky.js

index 14d7ddc930d5fa010d67b6286b91c7aa520478f1..6ce98a71a1d92416b988c7302750eb0a4d0916a1 100644 (file)
@@ -42,9 +42,9 @@ class Sticky {
     this.$container.addClass(this.options.containerClass);
 
     this.$element.addClass(this.options.stickyClass).attr({ 'data-resize': id, 'data-mutate': id });
-       if (this.options.anchor !== '') {
-               $('#' + _this.options.anchor).attr({ 'data-mutate': id });
-       }
+    if (this.options.anchor !== '') {
+        $('#' + _this.options.anchor).attr({ 'data-mutate': id });
+    }
 
     this.scrollCount = this.options.checkEvery;
     this.isStuck = false;
@@ -131,35 +131,37 @@ class Sticky {
                  .on('resizeme.zf.trigger', function(e, el) {
                     _this._eventsHandler(id);
     });
-       
-       this.$element.on('mutateme.zf.trigger', function (e, el) {
-               _this._eventsHandler(id);
-       });
-       
-       this.$anchor.on('mutateme.zf.trigger', function (e, el) {
-               _this._eventsHandler(id);
-       });
+
+    this.$element.on('mutateme.zf.trigger', function (e, el) {
+        _this._eventsHandler(id);
+    });
+
+    if(this.$anchor) {
+      this.$anchor.on('mutateme.zf.trigger', function (e, el) {
+          _this._eventsHandler(id);
+      });
+    }
   }
-  
+
   /**
    * Handler for events.
    * @private
    * @param {String} id - psuedo-random id for unique scroll event listener.
    */
   _eventsHandler(id) {
-          var _this = this,
+       var _this = this,
         scrollListener = this.scrollListener = `scroll.zf.${id}`;
-               
-          _this._setSizes(function() {
-          _this._calc(false);
-          if (_this.canStick) {
-                if (!_this.isOn) {
-                  _this._events(id);
-                }
-          } else if (_this.isOn) {
-                _this._pauseListeners(scrollListener);
-          }
-        });
+
+       _this._setSizes(function() {
+       _this._calc(false);
+       if (_this.canStick) {
+         if (!_this.isOn) {
+           _this._events(id);
+         }
+       } else if (_this.isOn) {
+         _this._pauseListeners(scrollListener);
+       }
+     });
   }
 
   /**
@@ -385,7 +387,7 @@ class Sticky {
                    'max-width': ''
                  })
                  .off('resizeme.zf.trigger')
-                                .off('mutateme.zf.trigger');
+                 .off('mutateme.zf.trigger');
     if (this.$anchor && this.$anchor.length) {
       this.$anchor.off('change.zf.sticky');
     }