1.0.0-beta.0 • Published 6 years ago
@framini/react-lazy-embed v1.0.0-beta.0
React Lazy Embed
React component for lazy loading heavy embeds like the one from YouTube. For now we only support YouTube videos but we might add support for Vimeo in the short term
Install
With Yarn
yarn install @framini/react-lazy-embedWith NPM
npm install @framini/react-lazy-embedHow it works
The embed can be in 4 possible status, 'idle' | 'visible' | 'load' | 'loaded'.
idle: By default it will always starts asidle(in the future we might support aneagermode).visible: Once the embed is within the threshold (by default 200px) it will change it's status tovisible. Here is where you can show the video thumbnail and a "play" button. Once the "play" button is pressedstatuswill change toload.load: While thestatus = loadyou can safely show the embed (and a loading indicator if you feel like).loaded: When the iframe has been fully loaded.
Example
You can play around with it by running StoryBook.
yarn storybook1.0.0-beta.1
6 years ago
1.0.0-beta.0
6 years ago