/ Published in: JavaScript
ResponsiveBootstrapToolkit : https://github.com/maciej-gurban/responsive-bootstrap-toolkit
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* Manage viewport behavior */ +function ($, viewport) { 'use strict'; window.BpUtils= { // add a callback to call on every breakpoint switch // callback is call this viewport as argument // more about viewport : https://github.com/maciej-gurban/responsive-bootstrap-toolkit newBreakpointRulesList: [], addCallBack: function(rule) { this.newBreakpointRulesList.push(rule); }, applyNewBreakpointRules: function (viewport) { if(this.newBreakpointRulesList.length == 0) { return; } $.each(this.newBreakpointRulesList, function(i, rule){ rule(viewport); }); }, // Listen viewport changes currentbp: '', onUpdateViewport: function() { var bp = viewport.current() ; if (bp.length != 2) { // if breakpoint not detected yet setTimeout(window.BpUtils.onUpdateViewport, 20); return; } // if (bp != this.currentbp) { this.currentbp = bp; window.BpUtils.applyNewBreakpointRules(viewport); } } }; // on resize $(window).resize( viewport.changed(function() { window.BpUtils.onUpdateViewport(); }) ); window.BpUtils.onUpdateViewport(); }(jQuery, ResponsiveBootstrapToolkit);