Giter Club home page Giter Club logo

react-scroll-parallax's Introduction

React Scroll Parallax

NPM Version Latest NPM Downloads Codecov Rate on Openbase

Test and Lint Storybook Storybook

React hooks and components to create parallax scroll effects for banners, images or any other DOM elements. Utilizes Parallax Controller to add vertical or horizontal scrolling based effects to elements. Optimized to reduce jank on scroll and works with SSR and SSG rendered React apps.

If you're coming from V2, here's a migration guide.

Install

With npm

npm install react-scroll-parallax

or yarn

yarn add react-scroll-parallax

Example

Create effects with a hook:

function Component() {
  const parallax = useParallax({
    speed: -10,
  });
  return <div ref={parallax.ref} />;
}

or with a component:

function Component() {
  return (
    <Parallax speed={-10}>
      <div />
    </Parallax>
  );
}

Getting Started

Read the documentation for setup and usage instructions.

Demos

Docs: Hooks

Docs: Components

react-scroll-parallax's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-scroll-parallax's Issues

1.0.0 Release

1.0.0 Release

The following tasks should be completed for a 1.0.0 release. See the project board for the current state of tasks: React Scroll Parallax Project

  • Remove will-change property from elements. Should be added by users as needed, not by default.
  • Test desktop browser support for major browsers.
  • Document expected browser support.
  • Update GitHub pages examples

support webp as image banner

Hello,

If layers image consist of a WebP image format they are not been rendered with ParallaxBanner. I am not sure if this is actually a feature or bug at the moment. This is an example setup:

