creativetimofficial / material-kit

Free and Open Source UI Kit for Bootstrap 5, React, Vue.js, React Native and Sketch based on Google's Material Design
https://www.creative-tim.com/product/material-kit?ref=mk-creativetimofficial-github
MIT License
5.91k stars 1.37k forks source link

React/Next.js - Parallax lost when changing page #126

Closed davidroman0O closed 6 years ago

davidroman0O commented 6 years ago

Hi!

It's not an issue, just a message for anyone who will have this issue.

On the highest component you got into your virtual dom tree, add this function inside of a component :

addParallax() {
    window.big_image = window.jQuery('.page-header[data-parallax="true"]');
    window.jQuery(window).on('scroll', window.materialKit.checkScrollForParallax);
}

For Next.js, add this function inside of your _app.js.

Now, we need to execute it!

componentDidUpdate(prevProps, prevState, snapshot) {
    this.addParallax();
}

componentDidMount() {
    this.addParallax();
}

I hope it will help someone in the world. Have fun! This theme is awesome!