malihu / malihu-custom-scrollbar-plugin

Highly customizable custom scrollbar jQuery plugin, featuring vertical/horizontal scrollbars, scrolling momentum, mouse-wheel, keyboard and touch support etc.
http://manos.malihu.gr/jquery-custom-content-scroller
MIT License
4.11k stars 1.51k forks source link

mCustomScrollbar is not a function #606

Open rknbgl opened 6 years ago

rknbgl commented 6 years ago

Hello, In my Angular CLI project:

package.json ... "dependencies": { ... "jquery": "^3.3.1", "ngx-malihu-scrollbar": "^1.3.2", "@types/mcustomscrollbar": "^2.8.32" ... } ...

.angular-cli.json ... "styles": [ "assets/styles/app.css", "styles.css", "../node_modules/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css" ], "scripts": [ "../node_modules/jquery/dist/jquery.min.js", "../node_modules/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js" ] ...

tsconfig.app.json ... "types": [ "jquery", "jquery-mousewheel", "mcustomscrollbar" ] ...

app.module.ts import {MalihuScrollbarModule} from 'ngx-malihu-scrollbar';

import * as $ from 'jquery'; window['$'] = window['jQuery'] = $;

... imports:[ ... MalihuScrollbarModule.forRoot() ...] ...

component.html <div class="js-custom-scrollbars e-custom-scrollbars" malihu-scrollbar [scrollbarOptions]="{ scrollbarPosition: 'outside', theme: 'minimal', advanced: { updateOnContentResize: true } }">

And I got a error: ERROR TypeError: n.mCustomScrollbar is not a function at main.a372dd5d0a99bcae16c2.bundle.js:1 at t.ZSR1.t.invoke (polyfills.9e79265bca3f3f91c6b4.bundle.js:1) at e.ZSR1.e.run (polyfills.9e79265bca3f3f91c6b4.bundle.js:1) at t.WT6e.t.runOutsideAngular (main.a372dd5d0a99bcae16c2.bundle.js:1) at t.J83O.t.initScrollbar (main.a372dd5d0a99bcae16c2.bundle.js:1) at t.initScrollbar (main.a372dd5d0a99bcae16c2.bundle.js:1) at t.ngAfterViewInit (main.a372dd5d0a99bcae16c2.bundle.js:1) at vi (main.a372dd5d0a99bcae16c2.bundle.js:1) at yi (main.a372dd5d0a99bcae16c2.bundle.js:1) at _i (main.a372dd5d0a99bcae16c2.bundle.js:1)

izy2nv commented 5 years ago

@JCarlosR Why liking a question if u don't have a response?

Prinsn commented 4 years ago

@izy2nv I interpret a like on a question as "I also have this question", so there's nothing else to respond with.

izy2nv commented 4 years ago

@Prinsn Got it. Hopefully we find solutions to this.

Prinsn commented 4 years ago

Yeah, I'm blocked on it right now, hopefully I'll find something today, for my own sanity.

izy2nv commented 4 years ago

@Prinsn We all will be fine. Keep pushing

Prinsn commented 4 years ago

Okay, so this may or may not be the solution, but this was the fix for karma, as my app was working but the tests would not work:

Where OP indicated:

"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js"
]

Add a path to 'node_modules/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.js' (this was in the karma config files argument for my case)