inuyaksa / jquery.nicescroll

nicescroll plugin for jquery - scrollbars like iphone/ipad
https://nicescroll.areaaperta.com/
3.6k stars 1.67k forks source link

[Webpack] - niceScroll is not a function #829

Open epeliberty opened 3 years ago

epeliberty commented 3 years ago

Hello,

I tried to use jquery.nicescroll with webpack 4.43 but i have this error :

jQuery.Deferred exception: $domElts.faqBox.niceScroll is not a function TypeError: $domElts.faqBox.niceScroll is not a function
    at HTMLDocument.<anonymous> 

My code is :

import '../../../css/sites/customize/main.scss';

const Customize = () => {
  const $domElts = {
    faqBox: $('.faq-list .faq-list-questions-content')
  };

  const initEvents = () => {
    if ($domElts.faqBox.length > 0) {
       $(() => {

         $domElts.faqBox.niceScroll({
           cursorcolor: "#31b7bc",
           cursorwidth: "7px",
           zindex: -1,
         });
       })
    }
  };

  return {
    init: () => {
      initEvents();
    },
  };
};

$(() =>{
  Customize().init();
});

On my webpack.config.js, I have add this :

.autoProvidejQuery()

but it's doesn't work ...

Thank you in advance for your help