thom4parisot / Imager.jsx

A React component for responsive images in desktop and mobile browsers. Featuring Imager.js.
https://npmjs.com/imager.jsx
MIT License
32 stars 7 forks source link

window.onresize to trigger individual images update #2

Closed thom4parisot closed 9 years ago

thom4parisot commented 9 years ago

What would be the best way for individual images to subscribe to resize events without keeping reference to these elements?

Probably by subscribing to the onImagesReplaced on Imager.ready.

var Imager = require('imager.jsx');
var ResponsiveImage = Imager({ onResize: true });

React.createClass({
  render: function(){
    return (
      <main>
        <header><ResponsiveImage src="..." alt="Site banner" /></header>

        <ResponsiveImage src="..." />
      </main>
    );
  }
});