GithubHelp home page GithubHelp logo

digitalkaoz / react-parallax Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rrutsche/react-parallax

0.0 3.0 0.0 26.84 MB

A React Component for parallax effect

License: MIT License

HTML 3.21% JavaScript 96.79%

react-parallax's Introduction

react-parallax NPM version

Install

npm install react-parallax --save

Default Usage

import { Parallax } from 'react-parallax';

const TheContainer = React.createClass({
  render: function () {
    return (
      <div>
	    <Parallax bgImage="assets/1.jpg" strength={400}>
		  <br/>
		  <h1> some content that is displayed above the bgImage </h1>
		</Parallax>
      </div>
    )
  }
});

Background Component

For more flexibility and styling purposes you can add a <Background></Background> section to your Parallax Container. Child nodes inside this Background will be positioned like the bgImage behind the other children. Compared to the bgImage there is no automatic scaling.

import { Parallax, Background } from 'react-parallax';

const TheContainer = React.createClass({
  render: function () {
    return (
      <div>
        <Parallax strength={300}>
		  <Background>
		    <img src="http://www.fillmurray.com/400/300"/>
			<div style={{
			   width: 800, 
			   height: 300, 
			   backgroundColor: '#450093'
			  }}></div>
			<img src="http://www.fillmurray.com/500/300"/>
		  </Background>
		  <h1>something else</h1>
		</Parallax>
      </div>
    )
  }
});

Props

  • bgImage: path to the background image that makes parallax effect visible - (type: String)
  • bgStyle: additional style object for the bg image/children - (type: Object) Valid style attributes
  • bgWidth: set bgImage width manually - (type: String), eg. '400px', 'auto'
  • bgHeight: set bgImage height manually - (type: String), eg. '400px', 'auto'
  • strength: parallax effect strength (in pixel), default 100. this will define the amount of pixels the background image is translated - (type: Number)
  • blur:
    1. pixel value for background image blur, default: 0 - (type: Number)
    2. or object in format {min:0, max:5} for dynamic blur depending on scroll position
  • disabled: turns off parallax effect if set to true, default: false - (type: Boolean)
  • className: set an additional className - (type: String)

Children

The children are used to display any content inside the react-parallax component

Development

Initial set up, run:

npm install

For watch on files, live reload, JSX transpiling and browserify, run:

npm run dev

Port on Windows is 80, 8080 on all other OS by default. Can be set with option -port=8080

License

MIT

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.