]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
check if cb is a function
authormaks feltrin <pine3ree@gmail.com>
Mon, 29 Aug 2016 23:27:41 +0000 (01:27 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Aug 2016 23:27:41 +0000 (01:27 +0200)
js/foundation.sticky.js

index 64060c5ba62502d63264df68776efc55b6a48314..69ddd97ae69d041477077e6e68549636971c5e4c 100644 (file)
@@ -267,7 +267,9 @@ class Sticky {
    */
   _setSizes(cb) {
     this.canStick = Foundation.MediaQuery.atLeast(this.options.stickyOn);
-    if (!this.canStick) { cb(); }
+    if (!this.canStick) {
+      if (cb && typeof cb === 'function') { cb(); }
+    }
     var _this = this,
         newElemWidth = this.$container[0].getBoundingClientRect().width,
         comp = window.getComputedStyle(this.$container[0]),
@@ -303,7 +305,7 @@ class Sticky {
     }
 
     this._setBreakPoints(newContainerHeight, function() {
-      if (cb) { cb(); }
+      if (cb && typeof cb === 'function') { cb(); }
     });
   }
 
@@ -315,7 +317,7 @@ class Sticky {
    */
   _setBreakPoints(elemHeight, cb) {
     if (!this.canStick) {
-      if (cb) { cb(); }
+      if (cb && typeof cb === 'function') { cb(); }
       else { return false; }
     }
     var mTop = emCalc(this.options.marginTop),
@@ -339,7 +341,7 @@ class Sticky {
     this.topPoint = topPoint;
     this.bottomPoint = bottomPoint;
 
-    if (cb) { cb(); }
+    if (cb && typeof cb === 'function') { cb(); }
   }
 
   /**