javascripthtmlcsswebflickity

How to wrap my whole code in flickity js into a function?


I cannot find any tutorials on how to modify this flickity js code. I am completely new with vanilla js and I admit that I do not have good knowledge with it. This is my code but the flickity slider is not working anymore when I wrapped the whole code into a function.

const slider = () => {
  new Flickity( '.slider', {

    cellAlign: 'left',
    draggable: true,
    contain: true,
    wrapAround: true,
    autoPlay: 2000,
    arrowShape: { 
      x0: 10,
      x1: 60, y1: 50,
      x2: 65, y2: 45,
      x3: 20
    }
  });  
}

export default slider

Solution

  • Alright, Thanks to @camaulay, I didn't notice the console. One of my js files is not under a function so the compiler won't let me compile my codes.