GithubHelp home page GithubHelp logo

isabella232 / fruitmachine-media Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ftlabs/fruitmachine-media

0.0 0.0 0.0 51 KB

FruitMachine helper that allows different setup and teardown callbacks to be called based on media queries

License: MIT License

JavaScript 100.00%

fruitmachine-media's Introduction

fruitmachine-media Build Status

FruitMachine helper that allows different setup and teardown callbacks to be called based on media queries. If asychronous logic is needed to be run within a teardown or setup callback, return a promise.

Example usage

var fm = require('fruitmachine');

fm.define({
  name: 'passionfruit',

  template: function() {
    // Normal fruitmachine template method
  },

  helpers: [
    require('fruitmachine-media')
  ],

  media: {
    '(max-width: 699px), (max-height: 699px)': 'small',
    '(min-width: 700px) and (min-height: 700px)': 'large'
  },

  states: {
    small: {
      setup: function(options) {
        // Run small setup logic
      },
      teardown: function(options) {
        // Run small teardown logic
      }
    },
    large: {
      setup: function(options) {
        // Run large setup logic

        // If asychronous logic needs to be run:-
        //
        // var promise = new Promise();
        // doAsyncStuff(function() {
        //   promise.resolve();
        // });
        // return promise;
      },
      teardown: function(options) {
        // Run large teardown logic
      }
    }
  }
});

License

Copyright (c) 2014 The Financial Times Limited Licensed under the MIT license.

Credits and collaboration

All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions. Please feel free to raise an issue or pull request.

fruitmachine-media's People

Contributors

adarosecannon avatar dominictobias avatar georgecrawford avatar kornelski avatar maft avatar matthew-andrews avatar rowanbeentje avatar wheresrhys 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.