miércoles, 6 de noviembre de 2013

How to integrate a third party library with airbnb rendr library




Hi all, today we are gonna integrate a third party library (we are going to use swipe as an example) with airbnb's rendr.
  1. Download the last version of swipe.js from https://github.com/bradbirdsall/Swipe
  2. Locate the library inside /app/lib
  3. Inside the swipe.js file you have to replace the declaration line (line 8) adding "module.exports":
   Original file:
1:  /*  
2:   * Swipe 2.0  
3:   *  
4:   * Brad Birdsall  
5:   * Copyright 2013, MIT License  
6:   *  
7:  */  
8:  function Swipe(container, options) {  
9:   "use strict";  

With our small modification:
1:  /*  
2:   * Swipe 2.0  
3:   *  
4:   * Brad Birdsall  
5:   * Copyright 2013, MIT License  
6:   *  
7:  */  
8:  module.exports = function Swipe(container, options) {  
9:   "use strict";  

4. In the view file that you want to use swipe, you have to import it using the require function:

1:  ...  
2:     if (typeof window != 'undefined') {  
3:      var Swipe = require('../../lib/swipe');   
4:     };  
5:  ...  

5. Drop the swipe.css file inside assets/stylesheets/vendor folder. In addition modify assets/stylesheets/index.styl in order to import swipe.css stylesheet.

6. Listo ;)


@sdemians
thanks to: @spikebrehm and @ignavaldi

No hay comentarios:

Publicar un comentario