Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
Conflicts:
	js/jquery.breakpoint-min.js
  • Loading branch information
Martin Jansson committed Apr 28, 2015
2 parents 5625d6b + 4eeae88 commit bf0eb96
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ Whenever the condition returns true, be it on page load or when the viewport cha
});
```

## Debugging

The plugin provides some basic debugging which you can activate by setting `$.breakpoint.debug = true`. This will cause the plugin to log information to the browser console whenever a breakpoint is entered or exited. Add a `toString` method to your breakpoint object to distinguish between breakpoints; otherwise you'll see `[object Object]` as the name of the breakpoint.


## Tips and tricks

### MatchMedia support in older browsers
Expand Down
18 changes: 18 additions & 0 deletions js/jquery.breakpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

function checkActiveBreakpoint(breakpoint) {
if (!breakpoint.condition()) {
debug('Exiting breakpoint: ' + breakpoint);

// We have left this breakpoint.
if (typeof breakpoint.exit === 'function') {
Expand All @@ -75,6 +76,8 @@

// We have entered this breakpoint.
if (typeof breakpoint.first_enter === 'function') {
debug('Entering breakpoint for the first time: ' + breakpoint);

try {
breakpoint.first_enter.apply(breakpoint);
} catch (e) {}
Expand All @@ -84,6 +87,7 @@
}

if (typeof breakpoint.enter === 'function') {
debug('Entering breakpoint: ' + breakpoint);
try {
breakpoint.enter.apply(breakpoint);
} catch (e) {}
Expand Down Expand Up @@ -125,4 +129,18 @@
});
}

/**
* Breakpoint debugging
*/

// (De)activate breakpoint debugging.
$.breakpoint.debug = false;

// Console logging wrapper.
function debug () {
if ($.breakpoint.debug && console && console.info) {
console.info.apply(console, arguments);
}
}

}(jQuery));

0 comments on commit bf0eb96

Please sign in to comment.