<ParallaxBanner layers={[image: 'image-url.webp']} /> // not applied as background
<ParallaxBanner layers={[image: 'image:'image-url.jpg']} /> // works

Best,
Dominic

Question: why warn when min is greater than zero and max is less than zero?

What the downside is of setting the offset min > 0 and offset max < 0?

With this setting I'm getting a warning

<Parallax
  offsetYMin={`25%`}
  offsetYMax={`-50%`}
  slowerScrollRate
>
  {numeral}
</Parallax>
Warning: Failed prop type: [offsetYMax] in Parallax is less than zero. [offsetYMax] must be greater than or equal to zero.

My intent was to have the content slide upwards while scrolling down the page. Is there an alternative way to create a reverse the parallax direction?

Usage clarifications

Hi @jscottsmith, thank you for putting this useful library! While using it, I was running into some issues and mostly centered around understanding the library works.

Context: My usecase is that I have an full viewport image on the homepage that I am trying to have another full viewport container scoll on top of. So my setup looks like this:

<ParallaxProvider>
  <PageWrapper>
    <Parallax>  {/* <----- */}
      <FullViewport> {/* <-----  Static Content */}
        <BackgroundImage />
      </FullViewport>
    </Parallax>
     <FullViewport> {/* <---- Content that should be over the Static Content */}
        <OverlayContent />
     </FullViewport>
     <FullViewport>
        <MoreThings />
     </FullViewport>
  </PageWrapper>
</ParallaxProvider>

Assuming the setup is correct, I had the following questions:

  1. Without adding any offset props, nothing really happens. But I wasn't clear about what those props do. Could you clarify the purpose and the application of each of the prop? In other words, what do they affect?

  2. On adding the offset props, the image jumps on load and I wasn't sure if that is to be expected?

  3. If I move my <Parallax /> to be the parent of <BackgroundImage /> rather than <FullViewport /> that breaks my image since it seems to break the height and width of the container. Is that to be expected?

  4. Is the setup correct? Or would you achieve the same effect in a different manner?

Thank you!

The positioning of a direct sibling to a parallax Element.

I have applied parallax to only one element on a website, and I have a problem with keeping the position of the sibling right under it normal.

See a screen recording: https://cloudup.com/c_pkJK-UDrM

The element changes height on resize, but the parallax container keeps the same dimensions, I tried applying update on resize as well, but that does nothing.

What's the expected way of dealing with this?

Getting error `window is not defined`

First things first, this is the most complete parallax library I have come across. Good job, many thanks.

Sometimes I am getting this error that has to do with undefined window, the message is as follows.

500 Internal Server Error. window is not defined ReferenceError: window is not defined at /Users/christos.paschalidis/Documents/new-vimcar/node_modules/react-parallax-component/dist/index.min.js:19:2129 at /Users/christos.paschalidis/Documents/new-vimcar/node_modules/react-parallax-component/dist/index.min.js:19:2061 at e.exports (/Users/christos.paschalidis/Documents/new-vimcar/node_modules/react-parallax-component/dist/index.min.js:19:2347) at Object.<anonymous> (/Users/christos.paschalidis/Documents/new-vimcar/node_modules/react-parallax-component/dist/index.min.js:19:2826) at t (/Users/christos.paschalidis/Documents/new-vimcar/node_modules/react-parallax-component/dist/index.min.js:1:426) at Object.<anonymous> (/Users/christos.paschalidis/Documents/new-vimcar/node_modules/react-parallax-component/dist/index.min.js:17:2115) at Object.<anonymous> (/Users/christos.paschalidis/Documents/new-vimcar/node_modules/react-parallax-component/dist/index.min.js:17:2180) at t (/Users/christos.paschalidis/Documents/new-vimcar/node_modules/react-parallax-component/dist/index.min.js:1:426) at Object.<anonymous> (/Users/christos.paschalidis/Documents/new-vimcar/node_modules/react-parallax-component/dist/index.min.js:17:651) at Object.t.__esModule (/Users/christos.paschalidis/Documents/new-vimcar/node_modules/react-parallax-component/dist/index.min.js:17:2032)

I am using nextjs as my framework not that I think this makes a big difference.

Thanks again.

Disable Scroll Effects on Mobile

Support

Trouble Disabling on Mobile

Hi! I've experienced some layout issues on a few of my devices and was hoping to disable the scrolling effects on mobile. I noticed you'd mentioned this as a best practice in the readme and was hoping you might be able to recommend a way to implement. Thanks!

IE11 issue on Update

this.updateElement = function (element, options) {
        // gets the index of the element to update based on id
        var index = elements.findIndex(function (el) {
            return el.id === element.id;
        });

Object doesn't support property or method 'findIndex'

When it runs the updateElement function in IE11 for me I am receiving the error above.
and that breaks the entire site for me.

Change appearance of scroll speed without affecting when element is not in viewport

@calsal8 ya I think you misunderstand how the library is designed to work, or I don't understand the problem. The offsets are used to give an element the varying appearance of scroll speed. Increase the offsets the more the dramatic the effect.

Not sure if the question is meant to relate to v2 since you're referencing the v1 API. If you're having trouble with implementation open a new ticket and I can help you out there, as I'd like this ticket to be used for discussing v2. Thanks!

@jscottsmith Sorry if I posted in the wrong place, I thought my question was related to a new feature that could be included in V2. But let's clarify the question here first. Maybe the library is not designed to work as I would hope. Either way I find it very useful.

When I change the offsets the appearance of scroll speed change, just as you wrote. I've used offsetYMin={-1000} to achieve the fast scroll speed that I want. But that also keeps affecting the style animation when the element is 1000% outside the viewport. In my case I want the fast scroll speed but, for performance reasons, I don't want it to change the style when it's far outside the viewport. I'm thinking that could be solved with a multiplier that multiplies the scroll speed with a given number. What are your thoughts?

Usage with Next.js

Hi, this issue is related to #9

I've got a Next.js app and currently use react-scroll-parallax on 2 separate pages (great library btw!). When you come to the page 1, the parallax works fine. But when you change route from here to the page 2, the parallaxes don't work (probably don't initialize).

The cause of the problem could be that in Next.js you cannot change or wrap the top-level component in your custom component (in this case ParallaxProvider). Basically the most "root" component (such as Layout) I can wrap is being unmounted on every route change.

Is there any workaround for this?

Parallax stop working if component re-render

Hello! Thanks for plugin, I very like it!
On initial mount is everything working fine.
A problem appear after returning to the component that just freezing parallax without any errors.
I have ParallaxController.init() on the root and window.ParallaxController.update() in componentDidMount.

I do not know what to do with this, can you help me please?

parallaxController.update

Hello,

Is there any examples for parallaxController.update, Since this is not working for me.

I just tried below.
in render
<ParallaxProvider ref={r => this.parallax = r}>
then
after scroll function i just call

this.parallax.parallaxController.update();

is this right?

Only work properly when I resize my browser manually

Hi, I really like this repo. It is amazing, especially in version 2. quite clean and easy to implement. However, the parallax always work properly when I resize my browser manually. Thus, I think it is because of the cache, but I update updating the cache when image load, it seems nothing happened. Even I set a timer say update the cache after 5 second. Would you please give me a hint to let me know if there is anything that might cause the issue? Thank you so much!

Parallax Not working on Initial Loading

Hello @jscottsmith , Thanks for this good library

Parallax is not working on initial loading when i resize window then parallax was working properly I don't know why this issue was coming..

Also i have add ParallaxProvider in my App.js

import React, { Component } from 'react'
import { Parallax } from 'react-scroll-parallax'

class TestComponent extends Component {
  render() {
    return (
      <Parallax className="custom-class" y={[-20, 20]} tagOuter="figure">
        <Image src="/image.jpg" />
      </Parallax>
    )
  }
}

export default TestComponent

Center Image?

Hi,
I'd like to maximize the height of my parallax container (which is on the very top of my page), but the containing image is always aligned top/left, and not centered vertically.
How can I do that?

Custom animation

Add custom animation props to get from/to animation style.
I need to add style my self, such as rotate or scale style and change their values on scrolling.
Example: I need to add rotate style to the element from 0deg to 180deg. It must work when page scroll.

problems when viewed on a monitor

Expected Behavior

Smooth parallax effect on a 32 in. computer monitor.

Actual Behavior

not so smooth parallax effect on a 32 in. computer monitor (little jank going on), you can somewhat see the element jumping slightly. I realized this when seeing the same behavior on the demo site after trying to figure out what was wrong with mine.

nothing on console log

Steps to Reproduce the Problem

  1. I opened the project im working on and saw it on a computer monitor

Environment

  • Version: 1.3.3 & 1.3.5
  • Platform: MacOS
  • Browser: Safari/Chrome

V2 Beta: Next Release

V2 Next

Publishing a new alpha to address some long standing issues and to make some API changes. Please give it a try and post any concerns, requests, or issues.

yarn add react-scroll-parallax@next

I've started updating the readme but have a ways to go. See here: README

Also the storybook for this version is published here:
http://react-scroll-parallax-next.surge.sh

Breaking changes

  • Replaces all the offset props and removes the slowerScrollRate prop in favor of x/y props that take arrays for start/end values
  • Updated the way progress is calculated
  • Support for the latest React version

New Features

  • Added support for horizontal scrolling
  • Support parallax scrolling effects in a div with scroll overflow

Breaking changes

Replaces all the offset props and removes the slowerScrollRate prop in favor of x/y props that take arrays for start/end values

This:

<Parallax offsetYMin={-100}  offsetYMax={100} slowerScrollRate={false}>

becomes this (values flipped):

<Parallax y={[100, -100]}>

And this:

<Parallax offsetYMin={-100}  offsetYMax={100} slowerScrollRate={true}>

becomes this (starts at -100%, ends at 100%):

<Parallax y={[-100, 100]}>

Why?

The way the min/max offsets worked was confusing and limiting:

Updated the way progress is calculated

Progress is now calculated from the original elements position in the viewport. So the top of the element at the bottom of the window is 0, the bottom of the element at the top of the window is 1. If you are upgrading from v1 some elements may appear to move further/faster than they did before so you might need to adjust the x/y offsets.

These changes address this issue:

#24

Which now allows for this:

http://react-scroll-parallax-next.surge.sh/?selectedKind=%3CParallax%3E%20Vertical&selectedStory=linear%20y%20offsets&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybooks%2Fstorybook-addon-knobs

Support for the latest React version

Removes usage of some deprecated lifestyle hooks and uses the latest context api. Requires [email protected] or greater.

New Features

Added support for horizontal scrolling

Horizontal scrolling is now working. Just tell the provider the axis:

<ParallaxProvider scrollAxis="horizontal" />

Example:

http://react-scroll-parallax-next.surge.sh/?selectedKind=%3CParallax%3E%20Horizontal&selectedStory=linear%20x%20offsets&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybooks%2Fstorybook-addon-knobs

Support parallax scrolling effects in a div with scroll overflow

Give the provider a reference to the DOM element which will be scrollable and contain parallax elements.

const domElement = document.getElementById('my-scrolling-div');

<ParallaxProvider scrollContainer={domElement} />;

Example:

http://react-scroll-parallax-next.surge.sh/?selectedKind=%3CParallax%3E%20in%20a%20%3Cdiv%3E&selectedStory=vertical%20with%20y%20offsets&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybooks%2Fstorybook-addon-knobs

React prallax scroll background video

I need do page with scroll parallax video background. I found this example:
link
But I can't found source for this example.

This is My code:

< ParallaxProvider >

	<Parallax
		style={{margin: "0 !important;"}}
		offsetYMax={200}
		offsetYMin={-200}
		slowerScrollRate
		tag="div">
		
			<video autoPlay loop id="video-background" muted plays-inline style={{width:"100%",height:"100%"}}>
			  <source src="./backgroung_massage.mp4" type="video/mp4" />
			</video>
	</Parallax>
		<div>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<Search  />
		</div>

< /ParallaxProvider >

Problem is, that 'Parallax' isn't background 'div'. How need look template for parallax video as background, ang other elements as normaly scroll?

Opacity prop

Really love this library. Great job!

Wondering if you've been considering implementing support for Opacity fade based on scroll as well? I think that'd make this library very complete.

Cheers

Speed control

Feature Request

Speed control of a parallax element would be useful, to have different speeds while scrolling. Right now all parallax elements animate with the same speed.

May use-case right now: think of art shapes (lines, triangles, ...) which are on different speed levels (eg. the triangle is on 0.3 and the rectangle on 0.1), this would make the rectangle the slowest and the triangle the fastest while scrolling.

Can only refer to an example made with react-spring (can't use react-spring in my case, since they do position: absolute on each element):
https://codesandbox.io/s/nwq4j1j6lm


Maybe this already exists but I haven't found any documentation to it, as when I implemented it, all elements had the same speed levels and would stop after say 20px of scroll.

Breaks on IE 11 because of array.find method

This package breaks on IE 11 because of the array.find method. I added a polyfill to my site to make it work, but I think you can either add that to the documentation or polyfill it in the package itself.

I think for example the problem lies in snippets like this.

const validUnits = ['px', '%'];
const isValidUnit = validUnits.find(unit => unit === out.unit);

I'm using version 1.3.5.

License file

Hello! I was wondering if you would be open to adding a license file to this project / clarifying what license the component is available under?

Right now, the only information I could find is in the package.json (ISC), which I imagine is from the npm init default.

Thanks for your hard work on this. By the way—I worked on Surge, so it’s always cool when I stumble across something I’m looking to use that’s using Surge for docs / examples.

little yanking in Chrome, more noticeable on Safari

Hi and first of all, thank you for this plugin! quite frankly its wonderful to work with!

Just wanted to point out that its yanking a little in both chrome and safari but more noticeable on safari. when you scroll down, the pages kinda rethinks smooth scrolling and thats when it begins to yank a little. right now, I only have it wrapped inside an <h1> tag, quoting you

but if you do (like I did) and you use this package try and use it responsibly...

anyways, just wanted to give you a heads up and ill patiently wait for any help if you can, in the meantime, ill keep trying to troubleshoot on my end.

i tried rolling back to 1.1.0 but same behavior.

again, great job and i appreciate the plugin

Support custom children as layer content for ParallaxBanner

Should be possible to allow custom children for each layer of the <ParallaxBanner>. This would allow video or other html to parallax inside a banner. See #21

const Video = ({ src }) => (
    <video src={src}></video>
);

...

<ParallaxBanner
    layer={[{
        amount: 0.2,
        children: <Video src="foo.mp4">,
    }]}
/>

Option to animate css

Is it possible to use ParallaxProvider, or Parallax to animate certain CSS property – for example adding fade in/out via opacity?

Is there a method, or callback that can be used to calculate some kind of a ratio?

Add support for new context API

Use React 16.3.0 new context API.

  • Update the <ParallaxProvider> and <Parallax> to use new context API
  • Document usage of controller methods with new context changes
  • Support old API for accessing controller methods
  • Add new tests/Fix broken tests

Update parallaxController to include method to set the scrollContainer

Feature Request

So that this component could be used with server side rendering (Gatsby is my case), it would be extremely helpful to be able to expose a method as part of the parallaxController api to update the scrollContainer property on ParallaxProvider.

In a SSR environment, the reference the the DOM element that is the scrolling container won't be known until componentDidMount in the parent component of ParallaxProvider can be called. Even if that is updated via a state change, the ParallaxProvider is initialized and does not update the scrollContainer property.

For example, the below does not work, as ParallaxProvider does not update after its first render, so the scrollContainer prop never passes in the updated element stored in the parent components state:

class MyComponent extends React.Component {
   
    componentDidMount() {
         const el = /* some code to either user ReactDOM or another method to get the HTML DOM node that is the scroll container. */
         this.setState({
             scrollContainer: el
         })
    }

    render() {
        return (
            <ParallaxProvider scrollContainer={this.state.scrollContainer}>
                {this.props.children}
            </ParallaxProvider>
        )
    }
}

A simple method to update the scrollContainer on the parallaxController api would solve this:

parallaxController.setScrollContainer(myelement)

ParallaxController.update() Throwing Error

Hello @jscottsmith. Parallax Component and Listener are super cool. The component works generally, except image loading is messing up the parallax calculations, and I am having issues getting the controller to update. Any way I try to call the update() method throws an error. Any help sorting this out would be really appreciated.

Here is my code:

`
import React, {Component} from 'react'
import { Parallax, ParallaxController } from 'react-scroll-parallax';
import styled from 'styled-components'
import media from '../components/mediaquery.jsx'

const City = styled.section margin: 5em 0; width: 100%;

const TextWrap = styled.div display: flex; flex-flow: row wrap; justify-content: space-between; margin: 5em 0; ${media.to.smmargin: 2em 0;`}

h2 {
width: 45%;
${media.to.xl width: 45%;}
${media.to.lg width: 100%;}
${media.to.md width: 100%;}
${media.to.sm width: 100%;}
}

p {
width: 45%;
${media.to.xl width: 45%;}
${media.to.lg width: 100%;}
${media.to.md width: 100%;}
${media.to.sm width: 100%;}
}
`

const ImageWrap = styled.section display: flex; flex-flow: row wrap; justify-content: space-between; margin: 5em 0; padding: 0; ${media.to.smmargin: 2em 0;`}

.city-image:nth-child(even) {
margin: 2em 5%;
width: 35%;
}

.city-image:nth-child(odd) {
margin: 2em 5%;
width: 35%;
}

img {
height: 100%;
width: 100%;
}
`

class CityComponent extends Component {

componentWillMount(){
ParallaxController.init()
}

componentDidMount() {
ParallaxController.update() // THIS IS WHAT THROWS THE ERROR
}

render() {
const Gallery = this.props.gallery.map((image, index) => {
let keyValue = ${this.props.name.toLowerCase()} + '_' + ${index}

  if ( index % 2 === 0 && index !== 0 ) {
    return (
      <Parallax
          className="city-image"
          offsetYMax={'60%'}
          offsetYMin={'0%'}
          slowerScrollRate
          tag="figure"
          key={keyValue}
      >
          <img src={this.props.gallery[index]} alt={this.props.name} />
      </Parallax>
    )
  } else if ( index !== 0 ) {
    return (
      <Parallax
          className="city-image"
          offsetYMax={'30%'}
          offsetYMin={'0%'}
          slowerScrollRate
          tag="figure"
          key={keyValue}
      >
          <img src={this.props.gallery[index]} alt={this.props.name} />
      </Parallax>
    )
  }
})
return (
  <City>
    <TextWrap>
      <h2>{this.props.name}</h2>
      <p>{this.props.text}</p>
    </TextWrap>
    <ImageWrap>
      <img src={this.props.gallery[0]} alt={this.props.name} />
      {Gallery}
    </ImageWrap>
  </City>
)

}
}

export default CityComponent
`
screen shot 2017-08-12 at 12 59 23 pm

Element with parallax applied always transformed along Y axis when scroll position is 0

Sorry for the long-winded title. I'm using this library (awesome work btw) to implement a parallax header similar to your example: https://codepen.io/jscottsmith/pen/aVBvGj

My issue is that I want the header to not be transformed at all until the user scrolls, so it sits flush to the top of the viewport. However, even when window.scrollY is 0 there's always some transformY being applied. You can see this even in the codepen above so I'm sure it's not something I'm doing wrong.

Is this by design?

Use of px unit

Hi,

I can't figure out how to use the px unit with the <Parallax> component.

When I do this : <Parallax offsetYMin="-60px">, I get the following error:

Uncaught Error: Must provide matching units for the min and max offset values of each axis

support: how to access parallax-inner by its ref

Hey!

I want to access the dom element parallax-inner by its ref.

I wanna do something like the following:

componentDidMount() {
        const aboutParallax = this.secondParallax;
        let aboutParallaxTransform = window.getComputedStyle(secondParallax, null).transform;
        console.log(aboutParallaxTransform);
      });
    }

<Parallax offsetXMax={-20} offsetXMin={20} slowerScrollRate  ref={(parallax) => { this.secondParallax = parallax; }}>
 ...
 </Parallax>


/* ERROR: 

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
    at HTMLDocument

*/

Any help would be appreciated! Thank you!

Beta pre-release

Beta Pre-release

The following goals and tasks should be completed for a beta pre-release. See the project board for the current state of tasks: React Scroll Parallax Project

  • Rename ParallaxScrollListener to ParallaxController
  • Increase test coverage
  • Complete documentation of component and ParallaxController public API
  • Review and clean up code comments
  • Update GitHub pages examples

TypeScript declaration file

Feature Request

People can't use this library in their TypeScript projects, because there is no TypeScript declaration file. Usually, for me it's easier to make own typings, but making typings for this project is more complex and takes more time then I can spend on it right now.

TypeScript becomes very popular. Following the last State of JavaScript survey results, almost half of participants using TypeScript and almost third of participants interested in it.

styleInner not added to the element

I was trying to add rotate style to the element with styleInner and StyleOuter but styleInner doesn't add my style to the element.

<Parallax
className="custom-class"
offsetYMax={-20}
offsetYMin={20}
tag="figure"
styleInner={{ transform: 'rotate(0)' }}
styleOuter={{ transform: 'rotate(80deg)' }}
slowerScrollRate
>
 <div className="my-element" />
</Parallax>
  • Version: 1.3.5

parallax scroll speed option

Would be nice if there was a scroll speed variable where we could set how fast the parallax-scroll would happen, also maybe some better explanation of what each attribute representes and how it affects the parallax effect

Choppy parallax on safari

Hi,

I'm using your component in an app I'm currently working on, but it's actually choppy on scroll... There are some animations run in the same time, but it works perfectly on Chrome. Firefox is a bit choppy too.

I read on the web that it could be solved with material acceleration. I tried to set up on .parallax-inner the two followings :

perspective: 1000;
backface-visibility: hidden;

But that hasn't any effect... Any clue why it's so slow and choppy ? And how to solve it ?

Thanks a lot :)

