johann-s / bs-breakpoints Goto Github PK
View Code? Open in Web Editor NEWA plugin which detect Bootstrap 4 breakpoints and emit when there is a change
License: MIT License
A plugin which detect Bootstrap 4 breakpoints and emit when there is a change
License: MIT License
Is code getting actual breakpoints also from defined BS4 CSS custom properties? It seems they are only hardcoded inside script? Or I'm wrong?
Of course, values of breakpoints may vary from project to project. So the definition in the script would then have to be changed.
As you know, there are available CSS custom properties from which the current breakpoints values can be read:
:root {
...
--breakpoint-xs: 0;
--breakpoint-sm: 576px;
--breakpoint-md: 768px;
--breakpoint-lg: 992px;
--breakpoint-xl: 1200px;
...
}
What do you think?
Discussion o about this twbs/bootstrap#25124 (comment)
Hello @Johann-S !
I tried to install your library to my BS4 project without success. I use laravel mix
(webpack based) compilation.
All my js files:
becomes one another big app-landing.js
file
that I include before </body>
:
...
</main>
<!-- Bootstrap core JavaScript
================================================== -->
<script src="{{ mix('landing/js/app-landing.js') }}"></script>
</body>
</html>
app-landing.js
(1st image) content:
require('./bootstrap');
require('./custom');
In bootstrap.js
file I put your library line. Full file content:
try {
window.$ = window.jQuery = require('jquery');
require('bootstrap');
//!!!here
require('bs-breakpoints');
require('jquery.easing');
//lg
require('lightgallery');
require('lg-zoom');
//fontawesome
require('./fontawesome');
} catch (e) {}
And in custom.js
I put two lines:
...
//all loaded
$(document).ready(function() {
console.log('loaded');
bsBreakpoints.init();
console.log(bsBreakpoints);
...
What I'm doing wrong?
p.s. https://github.com/sachinchoolur/lightGallery library works fine in same situation.
How to use this with conditional?
Ex. if( bsBreakpoints() == "xs" ) { // do something } else { // do something }
Thanks
Bootstrap 5 adds the bs-
prefix by default, turning properties like --breakpoint-sm
into --bs-breakpoint-sm
.
To not lose BS4 support I recommend checking if the --breakpoint-sm
formatted property names return NaN, and then attempting to get the prefixed ones.
See my PR #36
Hi I ran the following jQuery code under Safari on an iPhone 4 with iOS 7.1.2:
$(window).on('init.bs.breakpoint', function (e) {
alert('init ' + e.breakpoint);
})
e.breakpoint ended up being null.
Do you know is bs-breakpoints works under iOS 7 or do you know what the issue may be?
Hey thanks for the plugin - this looks great but I'm struggling to use it properly with jQuery
I can see the breakpoint if I query it like so:
console.log($.Event(bsBreakpoints.getCurrentBreakpoint()).type);
but reading your documentation I believe I should be able to access the breakpoint type on change by default? Could you please provide an example of the following:
"when breakpoint type changes fire XXX"
I could put it within a wrapper like: $(window).on('load resize scroll', function () { }
But I believe this has already been taken care of so not the correct way to handle it?
Bs-breakpoint is returning undefined in IE 11 although it is returning correct value in chrome
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.