!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("rxjs/operators"),require("@angular/core"),require("rxjs"),require("lodash/defaults"),require("lodash/isEqual"),require("@angular/common")):"function"==typeof define&&define.amd?define("ng-gxscrollable",["exports","rxjs/operators","@angular/core","rxjs","lodash/defaults","lodash/isEqual","@angular/common"],e):e(t["ng-gxscrollable"]={},t.rxjs.operators,t.ng.core,t.rxjs,null,null,t.ng.common)}(this,function(t,o,e,n,i,r,s){"use strict";function a(t,e,o,i){var n,r=arguments.length,s=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,i);else for(var a=t.length-1;0<=a;a--)(n=t[a])&&(s=(r<3?n(s):3<r?n(e,o,s):n(e,o))||s);return 3<r&&s&&Object.defineProperty(e,o,s),s}function l(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function c(t){return o.takeWhile((e=t,function(){return e.isDestroyed===undefined||!1===e.isDestroyed()}));var e}function h(t){var e=t.prototype.ngOnDestroy;t.prototype.isDestroyed=function(){return this._isComponentDestroyed!==undefined&&this._isComponentDestroyed},t.prototype.ngOnDestroy=function(){e&&"function"==typeof e&&e.apply(this,arguments),this._isComponentDestroyed=!0}}i=i&&i.hasOwnProperty("default")?i["default"]:i,r=r&&r.hasOwnProperty("default")?r["default"]:r;var p=function(){function t(t){this.cd=t,this.theme="default",this.hideTimeout=300,this.stateUpdated=new n.Subject,this.stateUpdatedRecently=!1}return t.prototype.ngOnInit=function(){var t=this;this.hideTimeout!=undefined&&this.stateUpdated.pipe(o.debounceTime(this.hideTimeout),c(this)).subscribe(function(){t.stateUpdatedRecently=!1,t.cd.detectChanges()})},t.prototype.ngOnDestroy=function(){},t.prototype.ngOnChanges=function(t){var e=this;t.scrollable&&(this.subscription&&this.subscription.unsubscribe(),this.scrollable?this.subscription=this.scrollable.state$.pipe(c(this)).subscribe(function(t){e.state=t,e.stateUpdatedRecently=!0,e.stateUpdated.next(),e.cd.detectChanges()}):this.subscription=undefined)},Object.defineProperty(t.prototype,"visibleVertical",{get:function(){return!(!this.state||!this.state.vertical)&&(100!=this.verticalHeightPercentage&&!!this.stateUpdatedRecently)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"verticalHeightPercentage",{get:function(){var t=this.state.vertical.viewportLength/this.state.vertical.scrollLength*100;return Math.max(t,5)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"verticalTopPercentage",{get:function(){return this.state.vertical.progress*(100-this.verticalHeightPercentage)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"visibleHorizontal",{get:function(){return!(!this.state||!this.state.horizontal)&&(100!=this.horizontalWidthPercentage&&!!this.stateUpdatedRecently)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"horizontalWidthPercentage",{get:function(){var t=this.state.horizontal.viewportLength/this.state.horizontal.scrollLength*100;return Math.max(t,5)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"horizontalLeftPercentage",{get:function(){return this.state.horizontal.progress*(100-this.horizontalWidthPercentage)},enumerable:!0,configurable:!0}),t.decorators=[{type:e.Component,args:[{selector:"gxs-scrollbar",template:'<span class="scrollbar" [ngClass]="[\'scrollbar_theme_\' + theme]">\n  <div *ngIf="state?.vertical"\n       class="scrollbar__track scrollbar__track_position_vertical"\n       [class.scrollbar__track_visible]="visibleVertical">\n    <div class="scrollbar__knob scrollbar__knob_position_vertical"\n         [style.top.%]="verticalTopPercentage"\n         [style.height.%]="verticalHeightPercentage">\n    </div>\n  </div>\n  <div *ngIf="state?.horizontal"\n       class="scrollbar__track scrollbar__track_position_horizontal"\n       [class.scrollbar__track_visible]="visibleHorizontal">\n    <div class="scrollbar__knob scrollbar__knob_position_horizontal"\n         [style.left.%]="horizontalLeftPercentage"\n         [style.width.%]="horizontalWidthPercentage">\n    </div>\n  </div>\n</span>\n',styles:[":host{box-sizing:border-box}:host *,:host ::after,:host ::before{box-sizing:inherit}:host a,:host a:hover,:host a:visited{text-decoration:none}.scrollbar_theme_default .scrollbar__track{position:absolute;background:#ccc;overflow:hidden;opacity:0;transition:opacity .3s ease}.scrollbar_theme_default .scrollbar__track_visible{opacity:1}.scrollbar_theme_default .scrollbar__track_position_vertical{top:0;right:0;bottom:0;width:3px}.scrollbar_theme_default .scrollbar__track_position_horizontal{right:0;bottom:0;left:0;height:3px}.scrollbar_theme_default .scrollbar__knob{position:absolute;top:50%;width:3px;height:10px;background:#000}.scrollbar_theme_default .scrollbar__knob_position_vertical{top:50%;width:3px;height:10px}.scrollbar_theme_default .scrollbar__knob_position_horizontal{left:50%;width:10px;height:3px}"],changeDetection:e.ChangeDetectionStrategy.OnPush}]}],t.ctorParameters=function(){return[{type:e.ChangeDetectorRef}]},t.propDecorators={scrollable:[{type:e.Input}],theme:[{type:e.Input}],hideTimeout:[{type:e.Input}]},t=a([h,l("design:paramtypes",[e.ChangeDetectorRef])],t)}(),u=function(){function t(t){this.el=t,this._state=new n.BehaviorSubject(undefined),this.dragging=!1,this.defaultOptions={vertical:!0,horizontal:!1,stopPropagation:!0,stopPropagationAlways:!1}}return Object.defineProperty(t.prototype,"state",{get:function(){return this._state.value},set:function(t){this._state.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state$",{get:function(){return this._state.asObservable()},enumerable:!0,configurable:!0}),t.prototype.ngOnInit=function(){},t.prototype.ngAfterViewInit=function(){var i=this;n.fromEvent(this.el.nativeElement,"wheel").pipe(c(this)).subscribe(function(t){var e=1,o=1;1==t.deltaMode?e=o=16:2==t.deltaMode&&(e=i.state.horizontal.viewportLength,o=i.state.vertical.viewportLength),i.handleScroll(t.deltaX*e,t.deltaY*o)&&(t.preventDefault(),i.options.stopPropagation&&t.stopPropagation()),i.options.stopPropagationAlways&&(t.preventDefault(),t.stopPropagation())}),n.fromEvent(this.el.nativeElement,"touchstart").pipe(c(this)).subscribe(function(t){i.dragging=!0,i.lastTouch={x:t.touches[0].clientX,y:t.touches[0].clientY}}),n.fromEvent(this.el.nativeElement,"touchmove").pipe(o.filter(function(){return i.dragging}),c(this)).subscribe(function(t){var e={x:t.touches[0].clientX,y:t.touches[0].clientY};i.lastTouch&&i.handleScroll(i.lastTouch.x-e.x,i.lastTouch.y-e.y)&&(t.cancelable&&t.preventDefault(),i.options.stopPropagation&&t.stopPropagation()),i.options.stopPropagationAlways&&(t.preventDefault(),t.stopPropagation()),i.lastTouch=e}),n.merge([n.fromEvent(this.el.nativeElement,"touchend"),n.fromEvent(this.el.nativeElement,"touchcancel")]).pipe(c(this)).subscribe(function(){return i.dragging=!1}),n.fromEvent(this.el.nativeElement,"scroll").pipe(c(this)).subscribe(function(){return i.updateState()}),this.updateState()},t.prototype.ngAfterViewChecked=function(){this.updateState()},Object.defineProperty(t.prototype,"options",{get:function(){return i(this.xsScrollableOptions||{},this.defaultOptions)},enumerable:!0,configurable:!0}),t.prototype.handleScroll=function(t,e){var o=!1;if(this.options.vertical&&!this.options.horizontal&&Math.abs(t)>Math.abs(e))return o;if(!this.options.vertical&&this.options.horizontal&&Math.abs(e)>Math.abs(t))return o;if(this.options.vertical){var i=this.el.nativeElement.scrollTop;this.el.nativeElement.scrollTop+=e,this.el.nativeElement.scrollTop!=i&&(o=!0)}if(this.options.horizontal){i=this.el.nativeElement.scrollLeft;this.el.nativeElement.scrollLeft+=t,this.el.nativeElement.scrollLeft!=i&&(o=!0)}return o},t.prototype.updateState=function(){var t={};this.options.vertical&&(t.vertical={progress:this.el.nativeElement.scrollHeight-this.el.nativeElement.offsetHeight?this.el.nativeElement.scrollTop/(this.el.nativeElement.scrollHeight-this.el.nativeElement.offsetHeight):1,viewportLength:this.el.nativeElement.offsetHeight,scrollLength:this.el.nativeElement.scrollHeight}),this.options.horizontal&&(t.horizontal={progress:this.el.nativeElement.scrollWidth-this.el.nativeElement.offsetWidth?this.el.nativeElement.scrollLeft/(this.el.nativeElement.scrollWidth-this.el.nativeElement.offsetWidth):1,viewportLength:this.el.nativeElement.offsetWidth,scrollLength:this.el.nativeElement.scrollWidth}),r(this.state,t)||(this.state=t)},t.prototype.scrollTo=function(t){this.options.vertical?this.el.nativeElement.scrollTop=t:this.options.horizontal&&(this.el.nativeElement.scrollLeft=t)},t.decorators=[{type:e.Directive,args:[{selector:"[xsScrollable]",exportAs:"scrollableDirective"}]}],t.ctorParameters=function(){return[{type:e.ElementRef}]},t.propDecorators={xsScrollableOptions:[{type:e.Input}]},t=a([h,l("design:paramtypes",[e.ElementRef])],t)}(),f=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[s.CommonModule],declarations:[u,p],exports:[u,p]}]}],t}();t.ScrollbarComponent=p,t.ScrollableDirective=u,t.NgGxScrollableModule=f,t.ɵa=h,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ng-gxscrollable.umd.min.js.map