wagerfield / parallax

Parallax Engine that reacts to the orientation of a smart device
http://wagerfield.github.io/parallax/
Other
16.51k stars 2.14k forks source link

[support] parallax only updates on click in react #313

Closed nehvaleem closed 2 years ago

nehvaleem commented 2 years ago

it's been a while for me when it comes to web development but this is something that I cannot understand. Parallax seems to be updated only when I click anywhere on the page (and it's working properly). I have a very basic setup, something like this:

class IndexPage extends React.Component {
  componentDidMount() {
    this.parallax = new Parallax(this.scene);
  }

  componentWillUnmount() {
    this.parallax.disable()
  }

  render() {
    return (
      <Wrapper ref={el => this.scene = el}>
        <CloudsComponent className="layer" data-depth="0.00" />
        <GrassComponent  className="layer" data-depth="0.20"  /> 
        <ForegroundGrass />
        <UsComponent  className="layer" data-depth="0.80"/>       
      </Wrapper>
    )
  }
}

export default IndexPage
nehvaleem commented 2 years ago

oh, I get it. It updates on click when simulating mobile in chrome dev tools (it's the same for the official example). Unfortunately, it behaves the same for the real device while the example is working great.

nehvaleem commented 2 years ago

I get it - almost. It seems that some security issues preventing accessing gyro or something when not using HTTPS. After deploying to a remote site everything works as expected. Well maybe apart from that iOS seems to be nonfunctional at all.

reneroth commented 2 years ago

I get it - almost. It seems that some security issues preventing accessing gyro or something when not using HTTPS. After deploying to a remote site everything works as expected. Well maybe apart from that iOS seems to be nonfunctional at all.

Yes, Apple decided to block the gyroscope API on their devices - one of the reasons I lost interest in maintaining this library :(
We have to blame the small minority of companies and individuals who have to abuse every tool they're given to make the internet a worse place. It's a shame they had to pull the plug on that, but I can see why they did it, since even Facebook started abusing it to track their users without consent.