ParallaxBanner Children not displayed

Hello, i'm very new to web dev.

My ParallaxBanner background image works,
but the children (title and subtitle) are not working, like if the image was on them.
Is it a problem with CSS?

import React from 'react';
import { ParallaxBanner } from 'react-scroll-parallax';

import './index.css';
import testHeaderImg from '...';

class ProjectHeader extends React.PureComponent {
  render() {
    return (
      <div className="project-header">

        <ParallaxBanner
          className="project-header-parallax-banner"
          layers={[
            {
              image: testHeaderImg,
              amount: 0.6,
              slowerScrollRate: true,
            }
          ]}
          style={{
            height: '900px',
          }}
        >
          <h3>Project TITLE</h3>
          <h5>Project SUBTITLE</h5>

        </ParallaxBanner>

      </div>
    );
  }
}

export default ProjectHeader;

Thank you for your time

ParallaxBanner video direction

ParallaxBanner video direction

Hi,
I added a ParallaxBanner to my project with a

I compared it to the ParallaxBanner video example on this website and the parallax direction seems inversed, may be I did something wrong but I can't figure it out, there's no errors / warnings related to the parallax in console.

Here is my code:

<ParallaxBanner
       style={{height: "95vh"}}
       layers={[
            {
                 children: <video autoPlay loop muted className="top-video" src={global.resourceServer + "video/top.mp4"} />,
                 amount: 0.1,
                 expanded: true
             }
       ]}
