I’ve imported the file into common.js bit when I try and use it I get ''Uncaught TypeError: ScrollReveal is not a function" showing in the console.
This is what my common.js looks like:
import 'scrollreveal/dist/scrollreveal.min';
export default {
init() {
// JavaScript to be fired on all pages
$('.hamburger').click(function() {
$(this).toggleClass('is-active');
$('.menu-block').toggleClass('visible');
});
},
finalize() {
// JavaScript to be fired on all pages, after page specific JS is fired
const ScrollReveal = require('scrollreveal');
ScrollReveal().reveal('.cta__subheader');
ScrollReveal().reveal('.cta__button');
},
};
I aslo had to remove the constant declaration for ScrollReveal and run the functions when the page has fully loaded.
import ScrollReveal from 'scrollreveal'
export default {
init() {
// JavaScript to be fired on all pages
$('.hamburger').click(function() {
$(this).toggleClass('is-active');
$('.menu-block').toggleClass('visible');
});
},
finalize() {
// JavaScript to be fired on all pages, after page specific JS is fired
$(window).load(function() {
ScrollReveal().reveal('.cta__subheader');
ScrollReveal().reveal('.cta__button');
});
},
};