Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bootstrap-detect-breakpoint

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bootstrap-detect-breakpoint - npm Package Compare versions

Comparing version 1.0.8 to 1.1.0

favicon.ico

4

package.json
{
"name": "bootstrap-detect-breakpoint",
"version": "1.0.8",
"description": "Detect the current Bootstrap 4 breakpoint in JavaScript",
"version": "1.1.0",
"description": "Detect the current Bootstrap breakpoint in JavaScript",
"main": "index.js",

@@ -6,0 +6,0 @@ "scripts": {

# bootstrap-detect-breakpoint
Detect the current Bootstrap 4 breakpoint in JavaScript.
Detect the current Bootstrap breakpoint in JavaScript.

@@ -32,1 +32,14 @@ - [Demo Page](https://shaack.com/projekte/bootstrap-detect-breakpoint/)

The index goes from 0 to 4, where 0 is "xs" and 4 is for "xl".
## 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.
You can make this script work with just adding this to your scss
```scss
@each $name, $value in $grid-breakpoints {
--#{$prefix}breakpoint-#{$name}: #{$value};
}
```
const bootstrapDetectBreakpoint = function () {
// cache some values on first call
if (!this.breakpointValues) {
this.breakpointNames = ["xl", "lg", "md", "sm", "xs"]
this.breakpointNames = ["xxl", "xl", "lg", "md", "sm", "xs"]
this.breakpointValues = []
const isPriorBS5 = !!window.getComputedStyle(document.documentElement).getPropertyValue('--breakpoint-sm')
const selector = isPriorBS5 ? "--breakpoint-" : "--bs-breakpoint-"
for (const breakpointName of this.breakpointNames) {
this.breakpointValues[breakpointName] = window.getComputedStyle(document.documentElement).getPropertyValue('--breakpoint-' + breakpointName)
const value = window.getComputedStyle(document.documentElement).getPropertyValue(selector + breakpointName)
if(value) {
this.breakpointValues[breakpointName] = value
}
}

@@ -18,2 +23,2 @@ }

return null
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc