bootstrap-detect-breakpoint
Advanced tools
Comparing version 1.1.1 to 1.1.3
{ | ||
"name": "bootstrap-detect-breakpoint", | ||
"version": "1.1.1", | ||
"version": "1.1.3", | ||
"description": "Detect the current Bootstrap breakpoint in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -31,9 +31,9 @@ # bootstrap-detect-breakpoint | ||
The index goes from 0 to 4, where 0 is "xs" and 4 is for "xl". | ||
The index goes from 0 to 5, where 0 is "xs" and 5 is for "xxl". | ||
## Get it working with Bootstrap 5 | ||
In Bootstrap 5 there is an [issue that the css variables for breakpoints are missing](https://github.com/twbs/bootstrap/issues/36094). I already created a [pull request](https://github.com/twbs/bootstrap/pull/36095), but I don't know when it will be merged. | ||
In Bootstrap 5 there is an [issue that the css variables for breakpoints are missing](https://github.com/twbs/bootstrap/issues/36094). I already created a [pull request](https://github.com/twbs/bootstrap/pull/36095), but I don't know when or if it will be merged. | ||
You can make this script work with just adding this to your scss | ||
Until then you can make the bootstrap-detect-breakpoint script work with Bootstrap 5 by just adding this to your scss | ||
```scss | ||
@@ -40,0 +40,0 @@ :root { |
@@ -0,1 +1,6 @@ | ||
/** | ||
* Author and copyright: Stefan Haack (https://shaack.com) | ||
* Repository: https://github.com/shaack/bootstrap-detect-breakpoint | ||
* License: MIT, see file 'LICENSE' | ||
*/ | ||
const bootstrapDetectBreakpoint = function () { | ||
@@ -7,5 +12,5 @@ // cache some values on first call | ||
const isPriorBS5 = !!window.getComputedStyle(document.documentElement).getPropertyValue('--breakpoint-sm') | ||
const selector = isPriorBS5 ? "--breakpoint-" : "--bs-breakpoint-" | ||
const prefix = isPriorBS5 ? "--breakpoint-" : "--bs-breakpoint-" | ||
for (const breakpointName of this.breakpointNames) { | ||
const value = window.getComputedStyle(document.documentElement).getPropertyValue(selector + breakpointName) | ||
const value = window.getComputedStyle(document.documentElement).getPropertyValue(prefix + breakpointName) | ||
if(value) { | ||
@@ -12,0 +17,0 @@ this.breakpointValues[breakpointName] = value |
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
21156
7
28