Huge News!Announcing our $40M Series B led by Abstract Ventures.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 9.2.1 to 9.2.2

2

bundles/ngx-slimscroll.umd.js

@@ -572,3 +572,3 @@ (function (global, factory) {

if (paddingBottom === 0) {
var delta = Math.round(_this.el.clientHeight * percentScroll);
var delta = Math.round((_this.el.clientHeight - barHeight) * percentScroll);
if (delta > 0) {

@@ -575,0 +575,0 @@ _this.renderer.setStyle(_this.bar, 'top', delta + "px");

@@ -15,3 +15,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("ngx-slimscroll",["exports","@angular/core","@angular/common","rxjs","rxjs/operators"],e):e((t=t||self)["ngx-slimscroll"]={},t.ng.core,t.ng.common,t.rxjs,t.rxjs.operators)}(this,(function(t,e,r,i,n){"use strict";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function o(t,e,r,i){var n,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(o<3?n(s):o>3?n(e,r,s):n(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s}function s(t,e){return function(r,i){e(r,i,t)}}function a(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}function l(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return t}var d=function(t){this.type=t.type,this.y=t&&t.y?t.y:0,this.percent=t&&t.percent?t.percent:0,this.duration=t&&t.duration?t.duration:0,this.easing=t&&t.easing?t.easing:"linear"},h=new e.InjectionToken("NGX_SLIMSCROLL_DEFAULTS"),c=function(){function t(t){this.position=t&&t.position?t.position:"right",this.barBackground=t&&t.barBackground?t.barBackground:"#343a40",this.barOpacity=t&&t.barOpacity?t.barOpacity:"1",this.barWidth=t&&t.barWidth?t.barWidth:"12",this.barBorderRadius=t&&t.barBorderRadius?t.barBorderRadius:"5",this.barMargin=t&&t.barMargin?t.barMargin:"1px 0",this.gridBackground=t&&t.gridBackground?t.gridBackground:"#adb5bd",this.gridOpacity=t&&t.gridOpacity?t.gridOpacity:"1",this.gridWidth=t&&t.gridWidth?t.gridWidth:"8",this.gridBorderRadius=t&&t.gridBorderRadius?t.gridBorderRadius:"10",this.gridMargin=t&&t.gridMargin?t.gridMargin:"1px 2px",this.alwaysVisible=!t||void 0===t.alwaysVisible||t.alwaysVisible,this.visibleTimeout=t&&t.visibleTimeout?t.visibleTimeout:1e3,this.alwaysPreventDefaultScroll=!t||void 0===t.alwaysPreventDefaultScroll||t.alwaysPreventDefaultScroll}return t.prototype.merge=function(e){var r=new t;return r.position=e&&e.position?e.position:this.position,r.barBackground=e&&e.barBackground?e.barBackground:this.barBackground,r.barOpacity=e&&e.barOpacity?e.barOpacity:this.barOpacity,r.barWidth=e&&e.barWidth?e.barWidth:this.barWidth,r.barBorderRadius=e&&e.barBorderRadius?e.barBorderRadius:this.barBorderRadius,r.barMargin=e&&e.barMargin?e.barMargin:this.barMargin,r.gridBackground=e&&e.gridBackground?e.gridBackground:this.gridBackground,r.gridOpacity=e&&e.gridOpacity?e.gridOpacity:this.gridOpacity,r.gridWidth=e&&e.gridWidth?e.gridWidth:this.gridWidth,r.gridBorderRadius=e&&e.gridBorderRadius?e.gridBorderRadius:this.gridBorderRadius,r.gridMargin=e&&e.gridMargin?e.gridMargin:this.gridMargin,r.alwaysVisible=e&&void 0!==e.alwaysVisible?e.alwaysVisible:this.alwaysVisible,r.visibleTimeout=e&&e.visibleTimeout?e.visibleTimeout:this.visibleTimeout,r.alwaysPreventDefaultScroll=!e||void 0===e.alwaysPreventDefaultScroll||e.alwaysPreventDefaultScroll,r},t}(),u=function(t){this.scrollPosition=t&&t.scrollPosition?t.scrollPosition:0,this.isScrollAtStart=!t||void 0===t.isScrollAtStart||t.isScrollAtStart,this.isScrollAtEnd=!(!t||void 0===t.isScrollAtEnd)&&t.isScrollAtEnd},p=function(t){return t},g=function(t){return t*t},y=function(t){return t*(2-t)},f=function(t){return t<.5?2*t*t:(4-2*t)*t-1},b=function(t){return t*t*t},m=function(t){return--t*t*t+1},v=function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},S=function(t){return t*t*t*t},w=function(t){return 1- --t*t*t*t},B=function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},T=function(t){return t*t*t*t*t},O=function(t){return 1+--t*t*t*t*t},C=function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t},E={linear:p,inQuad:g,outQuad:y,inOutQuad:f,inCubic:b,outCubic:m,inOutCubic:v,inQuart:S,outQuart:w,inOutQuart:B,inQuint:T,outQuint:O,inOutQuint:C},M=function(){function t(t,r,o,s){var a=this;this.viewContainer=t,this.renderer=r,this.document=o,this.optionsDefaults=s,this.enabled=!0,this.scrollChanged=new e.EventEmitter,this.barVisibilityChange=new e.EventEmitter,this.initWheel=function(){var t=i.fromEvent(a.el,"DOMMouseScroll"),e=i.fromEvent(a.el,"mousewheel"),r=i.merge.apply(void 0,l([t,e])).subscribe((function(t){var e=0;t.wheelDelta&&(e=-t.wheelDelta/120),t.detail&&(e=t.detail/3);var r=a.scrollContent(e,!0,!1);t.preventDefault&&(a.options.alwaysPreventDefaultScroll||null===r)&&t.preventDefault()}));a.interactionSubscriptions.add(r)},this.initDrag=function(){var t=a.bar,e=i.fromEvent(a.document.documentElement,"mousemove"),r=i.fromEvent(a.document.documentElement,"touchmove"),o=i.fromEvent(t,"mousedown"),s=i.fromEvent(a.el,"touchstart"),d=i.fromEvent(a.document.documentElement,"mouseup"),h=i.fromEvent(a.document.documentElement,"touchend"),c=o.pipe(n.mergeMap((function(r){return a.pageY=r.pageY,a.top=parseFloat(getComputedStyle(t).top),e.pipe(n.map((function(t){return t.preventDefault(),a.top+t.pageY-a.pageY})),n.takeUntil(d))}))),u=s.pipe(n.mergeMap((function(e){return a.pageY=e.targetTouches[0].pageY,a.top=-parseFloat(getComputedStyle(t).top),r.pipe(n.map((function(t){return-(a.top+t.targetTouches[0].pageY-a.pageY)})),n.takeUntil(h))}))),p=i.merge.apply(void 0,l([c,u])).subscribe((function(t){a.body.addEventListener("selectstart",a.preventDefaultEvent,!1),a.renderer.setStyle(a.body,"touch-action","pan-y"),a.renderer.setStyle(a.body,"user-select","none"),a.renderer.setStyle(a.bar,"top",t+"px");var e=a.scrollContent(0,!0,!1),r=a.el.offsetHeight-a.bar.offsetHeight;e&&e<0&&-e<=r?a.renderer.setStyle(a.el,"paddingTop",-e+"px"):e&&e>0&&e<=r&&a.renderer.setStyle(a.el,"paddingBottom",e+"px")})),g=i.merge.apply(void 0,l([d,h])).subscribe((function(){a.body.removeEventListener("selectstart",a.preventDefaultEvent,!1);var t=parseInt(a.el.style.paddingTop,10),e=parseInt(a.el.style.paddingBottom,10);a.renderer.setStyle(a.body,"touch-action","unset"),a.renderer.setStyle(a.body,"user-select","default"),(t>0||e>0)&&a.scrollTo(0,300,"linear")}));a.interactionSubscriptions.add(p),a.interactionSubscriptions.add(g)},this.preventDefaultEvent=function(t){t.preventDefault(),t.stopPropagation()},this.el=this.viewContainer.element.nativeElement,this.body=this.document.querySelector("body"),this.mutationThrottleTimeout=50}return t.prototype.ngOnInit=function(){!this.interactionSubscriptions&&this.enabled&&this.setup()},t.prototype.ngOnChanges=function(t){t.enabled&&(this.enabled?this.setup():this.destroy())},t.prototype.ngOnDestroy=function(){this.destroy()},t.prototype.setup=function(){var t=this;if(this.interactionSubscriptions=new i.Subscription,this.optionsDefaults?this.options=new c(this.optionsDefaults).merge(this.options):this.options=new c(this.options),this.setStyle(),this.wrapContainer(),this.initGrid(),this.initBar(),this.getBarHeight(),this.initWheel(),this.initDrag(),this.options.alwaysVisible||this.hideBarAndGrid(),MutationObserver&&(this.mutationObserver&&this.mutationObserver.disconnect(),this.mutationObserver=new MutationObserver((function(){t.mutationThrottleTimeout&&(clearTimeout(t.mutationThrottleTimeout),t.mutationThrottleTimeout=setTimeout(t.onMutation.bind(t),50))})),this.mutationObserver.observe(this.el,{subtree:!0,childList:!0})),this.scrollEvents&&this.scrollEvents instanceof e.EventEmitter){var r=this.scrollEvents.subscribe((function(e){return t.handleEvent(e)}));this.interactionSubscriptions.add(r)}},t.prototype.handleEvent=function(t){if("scrollToBottom"===t.type){var e=this.el.scrollHeight-this.el.clientHeight;this.scrollTo(e,t.duration,t.easing)}else if("scrollToTop"===t.type){e=0;this.scrollTo(e,t.duration,t.easing)}else if("scrollToPercent"===t.type&&t.percent>=0&&t.percent<=100){e=Math.round((this.el.scrollHeight-this.el.clientHeight)/100*t.percent);this.scrollTo(e,t.duration,t.easing)}else if("scrollTo"===t.type){var r=this.el.scrollHeight-this.el.clientHeight;(e=t.y<=r?t.y:r)>=0&&this.scrollTo(e,t.duration,t.easing)}else"recalculate"===t.type&&this.getBarHeight()},t.prototype.setStyle=function(){var t=this.el;this.renderer.setStyle(t,"overflow","hidden")},t.prototype.onMutation=function(){this.getBarHeight()},t.prototype.wrapContainer=function(){this.wrapper=this.renderer.createElement("div");var t=this.wrapper,e=this.el;this.renderer.addClass(t,"slimscroll-wrapper"),this.renderer.setStyle(t,"position","relative"),this.renderer.setStyle(t,"overflow","hidden"),this.renderer.setStyle(t,"display","block"),this.renderer.setStyle(t,"margin",getComputedStyle(e).margin),this.renderer.setStyle(t,"width","100%"),this.renderer.setStyle(t,"height",getComputedStyle(e).height),this.renderer.insertBefore(e.parentNode,t,e),this.renderer.appendChild(t,e)},t.prototype.initGrid=function(){this.grid=this.renderer.createElement("div");var t=this.grid;this.renderer.addClass(t,"slimscroll-grid"),this.renderer.setStyle(t,"position","absolute"),this.renderer.setStyle(t,"top","0"),this.renderer.setStyle(t,"bottom","0"),this.renderer.setStyle(t,this.options.position,"0"),this.renderer.setStyle(t,"width",this.options.gridWidth+"px"),this.renderer.setStyle(t,"background",this.options.gridBackground),this.renderer.setStyle(t,"opacity",this.options.gridOpacity),this.renderer.setStyle(t,"display","block"),this.renderer.setStyle(t,"cursor","pointer"),this.renderer.setStyle(t,"z-index","99"),this.renderer.setStyle(t,"border-radius",this.options.gridBorderRadius+"px"),this.renderer.setStyle(t,"margin",this.options.gridMargin),this.renderer.appendChild(this.wrapper,t)},t.prototype.initBar=function(){this.bar=this.renderer.createElement("div");var t=this.bar;this.renderer.addClass(t,"slimscroll-bar"),this.renderer.setStyle(t,"position","absolute"),this.renderer.setStyle(t,"top","0"),this.renderer.setStyle(t,this.options.position,"0"),this.renderer.setStyle(t,"width",this.options.barWidth+"px"),this.renderer.setStyle(t,"background",this.options.barBackground),this.renderer.setStyle(t,"opacity",this.options.barOpacity),this.renderer.setStyle(t,"display","block"),this.renderer.setStyle(t,"cursor","pointer"),this.renderer.setStyle(t,"z-index","100"),this.renderer.setStyle(t,"border-radius",this.options.barBorderRadius+"px"),this.renderer.setStyle(t,"margin",this.options.barMargin),this.renderer.appendChild(this.wrapper,t),this.barVisibilityChange.emit(!0)},t.prototype.getBarHeight=function(){var t=this.el.offsetHeight,e=Math.max(t/this.el.scrollHeight*t,30)+"px",r=parseInt(e,10)===t?"none":"block";this.wrapper.offsetHeight!==t&&this.renderer.setStyle(this.wrapper,"height",t+"px"),this.renderer.setStyle(this.bar,"height",e),this.renderer.setStyle(this.bar,"display",r),this.renderer.setStyle(this.grid,"display",r),this.barVisibilityChange.emit("none"!==r)},t.prototype.scrollTo=function(t,e,r){var i=this,n=Date.now(),o=this.el.scrollTop,s=this.el.scrollHeight-this.el.clientHeight,a=(Math.max(this.el.offsetHeight/this.el.scrollHeight*this.el.offsetHeight,30),parseInt(this.el.style.paddingTop,10)||0),l=parseInt(this.el.style.paddingBottom,10)||0,d=function(){var h=Date.now(),c=Math.min(1,(h-n)/e),p=E[r](c);if(a>0||l>0){var g=null;a>0&&(g=-(p*(t-(g=-a))+g),i.renderer.setStyle(i.el,"padding-top",g+"px")),l>0&&(g=p*(t-(g=l))+g,i.renderer.setStyle(i.el,"padding-bottom",g+"px"))}else i.el.scrollTop=p*(t-o)+o;var y=i.el.scrollTop/s;if(0===l){var f=Math.round(i.el.clientHeight*y);f>0&&i.renderer.setStyle(i.bar,"top",f+"px")}var b=0===i.el.scrollTop,m=i.el.scrollTop===i.el.scrollHeight-i.el.offsetHeight,v=Math.ceil(i.el.scrollTop),S=new u({scrollPosition:v,isScrollAtStart:b,isScrollAtEnd:m});i.scrollChanged.emit(S),c<1&&requestAnimationFrame(d)};requestAnimationFrame(d)},t.prototype.scrollContent=function(t,e,r){var i=this,n=t,o=this.el.offsetHeight-this.bar.offsetHeight,s=this.el.scrollHeight-this.el.offsetHeight,a=null;e&&(((n=parseInt(getComputedStyle(this.bar).top,10)+20*t/100*this.bar.offsetHeight)<0||n>o)&&(a=n>o?n-o:n),n=Math.min(Math.max(n,0),o),n=t>0?Math.ceil(n):Math.floor(n),this.renderer.setStyle(this.bar,"top",n+"px")),n=parseInt(getComputedStyle(this.bar).top,10)/(this.el.offsetHeight-this.bar.offsetHeight)*s,this.el.scrollTop=n,this.showBarAndGrid(),this.options.alwaysVisible||(this.visibleTimeout&&clearTimeout(this.visibleTimeout),this.visibleTimeout=setTimeout((function(){i.hideBarAndGrid()}),this.options.visibleTimeout));var l=0===n,d=n===s,h=Math.ceil(n),c=new u({scrollPosition:h,isScrollAtStart:l,isScrollAtEnd:d});return this.scrollChanged.emit(c),a},t.prototype.showBarAndGrid=function(){this.renderer.setStyle(this.grid,"background",this.options.gridBackground),this.renderer.setStyle(this.bar,"background",this.options.barBackground)},t.prototype.hideBarAndGrid=function(){this.renderer.setStyle(this.grid,"background","transparent"),this.renderer.setStyle(this.bar,"background","transparent")},t.prototype.destroy=function(){if(this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.el.parentElement.classList.contains("slimscroll-wrapper")){var t=this.el.parentElement,e=t.querySelector(".slimscroll-bar");t.removeChild(e);var r=t.querySelector(".slimscroll-grid");t.removeChild(r),this.unwrap(t)}this.interactionSubscriptions&&this.interactionSubscriptions.unsubscribe()},t.prototype.unwrap=function(t){for(var e=document.createDocumentFragment();t.firstChild;){var r=t.removeChild(t.firstChild);e.appendChild(r)}t.parentNode.replaceChild(e,t)},t.prototype.onResize=function(t){this.getBarHeight()},t.ctorParameters=function(){return[{type:e.ViewContainerRef,decorators:[{type:e.Inject,args:[e.ViewContainerRef]}]},{type:e.Renderer2,decorators:[{type:e.Inject,args:[e.Renderer2]}]},{type:void 0,decorators:[{type:e.Inject,args:[r.DOCUMENT]}]},{type:void 0,decorators:[{type:e.Inject,args:[h]},{type:e.Optional}]}]},o([e.Input()],t.prototype,"enabled",void 0),o([e.Input()],t.prototype,"options",void 0),o([e.Input()],t.prototype,"scrollEvents",void 0),o([e.Output()],t.prototype,"scrollChanged",void 0),o([e.Output()],t.prototype,"barVisibilityChange",void 0),o([e.HostListener("window:resize",["$event"])],t.prototype,"onResize",null),t=o([e.Directive({selector:"[slimScroll]",exportAs:"slimScroll"}),s(0,e.Inject(e.ViewContainerRef)),s(1,e.Inject(e.Renderer2)),s(2,e.Inject(r.DOCUMENT)),s(3,e.Inject(h)),s(3,e.Optional())],t)}(),x=function(){function t(){}return t=o([e.NgModule({declarations:[M],exports:[M]})],t)}();t.NgSlimScrollModule=x,t.SLIMSCROLL_DEFAULTS=h,t.SlimScrollDirective=M,t.SlimScrollEvent=d,t.SlimScrollOptions=c,t.SlimScrollState=u,t.easing=E,t.ɵ0=p,t.ɵ1=g,t.ɵ10=T,t.ɵ11=O,t.ɵ12=C,t.ɵ2=y,t.ɵ3=f,t.ɵ4=b,t.ɵ5=m,t.ɵ6=v,t.ɵ7=S,t.ɵ8=w,t.ɵ9=B,Object.defineProperty(t,"__esModule",{value:!0})}));
***************************************************************************** */function o(t,e,r,i){var n,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(o<3?n(s):o>3?n(e,r,s):n(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s}function s(t,e){return function(r,i){e(r,i,t)}}function a(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}function l(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return t}var d=function(t){this.type=t.type,this.y=t&&t.y?t.y:0,this.percent=t&&t.percent?t.percent:0,this.duration=t&&t.duration?t.duration:0,this.easing=t&&t.easing?t.easing:"linear"},h=new e.InjectionToken("NGX_SLIMSCROLL_DEFAULTS"),c=function(){function t(t){this.position=t&&t.position?t.position:"right",this.barBackground=t&&t.barBackground?t.barBackground:"#343a40",this.barOpacity=t&&t.barOpacity?t.barOpacity:"1",this.barWidth=t&&t.barWidth?t.barWidth:"12",this.barBorderRadius=t&&t.barBorderRadius?t.barBorderRadius:"5",this.barMargin=t&&t.barMargin?t.barMargin:"1px 0",this.gridBackground=t&&t.gridBackground?t.gridBackground:"#adb5bd",this.gridOpacity=t&&t.gridOpacity?t.gridOpacity:"1",this.gridWidth=t&&t.gridWidth?t.gridWidth:"8",this.gridBorderRadius=t&&t.gridBorderRadius?t.gridBorderRadius:"10",this.gridMargin=t&&t.gridMargin?t.gridMargin:"1px 2px",this.alwaysVisible=!t||void 0===t.alwaysVisible||t.alwaysVisible,this.visibleTimeout=t&&t.visibleTimeout?t.visibleTimeout:1e3,this.alwaysPreventDefaultScroll=!t||void 0===t.alwaysPreventDefaultScroll||t.alwaysPreventDefaultScroll}return t.prototype.merge=function(e){var r=new t;return r.position=e&&e.position?e.position:this.position,r.barBackground=e&&e.barBackground?e.barBackground:this.barBackground,r.barOpacity=e&&e.barOpacity?e.barOpacity:this.barOpacity,r.barWidth=e&&e.barWidth?e.barWidth:this.barWidth,r.barBorderRadius=e&&e.barBorderRadius?e.barBorderRadius:this.barBorderRadius,r.barMargin=e&&e.barMargin?e.barMargin:this.barMargin,r.gridBackground=e&&e.gridBackground?e.gridBackground:this.gridBackground,r.gridOpacity=e&&e.gridOpacity?e.gridOpacity:this.gridOpacity,r.gridWidth=e&&e.gridWidth?e.gridWidth:this.gridWidth,r.gridBorderRadius=e&&e.gridBorderRadius?e.gridBorderRadius:this.gridBorderRadius,r.gridMargin=e&&e.gridMargin?e.gridMargin:this.gridMargin,r.alwaysVisible=e&&void 0!==e.alwaysVisible?e.alwaysVisible:this.alwaysVisible,r.visibleTimeout=e&&e.visibleTimeout?e.visibleTimeout:this.visibleTimeout,r.alwaysPreventDefaultScroll=!e||void 0===e.alwaysPreventDefaultScroll||e.alwaysPreventDefaultScroll,r},t}(),u=function(t){this.scrollPosition=t&&t.scrollPosition?t.scrollPosition:0,this.isScrollAtStart=!t||void 0===t.isScrollAtStart||t.isScrollAtStart,this.isScrollAtEnd=!(!t||void 0===t.isScrollAtEnd)&&t.isScrollAtEnd},p=function(t){return t},g=function(t){return t*t},y=function(t){return t*(2-t)},f=function(t){return t<.5?2*t*t:(4-2*t)*t-1},b=function(t){return t*t*t},m=function(t){return--t*t*t+1},v=function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},S=function(t){return t*t*t*t},w=function(t){return 1- --t*t*t*t},B=function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},T=function(t){return t*t*t*t*t},O=function(t){return 1+--t*t*t*t*t},C=function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t},E={linear:p,inQuad:g,outQuad:y,inOutQuad:f,inCubic:b,outCubic:m,inOutCubic:v,inQuart:S,outQuart:w,inOutQuart:B,inQuint:T,outQuint:O,inOutQuint:C},M=function(){function t(t,r,o,s){var a=this;this.viewContainer=t,this.renderer=r,this.document=o,this.optionsDefaults=s,this.enabled=!0,this.scrollChanged=new e.EventEmitter,this.barVisibilityChange=new e.EventEmitter,this.initWheel=function(){var t=i.fromEvent(a.el,"DOMMouseScroll"),e=i.fromEvent(a.el,"mousewheel"),r=i.merge.apply(void 0,l([t,e])).subscribe((function(t){var e=0;t.wheelDelta&&(e=-t.wheelDelta/120),t.detail&&(e=t.detail/3);var r=a.scrollContent(e,!0,!1);t.preventDefault&&(a.options.alwaysPreventDefaultScroll||null===r)&&t.preventDefault()}));a.interactionSubscriptions.add(r)},this.initDrag=function(){var t=a.bar,e=i.fromEvent(a.document.documentElement,"mousemove"),r=i.fromEvent(a.document.documentElement,"touchmove"),o=i.fromEvent(t,"mousedown"),s=i.fromEvent(a.el,"touchstart"),d=i.fromEvent(a.document.documentElement,"mouseup"),h=i.fromEvent(a.document.documentElement,"touchend"),c=o.pipe(n.mergeMap((function(r){return a.pageY=r.pageY,a.top=parseFloat(getComputedStyle(t).top),e.pipe(n.map((function(t){return t.preventDefault(),a.top+t.pageY-a.pageY})),n.takeUntil(d))}))),u=s.pipe(n.mergeMap((function(e){return a.pageY=e.targetTouches[0].pageY,a.top=-parseFloat(getComputedStyle(t).top),r.pipe(n.map((function(t){return-(a.top+t.targetTouches[0].pageY-a.pageY)})),n.takeUntil(h))}))),p=i.merge.apply(void 0,l([c,u])).subscribe((function(t){a.body.addEventListener("selectstart",a.preventDefaultEvent,!1),a.renderer.setStyle(a.body,"touch-action","pan-y"),a.renderer.setStyle(a.body,"user-select","none"),a.renderer.setStyle(a.bar,"top",t+"px");var e=a.scrollContent(0,!0,!1),r=a.el.offsetHeight-a.bar.offsetHeight;e&&e<0&&-e<=r?a.renderer.setStyle(a.el,"paddingTop",-e+"px"):e&&e>0&&e<=r&&a.renderer.setStyle(a.el,"paddingBottom",e+"px")})),g=i.merge.apply(void 0,l([d,h])).subscribe((function(){a.body.removeEventListener("selectstart",a.preventDefaultEvent,!1);var t=parseInt(a.el.style.paddingTop,10),e=parseInt(a.el.style.paddingBottom,10);a.renderer.setStyle(a.body,"touch-action","unset"),a.renderer.setStyle(a.body,"user-select","default"),(t>0||e>0)&&a.scrollTo(0,300,"linear")}));a.interactionSubscriptions.add(p),a.interactionSubscriptions.add(g)},this.preventDefaultEvent=function(t){t.preventDefault(),t.stopPropagation()},this.el=this.viewContainer.element.nativeElement,this.body=this.document.querySelector("body"),this.mutationThrottleTimeout=50}return t.prototype.ngOnInit=function(){!this.interactionSubscriptions&&this.enabled&&this.setup()},t.prototype.ngOnChanges=function(t){t.enabled&&(this.enabled?this.setup():this.destroy())},t.prototype.ngOnDestroy=function(){this.destroy()},t.prototype.setup=function(){var t=this;if(this.interactionSubscriptions=new i.Subscription,this.optionsDefaults?this.options=new c(this.optionsDefaults).merge(this.options):this.options=new c(this.options),this.setStyle(),this.wrapContainer(),this.initGrid(),this.initBar(),this.getBarHeight(),this.initWheel(),this.initDrag(),this.options.alwaysVisible||this.hideBarAndGrid(),MutationObserver&&(this.mutationObserver&&this.mutationObserver.disconnect(),this.mutationObserver=new MutationObserver((function(){t.mutationThrottleTimeout&&(clearTimeout(t.mutationThrottleTimeout),t.mutationThrottleTimeout=setTimeout(t.onMutation.bind(t),50))})),this.mutationObserver.observe(this.el,{subtree:!0,childList:!0})),this.scrollEvents&&this.scrollEvents instanceof e.EventEmitter){var r=this.scrollEvents.subscribe((function(e){return t.handleEvent(e)}));this.interactionSubscriptions.add(r)}},t.prototype.handleEvent=function(t){if("scrollToBottom"===t.type){var e=this.el.scrollHeight-this.el.clientHeight;this.scrollTo(e,t.duration,t.easing)}else if("scrollToTop"===t.type){e=0;this.scrollTo(e,t.duration,t.easing)}else if("scrollToPercent"===t.type&&t.percent>=0&&t.percent<=100){e=Math.round((this.el.scrollHeight-this.el.clientHeight)/100*t.percent);this.scrollTo(e,t.duration,t.easing)}else if("scrollTo"===t.type){var r=this.el.scrollHeight-this.el.clientHeight;(e=t.y<=r?t.y:r)>=0&&this.scrollTo(e,t.duration,t.easing)}else"recalculate"===t.type&&this.getBarHeight()},t.prototype.setStyle=function(){var t=this.el;this.renderer.setStyle(t,"overflow","hidden")},t.prototype.onMutation=function(){this.getBarHeight()},t.prototype.wrapContainer=function(){this.wrapper=this.renderer.createElement("div");var t=this.wrapper,e=this.el;this.renderer.addClass(t,"slimscroll-wrapper"),this.renderer.setStyle(t,"position","relative"),this.renderer.setStyle(t,"overflow","hidden"),this.renderer.setStyle(t,"display","block"),this.renderer.setStyle(t,"margin",getComputedStyle(e).margin),this.renderer.setStyle(t,"width","100%"),this.renderer.setStyle(t,"height",getComputedStyle(e).height),this.renderer.insertBefore(e.parentNode,t,e),this.renderer.appendChild(t,e)},t.prototype.initGrid=function(){this.grid=this.renderer.createElement("div");var t=this.grid;this.renderer.addClass(t,"slimscroll-grid"),this.renderer.setStyle(t,"position","absolute"),this.renderer.setStyle(t,"top","0"),this.renderer.setStyle(t,"bottom","0"),this.renderer.setStyle(t,this.options.position,"0"),this.renderer.setStyle(t,"width",this.options.gridWidth+"px"),this.renderer.setStyle(t,"background",this.options.gridBackground),this.renderer.setStyle(t,"opacity",this.options.gridOpacity),this.renderer.setStyle(t,"display","block"),this.renderer.setStyle(t,"cursor","pointer"),this.renderer.setStyle(t,"z-index","99"),this.renderer.setStyle(t,"border-radius",this.options.gridBorderRadius+"px"),this.renderer.setStyle(t,"margin",this.options.gridMargin),this.renderer.appendChild(this.wrapper,t)},t.prototype.initBar=function(){this.bar=this.renderer.createElement("div");var t=this.bar;this.renderer.addClass(t,"slimscroll-bar"),this.renderer.setStyle(t,"position","absolute"),this.renderer.setStyle(t,"top","0"),this.renderer.setStyle(t,this.options.position,"0"),this.renderer.setStyle(t,"width",this.options.barWidth+"px"),this.renderer.setStyle(t,"background",this.options.barBackground),this.renderer.setStyle(t,"opacity",this.options.barOpacity),this.renderer.setStyle(t,"display","block"),this.renderer.setStyle(t,"cursor","pointer"),this.renderer.setStyle(t,"z-index","100"),this.renderer.setStyle(t,"border-radius",this.options.barBorderRadius+"px"),this.renderer.setStyle(t,"margin",this.options.barMargin),this.renderer.appendChild(this.wrapper,t),this.barVisibilityChange.emit(!0)},t.prototype.getBarHeight=function(){var t=this.el.offsetHeight,e=Math.max(t/this.el.scrollHeight*t,30)+"px",r=parseInt(e,10)===t?"none":"block";this.wrapper.offsetHeight!==t&&this.renderer.setStyle(this.wrapper,"height",t+"px"),this.renderer.setStyle(this.bar,"height",e),this.renderer.setStyle(this.bar,"display",r),this.renderer.setStyle(this.grid,"display",r),this.barVisibilityChange.emit("none"!==r)},t.prototype.scrollTo=function(t,e,r){var i=this,n=Date.now(),o=this.el.scrollTop,s=this.el.scrollHeight-this.el.clientHeight,a=Math.max(this.el.offsetHeight/this.el.scrollHeight*this.el.offsetHeight,30),l=parseInt(this.el.style.paddingTop,10)||0,d=parseInt(this.el.style.paddingBottom,10)||0,h=function(){var c=Date.now(),p=Math.min(1,(c-n)/e),g=E[r](p);if(l>0||d>0){var y=null;l>0&&(y=-(g*(t-(y=-l))+y),i.renderer.setStyle(i.el,"padding-top",y+"px")),d>0&&(y=g*(t-(y=d))+y,i.renderer.setStyle(i.el,"padding-bottom",y+"px"))}else i.el.scrollTop=g*(t-o)+o;var f=i.el.scrollTop/s;if(0===d){var b=Math.round((i.el.clientHeight-a)*f);b>0&&i.renderer.setStyle(i.bar,"top",b+"px")}var m=0===i.el.scrollTop,v=i.el.scrollTop===i.el.scrollHeight-i.el.offsetHeight,S=Math.ceil(i.el.scrollTop),w=new u({scrollPosition:S,isScrollAtStart:m,isScrollAtEnd:v});i.scrollChanged.emit(w),p<1&&requestAnimationFrame(h)};requestAnimationFrame(h)},t.prototype.scrollContent=function(t,e,r){var i=this,n=t,o=this.el.offsetHeight-this.bar.offsetHeight,s=this.el.scrollHeight-this.el.offsetHeight,a=null;e&&(((n=parseInt(getComputedStyle(this.bar).top,10)+20*t/100*this.bar.offsetHeight)<0||n>o)&&(a=n>o?n-o:n),n=Math.min(Math.max(n,0),o),n=t>0?Math.ceil(n):Math.floor(n),this.renderer.setStyle(this.bar,"top",n+"px")),n=parseInt(getComputedStyle(this.bar).top,10)/(this.el.offsetHeight-this.bar.offsetHeight)*s,this.el.scrollTop=n,this.showBarAndGrid(),this.options.alwaysVisible||(this.visibleTimeout&&clearTimeout(this.visibleTimeout),this.visibleTimeout=setTimeout((function(){i.hideBarAndGrid()}),this.options.visibleTimeout));var l=0===n,d=n===s,h=Math.ceil(n),c=new u({scrollPosition:h,isScrollAtStart:l,isScrollAtEnd:d});return this.scrollChanged.emit(c),a},t.prototype.showBarAndGrid=function(){this.renderer.setStyle(this.grid,"background",this.options.gridBackground),this.renderer.setStyle(this.bar,"background",this.options.barBackground)},t.prototype.hideBarAndGrid=function(){this.renderer.setStyle(this.grid,"background","transparent"),this.renderer.setStyle(this.bar,"background","transparent")},t.prototype.destroy=function(){if(this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.el.parentElement.classList.contains("slimscroll-wrapper")){var t=this.el.parentElement,e=t.querySelector(".slimscroll-bar");t.removeChild(e);var r=t.querySelector(".slimscroll-grid");t.removeChild(r),this.unwrap(t)}this.interactionSubscriptions&&this.interactionSubscriptions.unsubscribe()},t.prototype.unwrap=function(t){for(var e=document.createDocumentFragment();t.firstChild;){var r=t.removeChild(t.firstChild);e.appendChild(r)}t.parentNode.replaceChild(e,t)},t.prototype.onResize=function(t){this.getBarHeight()},t.ctorParameters=function(){return[{type:e.ViewContainerRef,decorators:[{type:e.Inject,args:[e.ViewContainerRef]}]},{type:e.Renderer2,decorators:[{type:e.Inject,args:[e.Renderer2]}]},{type:void 0,decorators:[{type:e.Inject,args:[r.DOCUMENT]}]},{type:void 0,decorators:[{type:e.Inject,args:[h]},{type:e.Optional}]}]},o([e.Input()],t.prototype,"enabled",void 0),o([e.Input()],t.prototype,"options",void 0),o([e.Input()],t.prototype,"scrollEvents",void 0),o([e.Output()],t.prototype,"scrollChanged",void 0),o([e.Output()],t.prototype,"barVisibilityChange",void 0),o([e.HostListener("window:resize",["$event"])],t.prototype,"onResize",null),t=o([e.Directive({selector:"[slimScroll]",exportAs:"slimScroll"}),s(0,e.Inject(e.ViewContainerRef)),s(1,e.Inject(e.Renderer2)),s(2,e.Inject(r.DOCUMENT)),s(3,e.Inject(h)),s(3,e.Optional())],t)}(),x=function(){function t(){}return t=o([e.NgModule({declarations:[M],exports:[M]})],t)}();t.NgSlimScrollModule=x,t.SLIMSCROLL_DEFAULTS=h,t.SlimScrollDirective=M,t.SlimScrollEvent=d,t.SlimScrollOptions=c,t.SlimScrollState=u,t.easing=E,t.ɵ0=p,t.ɵ1=g,t.ɵ10=T,t.ɵ11=O,t.ɵ12=C,t.ɵ2=y,t.ɵ3=f,t.ɵ4=b,t.ɵ5=m,t.ɵ6=v,t.ɵ7=S,t.ɵ8=w,t.ɵ9=B,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=ngx-slimscroll.umd.min.js.map

@@ -347,3 +347,3 @@ import { InjectionToken, EventEmitter, ViewContainerRef, Inject, Renderer2, Optional, Input, Output, HostListener, Directive, NgModule } from '@angular/core';

if (paddingBottom === 0) {
const delta = Math.round(this.el.clientHeight * percentScroll);
const delta = Math.round((this.el.clientHeight - barHeight) * percentScroll);
if (delta > 0) {

@@ -350,0 +350,0 @@ this.renderer.setStyle(this.bar, 'top', `${delta}px`);

@@ -353,3 +353,3 @@ import { InjectionToken, EventEmitter, ViewContainerRef, Inject, Renderer2, Optional, Input, Output, HostListener, Directive, NgModule } from '@angular/core';

if (paddingBottom === 0) {
var delta = Math.round(_this.el.clientHeight * percentScroll);
var delta = Math.round((_this.el.clientHeight - barHeight) * percentScroll);
if (delta > 0) {

@@ -356,0 +356,0 @@ _this.renderer.setStyle(_this.bar, 'top', delta + "px");

{
"name": "ngx-slimscroll",
"version": "9.2.1",
"version": "9.2.2",
"peerDependencies": {

@@ -5,0 +5,0 @@ "@angular/common": "^9.1.9",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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