Skip to content

Commit 3767e16

Browse files
author
AMJones
committed
Adds breakpoint into dom via a psuedo element for easy detection.
1 parent fdc74c6 commit 3767e16

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

js/breakpoint.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
/**
2-
* Determines which breakpoint is currently active.
2+
* Determines which breakpoint is currently active, either by querying for a psuedo element on the body
3+
* or by injecting an element with display classes.
34
*
45
* @returns {jQuery}
56
*/
67
jQuery.fn.extend( {
78
isBreakpoint: function ( points ) {
9+
var query = window.getComputedStyle(document.querySelector('body'), ':before').getPropertyValue('content') || null;
10+
if ( !points.constructor === Array ) { points = [ points ]; }
11+
if (null !== query) { return (points.indexOf(query) !== -1); }
812
var test = false;
913
var $body = $( 'body' );
1014
var cls = ' d-none d-sm-none d-md-none d-lg-none d-xl-none';
11-
if ( !points.constructor === Array ) { points = [ points ]; }
1215
$.each( points, function ( index, alias ) {
1316
if ( !$body.find( '.detect-' + alias ).length ) {
1417
var tCls = 'detect-' + alias + cls;

scss/_display-mixins.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@
77
.d-#{$criteria}-table-cell { display: table-cell !important; }
88
.d-#{$criteria}-flex { display: flex !important; }
99
.d-#{$criteria}-inline-flex { display: inline-flex !important; }
10+
}
11+
12+
@mixin display-responsive($breakpoint) {
13+
body::before { content: "#{$breakpoint}"; display: none !important; }
14+
@include display($breakpoint);
1015
}

scss/_display.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@if not($enable-framework) {
55
/*!
6-
* Strapless Display v1.0.2 (http://github.com/strapless/display)
6+
* Strapless Display v1.0.3 (http://github.com/strapless/display)
77
* Influenced by Bootstrap v4.0 (http://getbootstrap.com)
88
* Licensed under MIT (https://github.com/strapless/display/blob/master/LICENSE)
99
*/
@@ -64,10 +64,10 @@
6464
@if $enable-framework == false {
6565
@each $bp, $min in $grid-breakpoints {
6666
@if $min == 0 {
67-
@include display($bp)
67+
@include display-responsive($bp);
6868
} @else {
6969
@media screen and (min-width: $min) {
70-
@include display($bp);
70+
@include display-responsive($bp);
7171
}
7272
}
7373
}

0 commit comments

Comments
 (0)