ResponsiveJS
ResponsiveJS

Back to Wiki

Functions


r$ allows you to express some complex presentation task or action with javascript based functions. This functions are executed, based on some conditions, at r$ start event or every time resize event callback is called or on orientationchanged events for tablet/mobile devices. Three kind of options are given :

Function Description
register r$.register(name,func) - register a function(w) called name that will be executed onStart and at every resize event callback.
unregister r$.unregister(name) this function allow you to remove a function defined using register function.
onCondition r$.onCondition(condition) specify the first part of a fluent chain calls in witch you specify the function(w) condition what will be checked before executing a particular function. To conclude the chain you had to specify this function with do methods.
example : r$.onCondition(condition)do(action) where condition and action are function(w){}
whenInRange r$.whenInRange(min,max) specify the first part of a fluent chain calls in witch you specify the range of execution of a particular function. To conclude the chain you had to specify this function with do methods.
example : r$.whenInRange(min,max)do(action) where action is function(w){}


Example


r$.whenInRange(200, 700).do(function(w) {
    $('#box').css('background-color', 'red');
});

r$.onCondition(function(w) {
    return (w 700 && w < 1200);
}).do(function (w) {
    $('#box').css('background-color', 'blue');
});

r$.register('greatThan1200',function(w){
    if (w>1200)
       $('#box').css('background-color', 'purple');
});

r$.start();