bootstrap-detect-breakpoint
Advanced tools
Comparing version 1.0.6 to 1.0.8
{ | ||
"name": "bootstrap-detect-breakpoint", | ||
"version": "1.0.6", | ||
"version": "1.0.8", | ||
"description": "Detect the current Bootstrap 4 breakpoint in JavaScript", | ||
@@ -24,8 +24,3 @@ "main": "index.js", | ||
}, | ||
"homepage": "https://github.com/shaack/bootstrap-detect-breakpoint#readme", | ||
"devDependencies": { | ||
"bootstrap": "^4.4.1", | ||
"jquery": "^3.5.1", | ||
"popper.js": "^1.16.1" | ||
} | ||
"homepage": "https://github.com/shaack/bootstrap-detect-breakpoint#readme" | ||
} |
@@ -5,2 +5,5 @@ # bootstrap-detect-breakpoint | ||
- [Demo Page](https://shaack.com/projekte/bootstrap-detect-breakpoint/) | ||
- [npm Package](https://www.npmjs.com/package/bootstrap-detect-breakpoint) | ||
## Usage | ||
@@ -7,0 +10,0 @@ |
const bootstrapDetectBreakpoint = function () { | ||
const breakpointNames = ["xl", "lg", "md", "sm", "xs"] | ||
let breakpointValues = [] | ||
for (const breakpointName of breakpointNames) { | ||
breakpointValues[breakpointName] = window.getComputedStyle(document.documentElement).getPropertyValue('--breakpoint-' + breakpointName) | ||
// cache some values on first call | ||
if (!this.breakpointValues) { | ||
this.breakpointNames = ["xl", "lg", "md", "sm", "xs"] | ||
this.breakpointValues = [] | ||
for (const breakpointName of this.breakpointNames) { | ||
this.breakpointValues[breakpointName] = window.getComputedStyle(document.documentElement).getPropertyValue('--breakpoint-' + breakpointName) | ||
} | ||
} | ||
let i = breakpointNames.length | ||
for (const breakpointName of breakpointNames) { | ||
let i = this.breakpointNames.length | ||
for (const breakpointName of this.breakpointNames) { | ||
i-- | ||
if (window.matchMedia("(min-width: " + breakpointValues[breakpointName] + ")").matches) { | ||
if (window.matchMedia("(min-width: " + this.breakpointValues[breakpointName] + ")").matches) { | ||
return {name: breakpointName, index: i} | ||
@@ -12,0 +15,0 @@ } |
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
3665
0
17
32