ngx-slimscroll
Advanced tools
Comparing version 3.3.2 to 3.3.3
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@angular/core"),require("rxjs/Observable"),require("rxjs/add/observable/fromEvent"),require("rxjs/add/observable/merge"),require("rxjs/add/operator/mergeMap"),require("rxjs/add/operator/takeUntil"),require("rxjs/add/operator/map")):"function"==typeof define&&define.amd?define("ngx-slimscroll",["@angular/core","rxjs/Observable","rxjs/add/observable/fromEvent","rxjs/add/observable/merge","rxjs/add/operator/mergeMap","rxjs/add/operator/takeUntil","rxjs/add/operator/map"],t):"object"==typeof exports?exports["ngx-slimscroll"]=t(require("@angular/core"),require("rxjs/Observable"),require("rxjs/add/observable/fromEvent"),require("rxjs/add/observable/merge"),require("rxjs/add/operator/mergeMap"),require("rxjs/add/operator/takeUntil"),require("rxjs/add/operator/map")):e["ngx-slimscroll"]=t(e["@angular/core"],e["rxjs/Observable"],e["rxjs/add/observable/fromEvent"],e["rxjs/add/observable/merge"],e["rxjs/add/operator/mergeMap"],e["rxjs/add/operator/takeUntil"],e["rxjs/add/operator/map"])}(this,function(e,t,r,i,n,o,s){return function(e){function t(i){if(r[i])return r[i].exports;var n=r[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,i){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=2)}([function(t,r){t.exports=e},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var i=function(){function e(e){this.position=e&&e.position?e.position:"right",this.barBackground=e&&e.barBackground?e.barBackground:"#343a40",this.barOpacity=e&&e.barOpacity?e.barOpacity:"1",this.barWidth=e&&e.barWidth?e.barWidth:"12",this.barBorderRadius=e&&e.barBorderRadius?e.barBorderRadius:"5",this.barMargin=e&&e.barMargin?e.barMargin:"1px 0",this.gridBackground=e&&e.gridBackground?e.gridBackground:"#adb5bd",this.gridOpacity=e&&e.gridOpacity?e.gridOpacity:"1",this.gridWidth=e&&e.gridWidth?e.gridWidth:"8",this.gridBorderRadius=e&&e.gridBorderRadius?e.gridBorderRadius:"10",this.gridMargin=e&&e.gridMargin?e.gridMargin:"1px 2px",this.alwaysVisible=!e||void 0===e.alwaysVisible||e.alwaysVisible,this.visibleTimeout=e&&e.visibleTimeout?e.visibleTimeout:1e3}return e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(3);r.d(t,"NgSlimScrollModule",function(){return i.a});var n=r(1);r.d(t,"SlimScrollOptions",function(){return n.a});var o=r(11);r.d(t,"SlimScrollEvent",function(){return o.a})},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var i=r(0),n=(r.n(i),r(4)),o=function(){function e(){}return e.decorators=[{type:i.NgModule,args:[{declarations:[n.a],exports:[n.a]}]}],e.ctorParameters=function(){return[]},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return h});var i=r(0),n=(r.n(i),r(1)),o=r(5),s=(r.n(o),r(6)),l=(r.n(s),r(7)),a=(r.n(l),r(8)),d=(r.n(a),r(9)),u=(r.n(d),r(10)),p=(r.n(u),{linear:function(e){return e},inQuad:function(e){return e*e},outQuad:function(e){return e*(2-e)},inOutQuad:function(e){return e<.5?2*e*e:(4-2*e)*e-1},inCubic:function(e){return e*e*e},outCubic:function(e){return--e*e*e+1},inOutCubic:function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},inQuart:function(e){return e*e*e*e},outQuart:function(e){return 1- --e*e*e*e},inOutQuart:function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},inQuint:function(e){return e*e*e*e*e},outQuint:function(e){return 1+--e*e*e*e*e},inOutQuint:function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e}}),h=function(){function e(e,t){var r=this;this.viewContainer=e,this.renderer=t,this.initWheel=function(){var e=o.Observable.fromEvent(r.el,"DOMMouseScroll"),t=o.Observable.fromEvent(r.el,"mousewheel");o.Observable.merge.apply(o.Observable,[e,t]).subscribe(function(e){var t=0;e.wheelDelta&&(t=-e.wheelDelta/120),e.detail&&(t=e.detail/3),r.scrollContent(t,!0,!1),e.preventDefault&&e.preventDefault()})},this.initDrag=function(){var e=r.bar,t=o.Observable.fromEvent(document.documentElement,"mousemove"),i=o.Observable.fromEvent(document.documentElement,"touchmove"),n=o.Observable.fromEvent(e,"mousedown"),s=o.Observable.fromEvent(r.el,"touchstart"),l=o.Observable.fromEvent(document.documentElement,"mouseup"),a=o.Observable.fromEvent(document.documentElement,"touchend"),d=n.mergeMap(function(i){return r.pageY=i.pageY,r.top=parseFloat(getComputedStyle(e).top),t.map(function(e){return e.preventDefault(),r.top+e.pageY-r.pageY}).takeUntil(l)}),u=s.mergeMap(function(t){return r.pageY=t.targetTouches[0].pageY,r.top=-parseFloat(getComputedStyle(e).top),i.map(function(e){return-(r.top+e.targetTouches[0].pageY-r.pageY)}).takeUntil(a)});o.Observable.merge.apply(o.Observable,[d,u]).subscribe(function(e){r.body.addEventListener("selectstart",r.preventDefaultEvent,!1),r.renderer.setElementStyle(r.body,"touch-action","pan-y"),r.renderer.setElementStyle(r.body,"user-select","none"),r.renderer.setElementStyle(r.bar,"top",e+"px");var t=r.scrollContent(0,!0,!1),i=r.el.offsetHeight-r.bar.offsetHeight;t&&t<0&&-t<=i?r.renderer.setElementStyle(r.el,"paddingTop",-t+"px"):t&&t>0&&t<=i&&r.renderer.setElementStyle(r.el,"paddingBottom",t+"px")}),o.Observable.merge.apply(o.Observable,[l,a]).subscribe(function(){r.body.removeEventListener("selectstart",r.preventDefaultEvent,!1);var e=parseInt(r.el.style.paddingTop,10),t=parseInt(r.el.style.paddingBottom,10);r.renderer.setElementStyle(r.body,"touch-action","unset"),r.renderer.setElementStyle(r.body,"user-select","default"),e>0?r.scrollTo(0,300,"linear"):t>0&&r.scrollTo(0,300,"linear")})},this.preventDefaultEvent=function(e){e.preventDefault(),e.stopPropagation()},"undefined"!=typeof window&&(this.viewContainer=e,this.el=e.element.nativeElement,this.body=document.documentElement.querySelector("body"),this.mutationThrottleTimeout=50)}return e.prototype.ngOnInit=function(){var e=this;"undefined"!=typeof window&&(this.options=new n.a(this.options),this.destroy(),this.setElementStyle(),this.wrapContainer(),this.initGrid(),this.initBar(),this.getBarHeight(),this.initWheel(),this.initDrag(),this.options.alwaysVisible||this.hideBarAndGrid(),MutationObserver&&(this.mutationObserver=new MutationObserver(function(){e.mutationThrottleTimeout&&(clearTimeout(e.mutationThrottleTimeout),e.mutationThrottleTimeout=setTimeout(e.onMutation.bind(e),50))}),this.mutationObserver.observe(this.el,{subtree:!0,childList:!0})),this.scrollEvents&&this.scrollEvents instanceof i.EventEmitter&&this.scrollEvents.subscribe(function(t){return e.handleEvent(t)}))},e.prototype.handleEvent=function(e){if("scrollToBottom"===e.type){var t=this.el.scrollHeight-this.el.clientHeight;this.scrollTo(t,e.duration,e.easing)}else if("scrollToTop"===e.type){var t=0;this.scrollTo(t,e.duration,e.easing)}else if("scrollToPercent"===e.type&&e.percent>=0&&e.percent<=100){var t=Math.round((this.el.scrollHeight-this.el.clientHeight)/100*e.percent);this.scrollTo(t,e.duration,e.easing)}else if("scrollTo"===e.type){var t=e.y;t<=this.el.scrollHeight-this.el.clientHeight&&t>=0&&this.scrollTo(t,e.duration,e.easing)}else"recalculate"===e.type&&this.getBarHeight()},e.prototype.setElementStyle=function(){var e=this.el;this.renderer.setElementStyle(e,"overflow","hidden"),this.renderer.setElementStyle(e,"position","relative"),this.renderer.setElementStyle(e,"display","block")},e.prototype.onMutation=function(){this.getBarHeight()},e.prototype.wrapContainer=function(){this.wrapper=document.createElement("div");var e=this.wrapper,t=this.el;this.renderer.setElementClass(e,"slimscroll-wrapper",!0),this.renderer.setElementStyle(e,"position","relative"),this.renderer.setElementStyle(e,"overflow","hidden"),this.renderer.setElementStyle(e,"display","inline-block"),this.renderer.setElementStyle(e,"margin",getComputedStyle(t).margin),this.renderer.setElementStyle(e,"width","100%"),this.renderer.setElementStyle(e,"height",getComputedStyle(t).height),t.parentNode.insertBefore(e,t),e.appendChild(t)},e.prototype.initGrid=function(){this.grid=document.createElement("div");var e=this.grid;this.renderer.setElementClass(e,"slimscroll-grid",!0),this.renderer.setElementStyle(e,"position","absolute"),this.renderer.setElementStyle(e,"top","0"),this.renderer.setElementStyle(e,"bottom","0"),this.renderer.setElementStyle(e,this.options.position,"0"),this.renderer.setElementStyle(e,"width",this.options.gridWidth+"px"),this.renderer.setElementStyle(e,"background",this.options.gridBackground),this.renderer.setElementStyle(e,"opacity",this.options.gridOpacity),this.renderer.setElementStyle(e,"display","block"),this.renderer.setElementStyle(e,"cursor","pointer"),this.renderer.setElementStyle(e,"z-index","99"),this.renderer.setElementStyle(e,"border-radius",this.options.gridBorderRadius+"px"),this.renderer.setElementStyle(e,"margin",this.options.gridMargin),this.wrapper.appendChild(e)},e.prototype.initBar=function(){this.bar=document.createElement("div");var e=this.bar;this.renderer.setElementClass(e,"slimscroll-bar",!0),this.renderer.setElementStyle(e,"position","absolute"),this.renderer.setElementStyle(e,"top","0"),this.renderer.setElementStyle(e,this.options.position,"0"),this.renderer.setElementStyle(e,"width",this.options.barWidth+"px"),this.renderer.setElementStyle(e,"background",this.options.barBackground),this.renderer.setElementStyle(e,"opacity",this.options.barOpacity),this.renderer.setElementStyle(e,"display","block"),this.renderer.setElementStyle(e,"cursor","pointer"),this.renderer.setElementStyle(e,"z-index","100"),this.renderer.setElementStyle(e,"border-radius",this.options.barBorderRadius+"px"),this.renderer.setElementStyle(e,"margin",this.options.barMargin),this.wrapper.appendChild(e)},e.prototype.getBarHeight=function(){var e=this;setTimeout(function(){var t=Math.max(e.el.offsetHeight/e.el.scrollHeight*e.el.offsetHeight,30)+"px",r=parseInt(t,10)===e.el.offsetHeight?"none":"block";e.renderer.setElementStyle(e.bar,"height",t),e.renderer.setElementStyle(e.bar,"display",r),e.renderer.setElementStyle(e.grid,"display",r)})},e.prototype.scrollTo=function(e,t,r){var i=this,n=Date.now(),o=this.el.scrollTop,s=(this.el.offsetHeight,this.bar.offsetHeight,this.el.scrollHeight-this.el.clientHeight),l=Math.max(this.el.offsetHeight/this.el.scrollHeight*this.el.offsetHeight,30),a=parseInt(this.el.style.paddingTop,10)||0,d=parseInt(this.el.style.paddingBottom,10)||0,u=function(h){var c=Date.now(),m=Math.min(1,(c-n)/t),f=p[r](m);if(a>0||d>0){var g=null;a>0&&(g=-a,g=-(f*(e-g)+g),i.renderer.setElementStyle(i.el,"paddingTop",g+"px")),d>0&&(g=d,g=f*(e-g)+g,i.renderer.setElementStyle(i.el,"paddingBottom",g+"px"))}else i.el.scrollTop=f*(e-o)+o;var b=i.el.scrollTop/s;if(0===d){var y=Math.round(Math.round(i.el.clientHeight*b)-l);y>0&&i.renderer.setElementStyle(i.bar,"top",y+"px")}m<1&&requestAnimationFrame(u)};requestAnimationFrame(u)},e.prototype.scrollContent=function(e,t,r){var i,n=this,o=e,s=this.el.offsetHeight-this.bar.offsetHeight,l=this.bar,a=(this.grid,this.el),d=null;return t&&(o=parseInt(getComputedStyle(l).top,10)+20*e/100*l.offsetHeight,(o<0||o>s)&&(d=o>s?o-s:o),o=Math.min(Math.max(o,0),s),o=e>0?Math.ceil(o):Math.floor(o),this.renderer.setElementStyle(l,"top",o+"px")),i=parseInt(getComputedStyle(l).top,10)/(a.offsetHeight-l.offsetHeight),o=i*(a.scrollHeight-a.offsetHeight),a.scrollTop=o,this.showBarAndGrid(),this.options.alwaysVisible||(this.visibleTimeout&&clearTimeout(this.visibleTimeout),this.visibleTimeout=setTimeout(function(){n.hideBarAndGrid()},this.options.visibleTimeout)),d},e.prototype.showBarAndGrid=function(){this.renderer.setElementStyle(this.grid,"background",this.options.gridBackground),this.renderer.setElementStyle(this.bar,"background",this.options.barBackground)},e.prototype.hideBarAndGrid=function(){this.renderer.setElementStyle(this.grid,"background","transparent"),this.renderer.setElementStyle(this.bar,"background","transparent")},e.prototype.destroy=function(){if(this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.el.parentElement.classList.contains("slimscroll-wrapper")){var e=this.el.parentElement,t=this.el.querySelector(".slimscroll-bar");this.el.removeChild(t),this.unwrap(e)}},e.prototype.unwrap=function(e){for(var t=document.createDocumentFragment();e.firstChild;){var r=e.removeChild(e.firstChild);t.appendChild(r)}e.parentNode.replaceChild(t,e)},e.prototype.onResize=function(e){this.getBarHeight()},e.decorators=[{type:i.Directive,args:[{selector:"[slimScroll]",exportAs:"slimScroll"}]}],e.ctorParameters=function(){return[{type:i.ViewContainerRef,decorators:[{type:i.Inject,args:[i.ViewContainerRef]}]},{type:i.Renderer,decorators:[{type:i.Inject,args:[i.Renderer]}]}]},e.propDecorators={options:[{type:i.Input}],scrollEvents:[{type:i.Input}],onResize:[{type:i.HostListener,args:["window:resize",["$event"]]}]},e}()},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=i},function(e,t){e.exports=n},function(e,t){e.exports=o},function(e,t){e.exports=s},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var i=function(){function e(e){this.type=e.type,this.y=e&&e.y?e.y:0,this.percent=e&&e.percent?e.percent:0,this.duration=e&&e.duration?e.duration:0,this.easing=e&&e.easing?e.easing:"linear"}return e}()}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@angular/core"),require("rxjs/Observable"),require("rxjs/add/observable/fromEvent"),require("rxjs/add/observable/merge"),require("rxjs/add/operator/mergeMap"),require("rxjs/add/operator/takeUntil"),require("rxjs/add/operator/map")):"function"==typeof define&&define.amd?define("ngx-slimscroll",["@angular/core","rxjs/Observable","rxjs/add/observable/fromEvent","rxjs/add/observable/merge","rxjs/add/operator/mergeMap","rxjs/add/operator/takeUntil","rxjs/add/operator/map"],t):"object"==typeof exports?exports["ngx-slimscroll"]=t(require("@angular/core"),require("rxjs/Observable"),require("rxjs/add/observable/fromEvent"),require("rxjs/add/observable/merge"),require("rxjs/add/operator/mergeMap"),require("rxjs/add/operator/takeUntil"),require("rxjs/add/operator/map")):e["ngx-slimscroll"]=t(e["@angular/core"],e["rxjs/Observable"],e["rxjs/add/observable/fromEvent"],e["rxjs/add/observable/merge"],e["rxjs/add/operator/mergeMap"],e["rxjs/add/operator/takeUntil"],e["rxjs/add/operator/map"])}(this,function(e,t,r,i,n,o,s){return function(e){function t(i){if(r[i])return r[i].exports;var n=r[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,i){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=2)}([function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.position=e&&e.position?e.position:"right",this.barBackground=e&&e.barBackground?e.barBackground:"#343a40",this.barOpacity=e&&e.barOpacity?e.barOpacity:"1",this.barWidth=e&&e.barWidth?e.barWidth:"12",this.barBorderRadius=e&&e.barBorderRadius?e.barBorderRadius:"5",this.barMargin=e&&e.barMargin?e.barMargin:"1px 0",this.gridBackground=e&&e.gridBackground?e.gridBackground:"#adb5bd",this.gridOpacity=e&&e.gridOpacity?e.gridOpacity:"1",this.gridWidth=e&&e.gridWidth?e.gridWidth:"8",this.gridBorderRadius=e&&e.gridBorderRadius?e.gridBorderRadius:"10",this.gridMargin=e&&e.gridMargin?e.gridMargin:"1px 2px",this.alwaysVisible=!e||void 0===e.alwaysVisible||e.alwaysVisible,this.visibleTimeout=e&&e.visibleTimeout?e.visibleTimeout:1e3}return e}();t.SlimScrollOptions=i},function(e,t,r){"use strict";function i(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0});var n=r(3);t.NgSlimScrollModule=n.NgSlimScrollModule,i(r(1)),i(r(11))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(4),o=function(){function e(){}return e.decorators=[{type:i.NgModule,args:[{declarations:[n.SlimScrollDirective],exports:[n.SlimScrollDirective]}]}],e.ctorParameters=function(){return[]},e}();t.NgSlimScrollModule=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),o=r(5);r(6),r(7),r(8),r(9),r(10),t.easing={linear:function(e){return e},inQuad:function(e){return e*e},outQuad:function(e){return e*(2-e)},inOutQuad:function(e){return e<.5?2*e*e:(4-2*e)*e-1},inCubic:function(e){return e*e*e},outCubic:function(e){return--e*e*e+1},inOutCubic:function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},inQuart:function(e){return e*e*e*e},outQuart:function(e){return 1- --e*e*e*e},inOutQuart:function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},inQuint:function(e){return e*e*e*e*e},outQuint:function(e){return 1+--e*e*e*e*e},inOutQuint:function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e}};var s=function(){function e(e,t){var r=this;this.viewContainer=e,this.renderer=t,this.initWheel=function(){var e=o.Observable.fromEvent(r.el,"DOMMouseScroll"),t=o.Observable.fromEvent(r.el,"mousewheel");o.Observable.merge.apply(o.Observable,[e,t]).subscribe(function(e){var t=0;e.wheelDelta&&(t=-e.wheelDelta/120),e.detail&&(t=e.detail/3),r.scrollContent(t,!0,!1),e.preventDefault&&e.preventDefault()})},this.initDrag=function(){var e=r.bar,t=o.Observable.fromEvent(document.documentElement,"mousemove"),i=o.Observable.fromEvent(document.documentElement,"touchmove"),n=o.Observable.fromEvent(e,"mousedown"),s=o.Observable.fromEvent(r.el,"touchstart"),l=o.Observable.fromEvent(document.documentElement,"mouseup"),a=o.Observable.fromEvent(document.documentElement,"touchend"),d=n.mergeMap(function(i){return r.pageY=i.pageY,r.top=parseFloat(getComputedStyle(e).top),t.map(function(e){return e.preventDefault(),r.top+e.pageY-r.pageY}).takeUntil(l)}),u=s.mergeMap(function(t){return r.pageY=t.targetTouches[0].pageY,r.top=-parseFloat(getComputedStyle(e).top),i.map(function(e){return-(r.top+e.targetTouches[0].pageY-r.pageY)}).takeUntil(a)});o.Observable.merge.apply(o.Observable,[d,u]).subscribe(function(e){r.body.addEventListener("selectstart",r.preventDefaultEvent,!1),r.renderer.setElementStyle(r.body,"touch-action","pan-y"),r.renderer.setElementStyle(r.body,"user-select","none"),r.renderer.setElementStyle(r.bar,"top",e+"px");var t=r.scrollContent(0,!0,!1),i=r.el.offsetHeight-r.bar.offsetHeight;t&&t<0&&-t<=i?r.renderer.setElementStyle(r.el,"paddingTop",-t+"px"):t&&t>0&&t<=i&&r.renderer.setElementStyle(r.el,"paddingBottom",t+"px")}),o.Observable.merge.apply(o.Observable,[l,a]).subscribe(function(){r.body.removeEventListener("selectstart",r.preventDefaultEvent,!1);var e=parseInt(r.el.style.paddingTop,10),t=parseInt(r.el.style.paddingBottom,10);r.renderer.setElementStyle(r.body,"touch-action","unset"),r.renderer.setElementStyle(r.body,"user-select","default"),e>0?r.scrollTo(0,300,"linear"):t>0&&r.scrollTo(0,300,"linear")})},this.preventDefaultEvent=function(e){e.preventDefault(),e.stopPropagation()},"undefined"!=typeof window&&(this.viewContainer=e,this.el=e.element.nativeElement,this.body=document.documentElement.querySelector("body"),this.mutationThrottleTimeout=50)}return e.prototype.ngOnInit=function(){var e=this;"undefined"!=typeof window&&(this.options=new n.SlimScrollOptions(this.options),this.destroy(),this.setElementStyle(),this.wrapContainer(),this.initGrid(),this.initBar(),this.getBarHeight(),this.initWheel(),this.initDrag(),this.options.alwaysVisible||this.hideBarAndGrid(),MutationObserver&&(this.mutationObserver=new MutationObserver(function(){e.mutationThrottleTimeout&&(clearTimeout(e.mutationThrottleTimeout),e.mutationThrottleTimeout=setTimeout(e.onMutation.bind(e),50))}),this.mutationObserver.observe(this.el,{subtree:!0,childList:!0})),this.scrollEvents&&this.scrollEvents instanceof i.EventEmitter&&this.scrollEvents.subscribe(function(t){return e.handleEvent(t)}))},e.prototype.handleEvent=function(e){if("scrollToBottom"===e.type){var t=this.el.scrollHeight-this.el.clientHeight;this.scrollTo(t,e.duration,e.easing)}else if("scrollToTop"===e.type){var t=0;this.scrollTo(t,e.duration,e.easing)}else if("scrollToPercent"===e.type&&e.percent>=0&&e.percent<=100){var t=Math.round((this.el.scrollHeight-this.el.clientHeight)/100*e.percent);this.scrollTo(t,e.duration,e.easing)}else if("scrollTo"===e.type){var t=e.y;t<=this.el.scrollHeight-this.el.clientHeight&&t>=0&&this.scrollTo(t,e.duration,e.easing)}else"recalculate"===e.type&&this.getBarHeight()},e.prototype.setElementStyle=function(){var e=this.el;this.renderer.setElementStyle(e,"overflow","hidden"),this.renderer.setElementStyle(e,"position","relative"),this.renderer.setElementStyle(e,"display","block")},e.prototype.onMutation=function(){this.getBarHeight()},e.prototype.wrapContainer=function(){this.wrapper=document.createElement("div");var e=this.wrapper,t=this.el;this.renderer.setElementClass(e,"slimscroll-wrapper",!0),this.renderer.setElementStyle(e,"position","relative"),this.renderer.setElementStyle(e,"overflow","hidden"),this.renderer.setElementStyle(e,"display","inline-block"),this.renderer.setElementStyle(e,"margin",getComputedStyle(t).margin),this.renderer.setElementStyle(e,"width","100%"),this.renderer.setElementStyle(e,"height",getComputedStyle(t).height),t.parentNode.insertBefore(e,t),e.appendChild(t)},e.prototype.initGrid=function(){this.grid=document.createElement("div");var e=this.grid;this.renderer.setElementClass(e,"slimscroll-grid",!0),this.renderer.setElementStyle(e,"position","absolute"),this.renderer.setElementStyle(e,"top","0"),this.renderer.setElementStyle(e,"bottom","0"),this.renderer.setElementStyle(e,this.options.position,"0"),this.renderer.setElementStyle(e,"width",this.options.gridWidth+"px"),this.renderer.setElementStyle(e,"background",this.options.gridBackground),this.renderer.setElementStyle(e,"opacity",this.options.gridOpacity),this.renderer.setElementStyle(e,"display","block"),this.renderer.setElementStyle(e,"cursor","pointer"),this.renderer.setElementStyle(e,"z-index","99"),this.renderer.setElementStyle(e,"border-radius",this.options.gridBorderRadius+"px"),this.renderer.setElementStyle(e,"margin",this.options.gridMargin),this.wrapper.appendChild(e)},e.prototype.initBar=function(){this.bar=document.createElement("div");var e=this.bar;this.renderer.setElementClass(e,"slimscroll-bar",!0),this.renderer.setElementStyle(e,"position","absolute"),this.renderer.setElementStyle(e,"top","0"),this.renderer.setElementStyle(e,this.options.position,"0"),this.renderer.setElementStyle(e,"width",this.options.barWidth+"px"),this.renderer.setElementStyle(e,"background",this.options.barBackground),this.renderer.setElementStyle(e,"opacity",this.options.barOpacity),this.renderer.setElementStyle(e,"display","block"),this.renderer.setElementStyle(e,"cursor","pointer"),this.renderer.setElementStyle(e,"z-index","100"),this.renderer.setElementStyle(e,"border-radius",this.options.barBorderRadius+"px"),this.renderer.setElementStyle(e,"margin",this.options.barMargin),this.wrapper.appendChild(e)},e.prototype.getBarHeight=function(){var e=this;setTimeout(function(){var t=Math.max(e.el.offsetHeight/e.el.scrollHeight*e.el.offsetHeight,30)+"px",r=parseInt(t,10)===e.el.offsetHeight?"none":"block";e.renderer.setElementStyle(e.bar,"height",t),e.renderer.setElementStyle(e.bar,"display",r),e.renderer.setElementStyle(e.grid,"display",r)})},e.prototype.scrollTo=function(e,r,i){var n=this,o=Date.now(),s=this.el.scrollTop,l=(this.el.offsetHeight,this.bar.offsetHeight,this.el.scrollHeight-this.el.clientHeight),a=Math.max(this.el.offsetHeight/this.el.scrollHeight*this.el.offsetHeight,30),d=parseInt(this.el.style.paddingTop,10)||0,u=parseInt(this.el.style.paddingBottom,10)||0,p=function(c){var h=Date.now(),m=Math.min(1,(h-o)/r),g=t.easing[i](m);if(d>0||u>0){var f=null;d>0&&(f=-d,f=-(g*(e-f)+f),n.renderer.setElementStyle(n.el,"paddingTop",f+"px")),u>0&&(f=u,f=g*(e-f)+f,n.renderer.setElementStyle(n.el,"paddingBottom",f+"px"))}else n.el.scrollTop=g*(e-s)+s;var b=n.el.scrollTop/l;if(0===u){var y=Math.round(Math.round(n.el.clientHeight*b)-a);y>0&&n.renderer.setElementStyle(n.bar,"top",y+"px")}m<1&&requestAnimationFrame(p)};requestAnimationFrame(p)},e.prototype.scrollContent=function(e,t,r){var i,n=this,o=e,s=this.el.offsetHeight-this.bar.offsetHeight,l=this.bar,a=(this.grid,this.el),d=null;return t&&(o=parseInt(getComputedStyle(l).top,10)+20*e/100*l.offsetHeight,(o<0||o>s)&&(d=o>s?o-s:o),o=Math.min(Math.max(o,0),s),o=e>0?Math.ceil(o):Math.floor(o),this.renderer.setElementStyle(l,"top",o+"px")),i=parseInt(getComputedStyle(l).top,10)/(a.offsetHeight-l.offsetHeight),o=i*(a.scrollHeight-a.offsetHeight),a.scrollTop=o,this.showBarAndGrid(),this.options.alwaysVisible||(this.visibleTimeout&&clearTimeout(this.visibleTimeout),this.visibleTimeout=setTimeout(function(){n.hideBarAndGrid()},this.options.visibleTimeout)),d},e.prototype.showBarAndGrid=function(){this.renderer.setElementStyle(this.grid,"background",this.options.gridBackground),this.renderer.setElementStyle(this.bar,"background",this.options.barBackground)},e.prototype.hideBarAndGrid=function(){this.renderer.setElementStyle(this.grid,"background","transparent"),this.renderer.setElementStyle(this.bar,"background","transparent")},e.prototype.destroy=function(){if(this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.el.parentElement.classList.contains("slimscroll-wrapper")){var e=this.el.parentElement,t=this.el.querySelector(".slimscroll-bar");this.el.removeChild(t),this.unwrap(e)}},e.prototype.unwrap=function(e){for(var t=document.createDocumentFragment();e.firstChild;){var r=e.removeChild(e.firstChild);t.appendChild(r)}e.parentNode.replaceChild(t,e)},e.prototype.onResize=function(e){this.getBarHeight()},e.decorators=[{type:i.Directive,args:[{selector:"[slimScroll]",exportAs:"slimScroll"}]}],e.ctorParameters=function(){return[{type:i.ViewContainerRef,decorators:[{type:i.Inject,args:[i.ViewContainerRef]}]},{type:i.Renderer,decorators:[{type:i.Inject,args:[i.Renderer]}]}]},e.propDecorators={options:[{type:i.Input}],scrollEvents:[{type:i.Input}],onResize:[{type:i.HostListener,args:["window:resize",["$event"]]}]},e}();t.SlimScrollDirective=s},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=i},function(e,t){e.exports=n},function(e,t){e.exports=o},function(e,t){e.exports=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.type=e.type,this.y=e&&e.y?e.y:0,this.percent=e&&e.percent?e.percent:0,this.duration=e&&e.duration?e.duration:0,this.easing=e&&e.easing?e.easing:"linear"}return e}();t.SlimScrollEvent=i}])}); | ||
//# sourceMappingURL=ngx-slimscroll.umd.js.map |
@@ -1,3 +0,9 @@ | ||
export { NgSlimScrollModule } from './src/ngx-slimscroll/module/ngx-slimscroll.module'; | ||
export * from './src/ngx-slimscroll/classes/slimscroll-options.class'; | ||
export * from './src/ngx-slimscroll/classes/slimscroll-event.class'; | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ngx_slimscroll_module_1 = require("./src/ngx-slimscroll/module/ngx-slimscroll.module"); | ||
exports.NgSlimScrollModule = ngx_slimscroll_module_1.NgSlimScrollModule; | ||
__export(require("./src/ngx-slimscroll/classes/slimscroll-options.class")); | ||
__export(require("./src/ngx-slimscroll/classes/slimscroll-event.class")); |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var SlimScrollEvent = (function () { | ||
@@ -11,2 +13,2 @@ function SlimScrollEvent(obj) { | ||
}()); | ||
export { SlimScrollEvent }; | ||
exports.SlimScrollEvent = SlimScrollEvent; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var SlimScrollOptions = (function () { | ||
@@ -19,2 +21,2 @@ function SlimScrollOptions(obj) { | ||
}()); | ||
export { SlimScrollOptions }; | ||
exports.SlimScrollOptions = SlimScrollOptions; |
@@ -1,10 +0,12 @@ | ||
import { Directive, ViewContainerRef, HostListener, Renderer, Inject, Input, EventEmitter } from '@angular/core'; | ||
import { SlimScrollOptions } from '../classes/slimscroll-options.class'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import 'rxjs/add/observable/fromEvent'; | ||
import 'rxjs/add/observable/merge'; | ||
import 'rxjs/add/operator/mergeMap'; | ||
import 'rxjs/add/operator/takeUntil'; | ||
import 'rxjs/add/operator/map'; | ||
export var easing = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@angular/core"); | ||
var slimscroll_options_class_1 = require("../classes/slimscroll-options.class"); | ||
var Observable_1 = require("rxjs/Observable"); | ||
require("rxjs/add/observable/fromEvent"); | ||
require("rxjs/add/observable/merge"); | ||
require("rxjs/add/operator/mergeMap"); | ||
require("rxjs/add/operator/takeUntil"); | ||
require("rxjs/add/operator/map"); | ||
exports.easing = { | ||
linear: function (t) { return t; }, | ||
@@ -30,5 +32,5 @@ inQuad: function (t) { return t * t; }, | ||
this.initWheel = function () { | ||
var dommousescroll = Observable.fromEvent(_this.el, 'DOMMouseScroll'); | ||
var mousewheel = Observable.fromEvent(_this.el, 'mousewheel'); | ||
Observable.merge.apply(Observable, [dommousescroll, mousewheel]).subscribe(function (e) { | ||
var dommousescroll = Observable_1.Observable.fromEvent(_this.el, 'DOMMouseScroll'); | ||
var mousewheel = Observable_1.Observable.fromEvent(_this.el, 'mousewheel'); | ||
Observable_1.Observable.merge.apply(Observable_1.Observable, [dommousescroll, mousewheel]).subscribe(function (e) { | ||
var delta = 0; | ||
@@ -49,8 +51,8 @@ if (e.wheelDelta) { | ||
var bar = _this.bar; | ||
var mousemove = Observable.fromEvent(document.documentElement, 'mousemove'); | ||
var touchmove = Observable.fromEvent(document.documentElement, 'touchmove'); | ||
var mousedown = Observable.fromEvent(bar, 'mousedown'); | ||
var touchstart = Observable.fromEvent(_this.el, 'touchstart'); | ||
var mouseup = Observable.fromEvent(document.documentElement, 'mouseup'); | ||
var touchend = Observable.fromEvent(document.documentElement, 'touchend'); | ||
var mousemove = Observable_1.Observable.fromEvent(document.documentElement, 'mousemove'); | ||
var touchmove = Observable_1.Observable.fromEvent(document.documentElement, 'touchmove'); | ||
var mousedown = Observable_1.Observable.fromEvent(bar, 'mousedown'); | ||
var touchstart = Observable_1.Observable.fromEvent(_this.el, 'touchstart'); | ||
var mouseup = Observable_1.Observable.fromEvent(document.documentElement, 'mouseup'); | ||
var touchend = Observable_1.Observable.fromEvent(document.documentElement, 'touchend'); | ||
var mousedrag = mousedown.mergeMap(function (e) { | ||
@@ -71,3 +73,3 @@ _this.pageY = e.pageY; | ||
}); | ||
Observable.merge.apply(Observable, [mousedrag, touchdrag]).subscribe(function (top) { | ||
Observable_1.Observable.merge.apply(Observable_1.Observable, [mousedrag, touchdrag]).subscribe(function (top) { | ||
_this.body.addEventListener('selectstart', _this.preventDefaultEvent, false); | ||
@@ -86,3 +88,3 @@ _this.renderer.setElementStyle(_this.body, 'touch-action', 'pan-y'); | ||
}); | ||
Observable.merge.apply(Observable, [mouseup, touchend]).subscribe(function () { | ||
Observable_1.Observable.merge.apply(Observable_1.Observable, [mouseup, touchend]).subscribe(function () { | ||
_this.body.removeEventListener('selectstart', _this.preventDefaultEvent, false); | ||
@@ -118,3 +120,3 @@ var paddingTop = parseInt(_this.el.style.paddingTop, 10); | ||
} | ||
this.options = new SlimScrollOptions(this.options); | ||
this.options = new slimscroll_options_class_1.SlimScrollOptions(this.options); | ||
this.destroy(); | ||
@@ -140,3 +142,3 @@ this.setElementStyle(); | ||
} | ||
if (this.scrollEvents && this.scrollEvents instanceof EventEmitter) { | ||
if (this.scrollEvents && this.scrollEvents instanceof core_1.EventEmitter) { | ||
this.scrollEvents.subscribe(function (event) { return _this.handleEvent(event); }); | ||
@@ -248,3 +250,3 @@ } | ||
var time = Math.min(1, ((currentTime - start) / duration)); | ||
var easedTime = easing[easingFunc](time); | ||
var easedTime = exports.easing[easingFunc](time); | ||
if (paddingTop > 0 || paddingBottom > 0) { | ||
@@ -343,3 +345,3 @@ var fromY = null; | ||
SlimScrollDirective.decorators = [ | ||
{ type: Directive, args: [{ | ||
{ type: core_1.Directive, args: [{ | ||
selector: '[slimScroll]', | ||
@@ -351,12 +353,12 @@ exportAs: 'slimScroll' | ||
SlimScrollDirective.ctorParameters = function () { return [ | ||
{ type: ViewContainerRef, decorators: [{ type: Inject, args: [ViewContainerRef,] },] }, | ||
{ type: Renderer, decorators: [{ type: Inject, args: [Renderer,] },] }, | ||
{ type: core_1.ViewContainerRef, decorators: [{ type: core_1.Inject, args: [core_1.ViewContainerRef,] },] }, | ||
{ type: core_1.Renderer, decorators: [{ type: core_1.Inject, args: [core_1.Renderer,] },] }, | ||
]; }; | ||
SlimScrollDirective.propDecorators = { | ||
'options': [{ type: Input },], | ||
'scrollEvents': [{ type: Input },], | ||
'onResize': [{ type: HostListener, args: ['window:resize', ['$event'],] },], | ||
'options': [{ type: core_1.Input },], | ||
'scrollEvents': [{ type: core_1.Input },], | ||
'onResize': [{ type: core_1.HostListener, args: ['window:resize', ['$event'],] },], | ||
}; | ||
return SlimScrollDirective; | ||
}()); | ||
export { SlimScrollDirective }; | ||
exports.SlimScrollDirective = SlimScrollDirective; |
@@ -1,3 +0,5 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { SlimScrollDirective } from '../directives/slimscroll.directive'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@angular/core"); | ||
var slimscroll_directive_1 = require("../directives/slimscroll.directive"); | ||
var NgSlimScrollModule = (function () { | ||
@@ -7,8 +9,8 @@ function NgSlimScrollModule() { | ||
NgSlimScrollModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
{ type: core_1.NgModule, args: [{ | ||
declarations: [ | ||
SlimScrollDirective | ||
slimscroll_directive_1.SlimScrollDirective | ||
], | ||
exports: [ | ||
SlimScrollDirective | ||
slimscroll_directive_1.SlimScrollDirective | ||
] | ||
@@ -21,2 +23,2 @@ },] }, | ||
}()); | ||
export { NgSlimScrollModule }; | ||
exports.NgSlimScrollModule = NgSlimScrollModule; |
{ | ||
"name": "ngx-slimscroll", | ||
"version": "3.3.2", | ||
"version": "3.3.3", | ||
"description": "Angular2+ Customizable Scrollbar", | ||
@@ -5,0 +5,0 @@ "main": "bundles/ngx-slimscroll.umd.js", |
{ | ||
"compilerOptions": { | ||
"module": "es2015", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
@@ -5,0 +5,0 @@ "target": "es5", |
Sorry, the diff of this file is not supported yet
2930
710584