]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Fix ghetto for loop
authorChris Thronebury <cthronebury@gmail.com>
Sun, 26 Jun 2016 04:31:09 +0000 (00:31 -0400)
committerChris Thronebury <cthronebury@gmail.com>
Sun, 26 Jun 2016 04:31:09 +0000 (00:31 -0400)
scss/util/_breakpoint.scss

index 15707b992074c066641b841f49732b6f51f4b989..ddcf80aa0313db174d9bd5206854ad1de08c5033 100644 (file)
@@ -176,19 +176,10 @@ $breakpoint-classes: (small medium large) !default;
 /// @returns {Mixed} The value for the key after `$key`, if `$key` was found. If `$key` was not found, or `$key` was the last value in the map, returns `null`.
 @function -zf-map-next($map, $key) {
   // Store the values of the map as a list, so we can access them with nth
-  $values: map-values($map);
-
-  // Ghetto for loop
-  $i: 1;
-  $found: false;
-  @each $val in map-keys($map) {
-    @if $found == false {
-      @if ($key == $val) {
-        $found: true;
-      }
-      $i: $i + 1;
-    }
-  }
+  $values: map-keys($map);
+
+  // Get the index of the key within the map and add 1 to it for the next breakpoint in the map
+  $i: index($values, $key) + 1;
 
   // If the key doesn't exist, or it's the last key in the map, return null
   @if $i > length($map) {
@@ -196,7 +187,8 @@ $breakpoint-classes: (small medium large) !default;
   }
   // Otherwise, return the value
   @else {
-    @return nth($values, $i);
+    @return map-get($map, nth($values, $i));
+
   }
 }