bootstrap-detect-breakpoint
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "bootstrap-detect-breakpoint", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Detect the current Bootstrap 4 breakpoint in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,5 +18,12 @@ # bootstrap-detect-breakpoint | ||
``` | ||
which will return an object with the current breakpoint name and index, | ||
like this | ||
which will return "xs", "sm", "md", "lg" or "xl". | ||
```json | ||
{ | ||
"name": "lg", | ||
"index": 3 | ||
} | ||
``` | ||
The index goes fro 0-4, where 0 is "xs" and 4 is "xl". |
@@ -1,2 +0,2 @@ | ||
const DetectBreakpoint = (function() { | ||
const DetectBreakpoint = (function () { | ||
const breakpointNames = ["xl", "lg", "md", "sm", "xs"] | ||
@@ -9,5 +9,7 @@ let breakpointValues = [] | ||
current: () => { | ||
let i = breakpointNames.length | ||
for (const breakpointName of breakpointNames) { | ||
if(window.matchMedia("(min-width: " + breakpointValues[breakpointName] + ")").matches) { | ||
return breakpointName | ||
i-- | ||
if (window.matchMedia("(min-width: " + breakpointValues[breakpointName] + ")").matches) { | ||
return {name: breakpointName, index: i} | ||
} | ||
@@ -18,2 +20,2 @@ } | ||
} | ||
})(); | ||
})() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2087
4
18
29