Code Monkey home page Code Monkey logo

respondr's Introduction

Respondr

setup and teardown functions for responsive web development

depends on underscore.js

Usage

Quick Example

var respondr = Respondr.create();

respondr.set.ranges({
	small:  [0, 200],
	medium: [200, 300],
	large:  [300, Infinity]
});

respondr.on.enter('large').run(function () {
	// do something
});
respondr.on.exit('medium').run(function () {
	// do something
});
respondr.on.enter('small').run(function () {
	// do something
});
Initializing a respondr

For most applications, there is only a need to have one respondr instance, but you can create more if you'd like. They will operate independent of one another, and can have their own range definitions.

var respondr = Responder.create();
var auxillaryRespondr = Respondr.create();
Defining Ranges

To set ranges, pass an object map to respondr.set.ranges in the format:

respondr.set.ranges({
	firstRange: [min, max],
	secondRange: [min, max]
});

Notes on ranges:

  • Passed as an Array of Numbers (of length 1 or 2)
  • Must be non-negative integers or Infinity
  • If only one Number is provided, the second is assumed to be Infinity
  • Second Number must be greater than first Number
  • The key value of the range will later be used as the range identifier when binding events
Binding Events

To bind events, use the following syntax:

respondr.on.enter('rangeName').run(function () {
	// do some setup work for this range
});

respondr.on.exit('rangeName').run(function () {
	// do some teardown work for this range
});

respondr's People

Contributors

nmartin413 avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.