Skip to content

Commit 5006b7f

Browse files
committed
Updating the docs
1 parent 73d06cb commit 5006b7f

File tree

1 file changed

+84
-50
lines changed

1 file changed

+84
-50
lines changed

README.md

Lines changed: 84 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,69 @@ Responsive Bootstrap Toolkit provides an easy way of breakpoint detection in Jav
55

66
The SASS module enables quick and simple styling for elements needing different property values for each screen resolution.
77

8-
Current version: 2.3.0
8+
Current version: **2.3.0**
99

10-
[See a live example on CodePen](http://codepen.io/dih/full/ivECj)
10+
### Table of Contents
11+
* [Live example](#live-example)
12+
* [Migrating from an older version](#migrating-from-an-older-version)
13+
* JavaScript features
14+
* [Basic usage](#basic-usage)
15+
* [Execute code on window resize](#execute-code-on-window-resize)
16+
* [Get alias of current breakpoint](#get-alias-of-current-breakpoint)
17+
* [Taking precautions](#taking-precautions)
18+
* [How do I include it in my project?](#how-do-i-include-it-in-my-project)
19+
* [Dependencies](#dependencies)
20+
* SASS features
21+
* [Basic usage](#sass-features)
22+
* [How do I include it in my project?](#sass-instructions)
23+
* [Dependencies](#sass-dependencies)
1124

12-
### JavaScript
13-
#### Determine which breakpoint is active
25+
### Live example
1426

15-
````javascript
16-
if (viewport.is('xs')) {
17-
// do stuff in the lowest resolutions only!
18-
}
27+
Available on [CodePen](http://codepen.io/dih/full/ivECj)
1928

20-
if (viewport.is('lg')) {
21-
// do stuff on huge screens only
22-
}
23-
````
29+
### Migrating from an older version
2430

25-
#### Execute a script whenever window is resized
26-
##### Default interval, 300 ms
31+
Refer to the [changelog](https://github.com/maciej-gurban/responsive-bootstrap-toolkit/blob/master/CHANGELOG.md) for a list of improvements in each version of the library.
2732

28-
````javascript
29-
$(window).bind('resize', function() {
30-
viewport.changed(function() {
31-
32-
// do some other stuff!
33+
### JavaScript features
34+
#### Basic usage:
3335

34-
})
35-
});
36+
````javascript
37+
// Wrap IIFE around your code
38+
(function($, viewport){
39+
40+
// Do stuff in the lowest resolutions only
41+
if( viewport.is('xs') ) {
42+
// ...
43+
}
44+
45+
// Execute code each time window size changes
46+
$(window).bind('resize', function() {
47+
viewport.changed(function(){
48+
if( viewport.is('xs') ) {
49+
// ...
50+
}
51+
});
52+
});
53+
54+
})(jQuery, ResponsiveBootstrapToolkit);
3655
````
3756

38-
##### Custom interval
57+
#### Execute code on window resize
58+
Allows using custom debounce interval. The default one is set at 300ms.
3959

4060
````javascript
4161
$(window).bind('resize', function() {
4262
viewport.changed(function() {
4363

44-
// do some other stuff!
64+
// ...
4565

4666
}, 600)
4767
});
4868
````
4969

50-
#### Return the name of current breakpoint
51-
70+
#### Get alias of current breakpoint
5271
````javascript
5372
$(window).bind('resize', function() {
5473
viewport.changed(function() {
@@ -59,7 +78,42 @@ $(window).bind('resize', function() {
5978
});
6079
````
6180

62-
### SASS
81+
#### Taking precautions
82+
83+
In certain circumstances, it might be necessary to wait for certain events to happen before executing your scripts.
84+
````javascript
85+
// Execute code only when document has been loaded fully
86+
$(document).ready(function() {
87+
if( viewport.is('xs') ) {
88+
// ...
89+
}
90+
});
91+
// Execute code only when all resouces have loaded
92+
$(window).load(function() {
93+
if( viewport.is('xs') ) {
94+
// ...
95+
}
96+
});
97+
````
98+
99+
#### How do I include it in my project?
100+
101+
Paste just before `</body>`
102+
103+
````html
104+
<!-- Responsive Bootstrap Toolkit -->
105+
<script src="js/bootstrap-toolkit.min.js"></script>
106+
<!-- Your scripts using Responsive Bootstrap Toolkit -->
107+
<script src="js/main.js"></script>
108+
````
109+
110+
#### Dependencies:
111+
* jQuery
112+
* Bootstrap's responsive utility css classes (included in its standard stylesheet package)
113+
114+
115+
116+
### SASS features
63117
#### Set different CSS property value per breakpoint
64118

65119
````css
@@ -92,30 +146,10 @@ Output:
92146
````
93147

94148

95-
### How do I include it in my project?
96-
#### JavaScript
97-
98-
Include just before `</body>`
99-
100-
````html
101-
<!-- Responsive Bootstrap Toolkit -->
102-
<script src="js/bootstrap-toolkit.min.js"></script>
103-
104-
<!-- Your scripts using Responsive Bootstrap Toolkit -->
105-
<script src="js/main.js"></script>
106-
````
107-
108-
#### SASS
109-
149+
#### SASS Instructions
110150
Copy contents of `compass/bootstrap-toolkit` directory into your project. File `style.scss` contains lines that need to be in your own style.scss for the mixin to work. You'll need SASS 3.3+.
111151

112152

113-
### Dependencies
114-
115-
**JavaScript features:**
116-
1. Bootstrap's responsive utility css classes included in its standard stylesheet package
117-
2. jQuery library
118-
119-
**CSS features:**
120-
1. SASS 3.3+
121-
2. Compass
153+
#### SASS Dependencies
154+
* SASS 3.3+
155+
* Compass

0 commit comments

Comments
 (0)