New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ngx-slimscroll

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-slimscroll - npm Package Compare versions

Comparing version 3.3.0 to 3.3.1

2

bundles/ngx-slimscroll.umd.js

@@ -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,n,i,o,s){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},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 n});var n=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 n=r(3);r.d(t,"NgSlimScrollModule",function(){return n.a});var i=r(1);r.d(t,"SlimScrollOptions",function(){return i.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 s});var n=r(0),i=(r.n(n),r(4)),o=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=function(){function e(){}return e=o([Object(n.NgModule)({declarations:[i.a],exports:[i.a]})],e)}()},function(e,t,r){"use strict";r.d(t,"a",function(){return f});var n=r(0),i=(r.n(n),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),this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}),c=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},h=this&&this.__param||function(e,t){return function(r,n){t(r,n,e)}},m={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}},f=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"),n=o.Observable.fromEvent(document.documentElement,"touchmove"),i=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=i.mergeMap(function(n){return r.pageY=n.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),n.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),n=r.el.offsetHeight-r.bar.offsetHeight;t&&t<0&&-t<=n?r.renderer.setElementStyle(r.el,"paddingTop",-t+"px"):t&&t>0&&t<=n&&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 i.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 n.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)}},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 n=this,i=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(p){var c=Date.now(),h=Math.min(1,(c-i)/t),f=m[r](h);if(a>0||d>0){var b=null;a>0&&(b=-a,b=-(f*(e-b)+b),n.renderer.setElementStyle(n.el,"paddingTop",b+"px")),d>0&&(b=d,b=f*(e-b)+b,n.renderer.setElementStyle(n.el,"paddingBottom",b+"px"))}else n.el.scrollTop=f*(e-o)+o;var g=n.el.scrollTop/s;if(0===d){var y=Math.round(Math.round(n.el.clientHeight*g)-l);y>0&&n.renderer.setElementStyle(n.bar,"top",y+"px")}h<1&&requestAnimationFrame(u)};requestAnimationFrame(u)},e.prototype.scrollContent=function(e,t,r){var n,i=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")),n=parseInt(getComputedStyle(l).top,10)/(a.offsetHeight-l.offsetHeight),o=n*(a.scrollHeight-a.offsetHeight),a.scrollTop=o,this.showBarAndGrid(),this.options.alwaysVisible||(this.visibleTimeout&&clearTimeout(this.visibleTimeout),this.visibleTimeout=setTimeout(function(){i.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()},p([Object(n.Input)(),c("design:type",i.a)],e.prototype,"options",void 0),p([Object(n.Input)(),c("design:type",n.EventEmitter)],e.prototype,"scrollEvents",void 0),p([Object(n.HostListener)("window:resize",["$event"]),c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",void 0)],e.prototype,"onResize",null),e=p([Object(n.Directive)({selector:"[slimScroll]",exportAs:"slimScroll"}),h(0,Object(n.Inject)(n.ViewContainerRef)),h(1,Object(n.Inject)(n.Renderer)),c("design:paramtypes",[n.ViewContainerRef,n.Renderer])],e)}()},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t){e.exports=i},function(e,t){e.exports=o},function(e,t){e.exports=s},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n=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,n,i,o,s){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},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 n});var n=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 n=r(3);r.d(t,"NgSlimScrollModule",function(){return n.a});var i=r(1);r.d(t,"SlimScrollOptions",function(){return i.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 s});var n=r(0),i=(r.n(n),r(4)),o=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=function(){function e(){}return e=o([Object(n.NgModule)({declarations:[i.a],exports:[i.a]})],e)}()},function(e,t,r){"use strict";r.d(t,"a",function(){return f});var n=r(0),i=(r.n(n),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),this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}),c=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},h=this&&this.__param||function(e,t){return function(r,n){t(r,n,e)}},m={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}},f=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"),n=o.Observable.fromEvent(document.documentElement,"touchmove"),i=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=i.mergeMap(function(n){return r.pageY=n.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),n.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),n=r.el.offsetHeight-r.bar.offsetHeight;t&&t<0&&-t<=n?r.renderer.setElementStyle(r.el,"paddingTop",-t+"px"):t&&t>0&&t<=n&&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 i.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 n.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 n=this,i=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(p){var c=Date.now(),h=Math.min(1,(c-i)/t),f=m[r](h);if(a>0||d>0){var b=null;a>0&&(b=-a,b=-(f*(e-b)+b),n.renderer.setElementStyle(n.el,"paddingTop",b+"px")),d>0&&(b=d,b=f*(e-b)+b,n.renderer.setElementStyle(n.el,"paddingBottom",b+"px"))}else n.el.scrollTop=f*(e-o)+o;var g=n.el.scrollTop/s;if(0===d){var y=Math.round(Math.round(n.el.clientHeight*g)-l);y>0&&n.renderer.setElementStyle(n.bar,"top",y+"px")}h<1&&requestAnimationFrame(u)};requestAnimationFrame(u)},e.prototype.scrollContent=function(e,t,r){var n,i=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")),n=parseInt(getComputedStyle(l).top,10)/(a.offsetHeight-l.offsetHeight),o=n*(a.scrollHeight-a.offsetHeight),a.scrollTop=o,this.showBarAndGrid(),this.options.alwaysVisible||(this.visibleTimeout&&clearTimeout(this.visibleTimeout),this.visibleTimeout=setTimeout(function(){i.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()},p([Object(n.Input)(),c("design:type",i.a)],e.prototype,"options",void 0),p([Object(n.Input)(),c("design:type",n.EventEmitter)],e.prototype,"scrollEvents",void 0),p([Object(n.HostListener)("window:resize",["$event"]),c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",void 0)],e.prototype,"onResize",null),e=p([Object(n.Directive)({selector:"[slimScroll]",exportAs:"slimScroll"}),h(0,Object(n.Inject)(n.ViewContainerRef)),h(1,Object(n.Inject)(n.Renderer)),c("design:paramtypes",[n.ViewContainerRef,n.Renderer])],e)}()},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t){e.exports=i},function(e,t){e.exports=o},function(e,t){e.exports=s},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n=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}()}])});
//# sourceMappingURL=ngx-slimscroll.umd.js.map

@@ -170,2 +170,5 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

}
else if (e.type === 'recalculate') {
this.getBarHeight();
}
};

@@ -172,0 +175,0 @@ SlimScrollDirective.prototype.setElementStyle = function () {

{
"name": "ngx-slimscroll",
"version": "3.3.0",
"version": "3.3.1",
"description": "Angular2+ Customizable Scrollbar",

@@ -5,0 +5,0 @@ "main": "bundles/ngx-slimscroll.umd.js",

export interface ISlimScrollEvent {
type: 'scrollToBottom' | 'scrollToTop' | 'scrollToPercent' | 'scrollTo';
type: 'scrollToBottom' | 'scrollToTop' | 'scrollToPercent' | 'scrollTo' | 'recalculate';
y?: number;

@@ -12,3 +12,3 @@ percent?: number;

export class SlimScrollEvent implements ISlimScrollEvent {
type: 'scrollToBottom' | 'scrollToTop' | 'scrollToPercent' | 'scrollTo';
type: 'scrollToBottom' | 'scrollToTop' | 'scrollToPercent' | 'scrollTo' | 'recalculate';
y?: number;

@@ -15,0 +15,0 @@ percent?: number;

@@ -111,2 +111,4 @@ import { Directive, ViewContainerRef, HostListener, OnInit, Renderer, Inject, Input, EventEmitter } from '@angular/core';

}
} else if (e.type === 'recalculate') {
this.getBarHeight();
}

@@ -113,0 +115,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc