Code Monkey home page Code Monkey logo

ngx-malihu-scrollbar's Introduction

ngx-malihu-scrollbar

CircleCI Coverage Status version npm dependencies Status peerDependencies Status monthly Downloads

Angular Malihu jQuery Custom Scrollbar directive and service.

Malihu jQuery Custom Scrollbar is a highly customizable scrollbar plugin that include vertical and/or horizontal scrollbar(s), adjustable scrolling momentum, mouse-wheel (via jQuery mousewheel plugin), keyboard and touch support, ready-to-use themes and customization via CSS, RTL direction support, option parameters for full control of scrollbar functionality, methods for triggering actions like scroll-to, update, destroy etc., user-defined callbacks and more.

Table of contents

Installation

Use the following command to add ngx-malihu-scrollbar library to your package.json file. Note that jQuery will automatically be downloaded as a dependency.

npm install ngx-malihu-scrollbar --save

You will need to add Malihu Custom Scrollbar javascript and css files with jQuery to your application.

If you are using Angular CLI you can follow the example below...

angular.json

"styles": [
  "src/styles.scss",
+ "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

{
  "compilerOptions": {
    ...
    "types": [
+     "jquery",
+     "mcustomscrollbar"
    ]
  },
  ...
}

Usage

You must import MalihuScrollbarModule inside your module to be able to use malihu-scrollbar directive or MalihuScrollbarService.

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
+ import { MalihuScrollbarModule } from 'ngx-malihu-scrollbar';

import { HomeComponent } from './home.component';

@NgModule({
  imports: [
    CommonModule,
+   MalihuScrollbarModule.forRoot(),
  ],
  declarations: [HomeComponent],
})

ngx-malihu-scrollbar provides both a directive and a service to apply the custom scrollbar on your HTML element.

For a complete list of available customization options please refer to the original Malihu Custom Scrollbar documentation.

Directive

You can use malihu-scrollbar directive directly on an HTML element and provide plugin options using scrollbarOptions input property.

example.component.ts

public scrollbarOptions = { axis: 'yx', theme: 'minimal-dark' };

example.component.html

<div malihu-scrollbar [scrollbarOptions]="scrollbarOptions">
   Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...
</div>

Service

Alternatively, you can initialize scrollbar customizations using MalihuScrollbarService by providing either a string selector, a jQuery object or an HTML element along with the scrolling options.

The service also provide access to other Malihu Custom Scrollbar methods such as scrollTo, stop, update, disable and destroy.

constructor(
  private mScrollbarService: MalihuScrollbarService,
) { }

ngAfterViewInit() {
  this.mScrollbarService.initScrollbar('#myElementId', { axis: 'y', theme: 'dark-thick', scrollButtons: { enable: true } });
}

ngOnDestroy() {
  this.mScrollbarService.destroy('#myElementId');
}

FAQ

Can we customize the scrollbars?

Of course, the scrollbars are fully customizable. You can easily clone an existing theme and modify the CSS to apply your own styling. Follow the instructions provided on the original Malihu Custom Scrollbar Plugin documentation for more details.

The "custom-theme" example on the bottom of the demo is a good example of customization where I created a my own "metro" theme.

How can we apply scrollbar customization on the body?

Using MalihuScrollbarService you can target document.body to apply customization to the body scrollbar.

Note that this will automaticaly add some specific CSS to the <body> element that is needed to allow scrollbar customization.

import { MalihuScrollbarService } from 'ngx-malihu-scrollbar';

constructor(
  private mScrollbarService: MalihuScrollbarService,
) { }

ngOnInit() {
  this.mScrollbarService.initScrollbar(document.body, { axis: 'y', theme: 'dark-3' });
}

Demo application

You can find the demo source code inside the demo directory.

The following commands will clone the repository, install npm dependencies and serve the application @ http://localhost:4200

git clone https://github.com/jfcere/ngx-malihu-scrollbar.git

npm install

ng serve

Contribution

Contributions are always welcome, just make sure that ...

  • Your code style matches with the rest of the project
  • Unit tests pass
  • Linter passes

License

Licensed under MIT.

ngx-malihu-scrollbar's People

Contributors

dependabot[bot] avatar jfcere avatar quigleyj97 avatar teslovych avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ngx-malihu-scrollbar's Issues

Can't implement infinite data load with this scroll

Hello,
I've implemented this scroll in my grid table and now I want to implement infinite scroll with this as well using the same container, it seems not possible so far as onscroll event not getting fire on malihu scrolling.
Please anyone suggest me how I can do that?
Thanks in advance!

Regards,
Kundan

ngx-malihu-scrollbar scrollTo method is not working

I am using ngx-malihu-scrollbar in my angular project. scrollTo is not working,

`import { MalihuScrollbarService } from 'ngx-malihu-scrollbar';
constructor(private mScrollbarService: MalihuScrollbarService) { }

ngOnChanges() {
this.mScrollbarService.scrollTo(#${this.dateIndex}, 10 , { scrollEasing:'easeOut' });
}my HTML code<div malihu-scrollbar [scrollbarOptions]="darksScrollbarOptions">

... `

In this.dateIndex I will be getting the id

Using Callbacks with Ng Custom functions

I'm trying to use the onTotalScroll callback to trigger a function in the component, which would "lazy load" more items into the scroll box:

ngOnInit() {
  this.scrollbarOptions = {
  axis: 'y',
  scrollButtons: {enable: false},
  scrollInertia: 250,
  theme: 'content-cloud',
  callbacks:{
    onTotalScroll: function() {
      console.log("End of Scroll");
      this.loadMore();
    }
  }
};

loadMore() {
  console.log("Loading more!");
};

However, the function loadMore() can't be found:

EXCEPTION: this.loadMore is not a function

I'm unsure about the best way to do this, because the function is trying to be called inside the callback inside the scrollbarOptions.

Any help is much appreciated!

Could you please remove the jQuery and d.ts dependency for this project?

It is not a good practice to include such type definition dependency in the npm UI component.

First of all, it possibly in conflict with version's/context of what the developer's project has.

Second, it does nothing, because you have asked the user to import it (better optionally) explicitly as an external source in the guidance.

mCSB_draggerRail is inside the mCSB_dragger

Hello.
The mCSB_draggerRail is inside the mCSB_dragger. This causes a display problems with the dragger rail (it isn't shown properly). It looks like an issue: malihu/malihu-custom-scrollbar-plugin#652.
It can be seen on the demo page also.
I solved that by the jQuery downgrade to v3.4.1. But it isn't a perspective solution for the future.
Is there any better known solution for this issue?

Thanks s lot.

Multiple scroll bars

Not sure what iam doing wrong ,I can see 2 scroll bars one is dark theme , another is light theme.
any help ?

image

here is the component.

image

same issue when I use directive as well.
Looking forward for kind response.

Require Update

Can you please update so it will work with Angular 5 and 6, Also please setup the different demos and github projects for component approach, Service approach etc. Now it is little bit confusing.

MalihuScrollbarService / MalihuScrollbarDirective not exported in the bundle

Hello,

Looking at the npm bundle in the current version 1.2.1 (node_modules\ngx-malihu-scrollbar\dist\bundles\ngx-malihu-scrollbar.umd.js) it seems only MalihuScrollbarModule is exported, not the directive or service, so the service cannot be injected (MalihuScrollbarService is undefined and cannot be used as a token).

Reproduced here: https://plnkr.co/edit/YQaW13j5sW5n7xKjjX7F

(BTW thanks for the performance in 1.2.1, it seems to work fine, the dirty checking is not invoked on each auto-update anymore).

Regards,
Jeremy

Cannot read property 'autoUpdate' of undefined

TypeError: Cannot read property 'autoUpdate' of undefined
at HTMLDivElement.N (http://localhost:4200/scripts.bundle.js:12:593)
at HTMLDivElement. (http://localhost:4200/scripts.bundle.js:11:6429)
at Function.each (http://localhost:4200/scripts.bundle.js:4:2861)
at n.fn.init.each (http://localhost:4200/scripts.bundle.js:4:845)
at n.fn.init.destroy (http://localhost:4200/scripts.bundle.js:11:6232)
at n.fn.init.e.fn.(anonymous function) [as mCustomScrollbar] (http://localhost:4200/scripts.bundle.js:12:6801)
at http://localhost:4200/vendor.bundle.js:22637:82
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:2801:26)
at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run (http://localhost:4200/polyfills.bundle.js:2551:43)
at NgZone.webpackJsonp.../../../core/@angular/core.es5.js.NgZone.runOutsideAngular (http://localhost:4200/vendor.bundle.js:85993:83)
at HTMLDivElement.N (http://localhost:4200/scripts.bundle.js:12:593)
at HTMLDivElement. (http://localhost:4200/scripts.bundle.js:11:6429)
at Function.each (http://localhost:4200/scripts.bundle.js:4:2861)
at n.fn.init.each (http://localhost:4200/scripts.bundle.js:4:845)
at n.fn.init.destroy (http://localhost:4200/scripts.bundle.js:11:6232)
at n.fn.init.e.fn.(anonymous function) [as mCustomScrollbar] (http://localhost:4200/scripts.bundle.js:12:6801)
at http://localhost:4200/vendor.bundle.js:22637:82
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:2801:26)
at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run (http://localhost:4200/polyfills.bundle.js:2551:43)
at NgZone.webpackJsonp.../../../core/@angular/core.es5.js.NgZone.runOutsideAngular (http://localhost:4200/vendor.bundle.js:85993:83)
at resolvePromise (http://localhost:4200/polyfills.bundle.js:3233:31)
at resolvePromise (http://localhost:4200/polyfills.bundle.js:3204:17)
at http://localhost:4200/polyfills.bundle.js:3282:17
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (http://localhost:4200/polyfills.bundle.js:2834:31)
at Object.onInvokeTask (http://localhost:4200/vendor.bundle.js:86030:33)
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (http://localhost:4200/polyfills.bundle.js:2833:36)
at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (http://localhost:4200/polyfills.bundle.js:2601:47)
at drainMicroTaskQueue (http://localhost:4200/polyfills.bundle.js:3011:35)
at ZoneTask.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (http://localhost:4200/polyfills.bundle.js:2912:21)
at invokeTask (http://localhost:4200/polyfills.bundle.js:3949:14)
defaultErrorLogger @ core.es5.js:1020
webpackJsonp.../../../core/@angular/core.es5.js.ErrorHandler.handleError @ core.es5.js:1080
next @ core.es5.js:4503
schedulerFn @ core.es5.js:3635
webpackJsonp.../../../../rxjs/Subscriber.js.SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
webpackJsonp.../../../../rxjs/Subscriber.js.SafeSubscriber.next @ Subscriber.js:185
webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber._next @ Subscriber.js:125
webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.next @ Subscriber.js:89
webpackJsonp.../../../../rxjs/Subject.js.Subject.next @ Subject.js:55
webpackJsonp.../../../core/@angular/core.es5.js.EventEmitter.emit @ core.es5.js:3621
(anonymous) @ core.es5.js:3912
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:392
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run @ zone.js:142
webpackJsonp.../../../core/@angular/core.es5.js.NgZone.runOutsideAngular @ core.es5.js:3844
onHandleError @ core.es5.js:3912
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.handleError @ zone.js:396
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runGuarded @ zone.js:158
_loop_1 @ zone.js:702
api.microtaskDrainDone @ zone.js:711
drainMicroTaskQueue @ zone.js:610
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:503
invokeTask @ zone.js:1540
globalZoneAwareCallback @ zone.js:1566

The malihu scroll bar seems keep firing endless events, which makes the angular DoCheck life circle hook runs over and over again

reproduce this issue

follow this to reproduce this issue, all code is based on the repo:

  1. add the following lines to the head of malihu-scrollbar-demo.component.html
<button (click)="get()">click</button>
<div *ngFor="let theme of themes; trackBy: track">
  <!--do nothing here-->
</div>
  1. add the following line in the class MalihuScrollbarDemoComponent defined in malihu-scrollbar-demo.component.ts
  track() {
    if (!window['cc']) {
      window['cc'] = 1;
    }
    window['cc']++;
  }

  get() {
    console.log(window['cc']);
  }
  1. recompile the repo, open the console of the browser, wait for seconds and click the button at the head of the page. it look like this in my browser:

image

  1. if everything goes right, your console should look like this (btw I clicked several times )

image

this is a series performance problem

as we known, the ngFor implements the DoCheck life cicle hook, which makes the ngFor very sensitive to any change, because that after any event, the ngDoCheck of ngFor will be invoked. It seems that malihu keep firing event and make angular executes the ngDoCheck hook time and time again.

How to fix this?

Angular 8 support

I'd like to update to Angular 8 my project but there is a dependencies conflict that would requires an update by this package:

Package "ngx-malihu-scrollbar" has an incompatible peer dependency to "zone.js" (requires "^0.8.26", would install "0.9.1").

update to angular4, aot build get error

ERROR in Error encountered resolving symbol values statically. Calling function 'makeDecorator', function calls are not supported. Consider replacing the function
or lambda with a reference to an exported function, resolving symbol Injectable in /Users/Dave/work/weishu-admin/node_modules/ngx-malihu-scrollbar/node_modules/@an
gular/core/src/di/metadata.d.ts, resolving symbol OpaqueToken in /Users/Dave/work/weishu-admin/node_modules/ngx-malihu-scrollbar/node_modules/@angular/core/src/di/
opaque_token.d.ts, resolving symbol OpaqueToken in /Users/Dave/work/weishu-admin/node_modules/ngx-malihu-scrollbar/node_modules/@angular/core/src/di/opaque_token.d
.ts

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/Dave/work/weishu-admin/src'
@ ./src/main.ts 4:0-74
@ multi ./src/main.ts

when I recently update to angular4 and angular cli 1.0.0, I try to aot build then I get this error, this is my package.json
{ "name": "isaqa", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { "ng": "ng", "start": "ng serve --proxy-config proxy.conf.json", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "compodoc": "./node_modules/.bin/compodoc -p src/tsconfig.json" }, "private": true, "dependencies": { "@angular/animations": "^4.0.0", "@angular/common": "^4.0.0", "@angular/compiler": "^4.0.0", "@angular/core": "^4.0.0", "@angular/forms": "^4.0.0", "@angular/http": "^4.0.0", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/platform-server": "^4.0.0", "@angular/router": "^4.0.0", "bootstrap": "^3.3.7", "core-js": "^2.4.1", "font-awesome": "^4.7.0", "jquery": "^3.1.1", "ng2-bootstrap": "^1.3.3", "ng2-ckeditor": "^1.1.6", "ngx-malihu-scrollbar": "^1.1.0", "ngx-mydatepicker": "^0.1.0", "ngx-tooltip": "^0.0.9", "rxjs": "^5.1.0", "zone.js": "^0.7.6" }, "devDependencies": { "@angular/cli": "^1.0.0", "@angular/compiler-cli": "^4.0.0", "@types/jasmine": "2.5.38", "@types/jquery": "^2.0.40", "@types/node": "~6.0.60", "codelyzer": "~2.0.0-beta.4", "jasmine-core": "~2.5.2", "jasmine-spec-reporter": "~3.2.0", "karma": "~1.4.1", "karma-chrome-launcher": "~2.0.0", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^0.2.0", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.0", "ts-node": "~2.0.0", "tslint": "~4.4.2", "typescript": "^2.2.1" } }

"Cannot find namespace" & "Cannot find name"

When I "ng serve" my project with Angular CLI 1.0.0.rc, the compile fails and I get the following errors from ngx-malihu-scrollbar:

ERROR in C:/wamp64/www/contentcloud/node_modules/ngx-malihu-scrollbar/src/app/malihu-scrollbar/malihu-scrollbar.service.ts (3,31): Cannot find name 'JQuery'.)
C:/wamp64/www/contentcloud/node_modules/ngx-malihu-scrollbar/src/app/malihu-scrollbar/malihu-scrollbar.service.ts (10,50): Cannot find namespace 'MCustomScrollbar'.)
C:/wamp64/www/contentcloud/node_modules/ngx-malihu-scrollbar/src/app/malihu-scrollbar/malihu-scrollbar.service.ts (14,61): Cannot find namespace 'MCustomScrollbar'.)
C:/wamp64/www/contentcloud/node_modules/ngx-malihu-scrollbar/src/app/malihu-scrollbar/malihu-scrollbar.service.ts (34,47): Cannot find name 'JQuery'.)
C:/wamp64/www/contentcloud/node_modules/ngx-malihu-scrollbar/src/app/malihu-scrollbar/malihu-scrollbar.service.ts (36,14): Cannot find name '$'.)
C:/wamp64/www/contentcloud/node_modules/ngx-malihu-scrollbar/src/app/malihu-scrollbar/malihu-scrollbar.service.ts (39,14): Cannot find name '$'.)
C:/wamp64/www/contentcloud/node_modules/ngx-malihu-scrollbar/src/app/malihu-scrollbar/malihu-scrollbar.service.ts (41,28): Cannot find name 'jQuery'.)

ERROR in C:/wamp64/www/contentcloud/node_modules/ngx-malihu-scrollbar/src/app/malihu-scrollbar/malihu-scrollbar.directive.ts (13,30): Cannot find namespace 'MCustomScrollbar'.)
C:/wamp64/www/contentcloud/node_modules/ngx-malihu-scrollbar/src/app/malihu-scrollbar/malihu-scrollbar.directive.ts (15,22): Cannot find name 'JQuery'.)
C:/wamp64/www/contentcloud/node_modules/ngx-malihu-scrollbar/src/app/malihu-scrollbar/malihu-scrollbar.directive.ts (33,9): Cannot find name '$'.)
C:/wamp64/www/contentcloud/node_modules/ngx-malihu-scrollbar/src/app/malihu-scrollbar/malihu-scrollbar.directive.ts (34,9): Cannot find name '$'.)

If I save a file, and the project recompiles, the project runs fine and the scrollbars work perfectly.

This prevents the project from being successfully built.

Page scroll on bootstrap modal close

I used this module with angular 7. My page also consist a model popup. When model popup closed page scroll to malihu-scrollbar container top position.

remove jquery dependency in project

Can you provide new version without dependency of jquery in the project ?

because Jquery is not good for angular >= 2
And use only the angular component for the ngx-malihu-scrollbar implementation.
We love your work, but we are reluctant to use the module because of the dependency with JQuery. Plz can you update if is possible and remove Jquery dépendency.

Typescript error (Cannot find type definition file for 'jquery' and 'mcustomscrollbar')

Hello,

Once I do include the "types": [ "jquery", "mcustomscrollbar" ], I get

[app-scripts] [10:15:52] typescript error [app-scripts] Cannot find type definition file for 'jquery'. [app-scripts] Cannot find type definition file for 'mcustomscrollbar'. [app-scripts] [10:15:52] typescript error
in my logs.

Also, when I do open the browser I get the

Refused to apply style from 'http://localhost:8100/build/main.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Any ideas how to solve this?

the name 'MalihuScrollbarService' was not found

Hi, I've tried to import the script into my angular project and I want to use it in a component with the Service method. But after following the instructions the compiler gives me this error:

error TS2304: Cannot find name 'MalihuScrollbarService'

refering to the MalihuScrollbarService in the constructor (private mScrollbarService: MalihuScrollbarService)

Still quite new to angular by the way.

Can't bind to 'scrollbarOptions' since it isn't a known property of 'div'.

I get this error message in Angular 5 - Can't bind to 'scrollbarOptions' since it isn't a known property of 'div'.

Angular CLI: 1.6.8
Node: 8.9.1
OS: win32 x64
Angular: 5.0.1
... common, compiler, compiler-cli, core, forms, http
... language-service, platform-browser, platform-browser-dynamic
... router

@angular/animations: 5.2.1
@angular/cli: 1.6.8
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.8
@schematics/angular: 0.1.17
typescript: 2.4.2
webpack: 3.10.0

Error: Module build failed

I follow all step and when i want to use the script, give me this error:

Error: Module build failed: Error: ENOENT: no such file or directory, open '/Users/observatoriotui/Git/observatorio-tui-app/node_modules/ngx-malihu-scrollbar/index.js'
    at Error (native)
    at Object.<anonymous> (http://localhost:8100/build/vendor.js:133087:7)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.440 (http://localhost:8100/build/main.js:1961:80)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.437 (http://localhost:8100/build/main.js:1909:70)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at webpackJsonpCallback (http://localhost:8100/build/vendor.js:26:23)
    at http://localhost:8100/build/main.js:1:1

What can i do?

Unable to import module

I'm receiving this error when trying to serve after importing the MalihuScrollbarModule

ERROR in node_modules/ngx-malihu-scrollbar/src/malihu-scrollbar.module.d.ts:3:23 - error TS2314: Generic type 'ModuleWithProviders<T>' requires 1 type argument(s).
     static forRoot(): ModuleWithProviders;

The error refers to the following file

import { ModuleWithProviders } from '@angular/core';
export declare class MalihuScrollbarModule {
    static forRoot(): ModuleWithProviders;
    static forChild(): ModuleWithProviders;
}

The error is only in version 9. version 8 is working fine.
Please advise.
Thanks.

change Color

Can we change color of the scroll bar . i would like to have the color of material themes .

is this possible ?
if so Please suggest on how that can be achieved

Unable to install package through npm (using github link)

Hello,

I tried adding the package from branch update-angular-10 to the project I'm working on by providing a github link in npm, but I'm receiving the following error:

npm ERR! code ENOLOCAL
npm ERR! Could not install from "node_modules\ngx-malihu-scrollbar\lib" as it does not contain a package.json file.

I tried various syntaxes (npm install user/package#branch, npm install github:user/package#branch) or adding dependencies in package.json with these paths but the outcome is the same. I don't have this problem when installing some other packages from github - for example the branch angular2-moment from the package ngx-moment works just fine.

Is this a problem with this repo, or is my configuration somehow broken?

I also tried deleting the previous version of the package from node_modules and cleaned/verified cache.

Regards,
baklo

Auto expand scroll container on dynamic data added on x axis.

Scroll bar on x axis doesn't scroll beyond a specific point, if the data is added dynamically the scroll bar doesn't expand, it does when the axis is 'y' but not when its 'x'. I have tried advanced: { autoExpandHorizontalScroll: true, updateOnContentResize: true } option as well but its not seems to be working.

Scroll offset issue when resizing

Hi, I have an application which has to be locked to an aspect ratio. To do so I have a Directive that handles the resizing and makes sure that the content stays with the same aspect ratio. This is done with the use of CSS transform: scale().

Here is the directive I have implemented:

import { Directive, ElementRef, HostListener, OnInit, Input } from '@angular/core';

@Directive({
	selector: '[myResize]'
})

export class ResizeDirective implements OnInit {
	baseContentWidth: number;
	baseContentHeight: number;

	@Input() position: string = 'relative';

	private element: HTMLElement;
	private windowWidth: number;
	private windowHeight: number;

	constructor(
		private elementRef: ElementRef
	) { }

	ngOnInit() {
		this.baseContentWidth = 1920;
		this.baseContentHeight = 1080;

		this.element = this.elementRef.nativeElement;

		this.element.style.width = this.baseContentWidth + 'px';
		this.element.style.height = this.baseContentHeight + 'px';

		this.scaleContent(window.innerWidth, window.innerHeight);
	}

	@HostListener('window:resize', ['$event'])
	onResize(event: Event) {
		let windowRef = event.currentTarget as Window;
			this.scaleContent(windowRef.innerWidth, windowRef.innerHeight);
	}

	private scaleContent(windowWidth: number, windowHeight: number) {
		this.windowWidth = windowWidth;
		this.windowHeight = windowHeight;

		let widthScale = this.windowWidth / this.baseContentWidth;
		let heightScale = this.windowHeight / this.baseContentHeight;

		let newScale = (widthScale < heightScale) ? widthScale : heightScale;
		this.element.style.transform = 'scale(' + newScale + ')';

		this.keepContentCentered(newScale);
	}

	private keepContentCentered(contentScale) {
		let contentWidth = this.baseContentWidth * contentScale;
		let contentHeight = this.baseContentHeight * contentScale;

		let widthDiff = this.windowWidth - contentWidth;
		let heightDiff = this.windowHeight - contentHeight;

		let left = (widthDiff < 0) ? 0 : widthDiff / 2;
		let top = (heightDiff < 0) ? 0 : heightDiff / 2;

		this.element.style.left = left + 'px';
		this.element.style.top = top + 'px';
	}
}

Now in one part of my application I'm trying to implement an infinte scroll. The scrollbar has the following config:

	scrollbarOptions = {
		axis: 'y',
		theme: 'minimal-dark',
		autoHideScrollbar: false,
		advanced: {
			updateOnContentResize: true
		},
		callbacks: {
			onTotalScroll: () => {
				this.onScrollReachEnd.emit();
				this.malihuScrollbarService.update('#test-scrollbar');
			}
		}
	};

For some reason the scrollbar won't go all the way down when the window is not set to full screen (i.e. full screen after pressing F11 to go full screen mode). I tried enabling updateOnContentResize thinking that it might help fix the issue, but no luck so far.

I know that this is a very specific scenario but I was wondering if you might have an idea of what I can do to solve it.

Compatibility with CDK-Virtual-Scroll-bar

Hi @jfcere , thanks for this cool wrapper, just seeking for help to enable custom-scroll bar with Angular materials virtual-scroll(CDK) powered div/list.

While trying to do it, the contents of the virtual-scroll area is being wrapped by the mcustomScrollbar elements and hiding it.

Please confirm whether both of this feature could exist together.

ReferenceError: $ is not defined after using angular universal

error :

ERROR ReferenceError: $ is not defined
    at MalihuScrollbarDirective.initElements (/var/www/html/game-ssr/dist/server.js:127055:15)
    at MalihuScrollbarDirective.ngAfterViewInit (/var/www/html/game-ssr/dist/server.js:127046:14)
    at callProviderLifecycles (/var/www/html/game-ssr/dist/server.js:13408:18)
    at callElementProvidersLifecycles (/var/www/html/game-ssr/dist/server.js:13379:13)
    at callLifecycleHooksChildrenFirst (/var/www/html/game-ssr/dist/server.js:13363:17)
    at checkAndUpdateView (/var/www/html/game-ssr/dist/server.js:14496:5)
    at callViewAction (/var/www/html/game-ssr/dist/server.js:14838:21)
    at execComponentViewsAction (/var/www/html/game-ssr/dist/server.js:14770:13)
    at checkAndUpdateView (/var/www/html/game-ssr/dist/server.js:14494:5)
    at callViewAction (/var/www/html/game-ssr/dist/server.js:14838:21)

it shows no error on 'ng serve' and if i run dist.
but shows the above error when run using server side rendering (by angular universal)

my packege.json is

{
  "name": "game",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "webpack-dev-server --port=4200",
    "build": " webpack",
    "test": "karma start ./karma.conf.js",
    "lint": "ng lint",
    "e2e": "protractor ./protractor.conf.js",
    "pree2e": "webdriver-manager update --standalone false --gecko false --quiet",
    "build:universal": "npm run build:client-and-server-bundles && npm run webpack:server",
    "serve:universal": "node dist/server.js",
    "build:client-and-server-bundles": "ng build --prod && ng build --prod --app 1 --output-hashing=false",
    "webpack:server": "webpack --config webpack.server.config.js --progress --colors",
    "compile_ng_circle_progress": "babel node_modules/ng-circle-progress -d node_modules/ng-circle-progress --presets @babel/preset-env",
    "postinstall": "npm run compile_ng_circle_progress"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~5.0.0",
    "@angular/common": "~5.0.0",
    "@angular/compiler": "~5.0.0",
    "@angular/core": "~5.0.0",
    "@angular/forms": "~5.0.0",
    "@angular/http": "~5.0.0",
    "@angular/platform-browser": "~5.0.0",
    "@angular/platform-browser-dynamic": "~5.0.0",
    "@angular/platform-server": "~5.0.0",
    "@angular/router": "~5.0.0",
    "@angular/upgrade": "~5.0.0",
    "@nguniversal/express-engine": "^5.0.0",
    "@nguniversal/module-map-ngfactory-loader": "^5.0.0",
    "@ngx-loading-bar/core": "^1.6.0",
    "@ngx-loading-bar/http-client": "^1.6.0",
    "@ngx-loading-bar/router": "^1.6.0",
    "@ngx-utils/cookies": "^3.0.2",
    "angular-in-memory-web-api": "~0.5.0",
    "angular2-draggable": "^1.4.0",
    "bootstrap": "^4.1.0",
    "cookie-parser": "^1.4.3",
    "core-js": "^2.4.1",
    "jquery": "^3.3.1",
    "localstorage-polyfill": "^1.0.1",
    "ng-circle-progress": "^1.0.0",
    "ngx-cookie-service": "^1.0.10",
    "ngx-malihu-scrollbar": "^1.3.2",
    "ngx-mask": "^2.7.3",
    "ngx-order-pipe": "^2.0.1",
    "ngx-tooltip": "0.0.9",
    "ngx-webstorage": "^2.0.1",
    "popper.js": "^1.14.3",
    "rxjs": "^5.5.0",
    "ts-loader": "^3.1.1",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular-devkit/core": "0.3.2",
    "@angular/cli": "~1.7.3",
    "@angular/compiler-cli": "~5.0.0",
    "@angular/language-service": "~5.0.0",
    "@babel/cli": "^7.1.2",
    "@babel/core": "^7.1.2",
    "@babel/preset-env": "^7.1.0",
    "@ngtools/webpack": "1.10.2",
    "@types/jasmine": "~2.8.0",
    "@types/jasminewd2": "^2.0.3",
    "@types/node": "^6.0.45",
    "autoprefixer": "^7.2.3",
    "circular-dependency-plugin": "^4.2.1",
    "codelyzer": "^4.0.1",
    "copy-webpack-plugin": "~4.4.1",
    "file-loader": "^1.1.5",
    "grunt": "~0.4.5",
    "grunt-contrib-clean": "^1.1.0",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-exec": "^3.0.0",
    "grunt-http": "^2.3.1",
    "grunt-string-replace": "^1.3.1",
    "html-webpack-plugin": "^2.29.0",
    "istanbul-instrumenter-loader": "^3.0.0",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-coverage-istanbul-reporter": "^1.3.3",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-phantomjs-launcher": "^1.0.2",
    "less-loader": "^4.0.5",
    "lodash": "^4.16.2",
    "phantomjs-prebuilt": "^2.1.7",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.10",
    "postcss-url": "^7.1.2",
    "protractor": "~5.1.0",
    "raw-loader": "^0.5.1",
    "sass-loader": "^6.0.6",
    "style-loader": "^0.19.1",
    "stylus-loader": "^3.0.1",
    "ts-node": "^3.3.0",
    "tslint": "^3.15.1",
    "typescript": "2.4.2",
    "uglifyjs-webpack-plugin": "^1.2.7",
    "url-loader": "^0.6.2",
    "webpack": "~3.11.0",
    "webpack-dev-server": "~2.11.0"
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.