/>

Alpha v2 Release

NOTICE

This was never implemented in the current v2. Do not reference this for issues or examples on how to work with the current API. Use the documentation.


Why?

v2 is a re-write of v1 to add new scroll effects such as opacity and scale in addition to translations. It also uses the new Intersection Observer API which is a more efficient way of determining when elements are within the viewport as compared with v1's implementation. Additionally, much of the state of v1's ParallaxController has been moved to focused React components with the hope that these components can also be repurposed to create additional effects. This also has the added benefit of being able to easily debug with React specific tooling to see the state of effects in the browser.

Installation

Currently pre-releases can be installed via react-scroll-parallax@next. But note this is an alpha and subject to breaking changes -- it should not be used in production.

Demos

Take a look at the Storybook Demos for various implementations with v2 prop API. Toggle knobs to change the props on the fly.

Todo List

Tasks that still need to be completed for a proper Beta release:

  • Add additional stories
  • Update old example sites to use v2
  • Remove debug styles
  • Increase test coverage
  • Review and update the README
  • Add an ISSUE_TEMPLATE
  • Add disabled prop
  • Document all props
  • Add an example of how to update cached properties
  • Document internal components that can be used without parallax such as <Observed>
  • Expose progress value in the render function
  • Consider adding an illustration that details how this lib works (x, y offsets)
  • Consider additional components like <ParallaxImage> or <ParallaxBanner>
  • Consider prop config to determine how progress is calculated for special use cases #21
  • Consider adding a specialized component that supports parallax of fixed position elements. See #23

Requests

Any feature requests, concerns, or changes to the current API can be discussed here.

Parallax for Background Image With Content On Top

Hello,

I was curious as to if you could provide an example where the background image is the component and the content inside the image area scrolls naturally. Prior to this library, I was using CSS to parallax the background image which made it easy to put regular HTML content on top; however, I don't think that approach works with this library due to the fact that your parallax content must live inside the Parallax component.

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.