bootstrap-detect-breakpoint
Advanced tools
Comparing version 1.0.2 to 1.0.4
{ | ||
"name": "bootstrap-detect-breakpoint", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"description": "Detect the current Bootstrap 4 breakpoint in JavaScript", | ||
@@ -25,3 +25,8 @@ "main": "index.js", | ||
}, | ||
"homepage": "https://github.com/shaack/bootstrap-detect-breakpoint#readme" | ||
"homepage": "https://github.com/shaack/bootstrap-detect-breakpoint#readme", | ||
"devDependencies": { | ||
"bootstrap": "^4.4.1", | ||
"jquery": "^3.5.1", | ||
"popper.js": "^1.16.1" | ||
} | ||
} |
@@ -16,3 +16,3 @@ # bootstrap-detect-breakpoint | ||
```js | ||
DetectBreakpoint.current() | ||
var currentBreakpoint = bootstrapDetectBreakpoint() | ||
``` | ||
@@ -29,2 +29,2 @@ which will return an object with the current breakpoint name and index, | ||
The index goes fro 0-4, where 0 is "xs" and 4 is "xl". | ||
The index goes from 0 to 4, where 0 is "xs" and 4 is for "xl". |
@@ -1,2 +0,2 @@ | ||
const DetectBreakpoint = (function () { | ||
const bootstrapDetectBreakpoint = function () { | ||
const breakpointNames = ["xl", "lg", "md", "sm", "xs"] | ||
@@ -7,14 +7,10 @@ let breakpointValues = [] | ||
} | ||
return { | ||
current: () => { | ||
let i = breakpointNames.length | ||
for (const breakpointName of breakpointNames) { | ||
i-- | ||
if (window.matchMedia("(min-width: " + breakpointValues[breakpointName] + ")").matches) { | ||
return {name: breakpointName, index: i} | ||
} | ||
} | ||
return null | ||
let i = breakpointNames.length | ||
for (const breakpointName of breakpointNames) { | ||
i-- | ||
if (window.matchMedia("(min-width: " + breakpointValues[breakpointName] + ")").matches) { | ||
return {name: breakpointName, index: i} | ||
} | ||
} | ||
})() | ||
return null | ||
} |
Sorry, the diff of this file is not supported yet
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
2880
3
14