Git Product home page Git Product logo

sky's Introduction

Sky

React component for interactive backgrounds

Demo

https://codepen.io/lucagez/full/oQoRyK/

Installation

$ npm install --save react-sky

Usage

import React, { Component } from 'react';
import Sky from 'react-sky';

// you can pass imported images to Sky
import myImage from "./media/myImage.png"

class App extends Component {
  render() {
    return (
      <div>
        /* Sky adapts size to its container */
        <Sky
          images={{
            /* FORMAT AS FOLLOWS */
            0: "https://linkToYourImage0",  /* You can pass as many images as you want */
            1: "https://linkToYourImage1",
            2: myImage /* you can pass images in any form: link, imported via webpack... */
            /* 3: your other image... */
            /* 4: your other image... */
            /* 5: your other image... */
            /* ... */
          }}
          how={130} /* Pass the number of images Sky will render chosing randomly */
          time={40} /* time of animation */
          size={'100px'} /* size of the rendered images */
          background={'palettedvioletred'} /* color of background */
        />
      </div>
    );
  }
}

export default App;

Props

images

Type: Object. Required

NOTE: Only one object is allowed to be passed.

how

Type: Number. Required

Number of images you want to display

time

Type: Number. Default: 20

Number of seconds of every single animation

size

Type: String. Default: 150px

Dimension of the images

background

Type: String. Default: none

Color of the background

License

MIT

sky's People

Contributors

lucagez avatar muhnad avatar fzzr avatar

Stargazers

Zhazha_JiaYiZhen avatar yushuisheng avatar  avatar Ehtesham Ali avatar ToNy RANDRIAMANANTSOA avatar Dan Gherasimciuc avatar Joc rgb avatar Sujay avatar kycklingbror avatar Alejandro Jurado  avatar Noah Hendlish avatar Khan avatar Adriana Toledo Santiago avatar Havenstd06 avatar Rahul Banerjee avatar Leo Wong avatar gshah2020 avatar Pratima Singh avatar  avatar Ashraful Rahman Sakil avatar  avatar 水也 avatar  avatar Nuwan Alawatta avatar Shi Han avatar Utkarsh singh avatar  avatar  avatar  avatar Priyank Rupareliya avatar Marcos Garcia avatar Cirill avatar Shashwat Mishra avatar Saeid Nasiri avatar lindelof avatar Andre Korol avatar Daniel avatar Gautam V. avatar Antonio Barros da Silva Netto avatar Keshavaa Shaiskandan avatar Clara Chick avatar Colton Colcleasure avatar Ezra Lalonde avatar Noman Ahmed Khan avatar shawmon avatar Adam avatar Mukti avatar Mahmoud Abdelwahab avatar Arun  avatar Stefan Taranu avatar  avatar Johnny Squardo avatar hirokishingu avatar Kyrie Leee avatar Nicolas Azari avatar Ertaç Paprat avatar wangxingwen avatar Keegan Helmbrecht avatar Sabin Tudor avatar  avatar Mukai Li avatar kyralo avatar Rossi Meacham avatar Gerardo Keys avatar 한만섭 avatar Penn avatar Guangyao Li avatar  avatar Will avatar Andrés Barreto avatar LucasHDSF avatar  avatar Tantatorn Suksangwarn avatar tiantianYa avatar Kirill Pavlyashik avatar Davo Galavotti avatar Annemarie Cates avatar Pramod Vidyarthi avatar zeromake avatar Pwned avatar Abdo avatar Geoffrey Murray avatar Samir Fors avatar Jim avatar  avatar Дмитрий Егоров avatar Yu Watanabe avatar  avatar 蒲大飛 avatar Melissa Masia avatar carrie avatar  avatar Yully Che avatar  avatar  avatar Chris Lusted avatar Serkan Güzel avatar zojian avatar  avatar · 苳 avatar

Watchers

James Cloos avatar leesren avatar Nick White avatar  avatar ricardozv avatar  avatar Saeid Nasiri avatar

sky's Issues

How to add Sky to div and get size to adapt to the divs?

Hello,

I really liked your react-sky, and wish to add it as an opening animation that may be seen.

However, the animation covers the entire screen (I only want it to be within the div enclosing it), and I cannot figure out how to constrain the objects to the limits of its container.

Also, the container (div) doesn't change size once I add the Sky component.

I have added the code I use below for reference.

``

const jumb1Styles = {
  padding: '30px',
  marginBottom: '30px',
  fontSize: '21px',
  fontWeight: '200',
  lineHeight: '2.1428571435',
  height: '50px',
  width: '50px'

}


<div> 
    
  <div style = {jumb1Styles}>
      <Sky
            images={{
              0: "../img/clip1.png",
              1: "../img/planet1.png"

            }}
            how={5} /* Pass the number of images Sky will render chosing randomly */
            time={40} /* time of animation */
            size={'100px'} /* size of the rendered images */
            background = {'gray'}
          />
      <h1> Hack to save lives. </h1>

  </div>


</div>

``

More details: I am using latest version of React.js
The code above was part of a class component (separate class component from App.js) (part of render method)

setTimeout calls not cleared on Item component unmount

Thanks for making this package - we are using it in a project and chrome dev tools is giving us memory leak warnings due to setTimeout calls that aren't being cleared when the component is unmounted.

I think the issue is in item.js, setTimeout calls are made on lines 16 and 42 such that there will always be some sort of timeout running, but this then isn't cleared via clearTimeout when the component is unmounted.

A fairly small thing I know, but an easy fix too :)

I am happy to fork and raise a PR for this if that would be useful?

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.