UNPKG

ngx-free-fullpage

Version:

ngx-free-fullpage is a free-for-profit angular library that gives you all the tools you need to implement a fullpage scroll effect. This library hasn't been developed in order to substitute the current ngx-fullpage, this library is an alternative for thos

16 lines (14 loc) 6.31 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("ngx-free-fullpage",["exports","@angular/core"],t):t((e=e||self)["ngx-free-fullpage"]={},e.ng.core)}(this,(function(e,t){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function n(e,t,n,r){var i,o=arguments.length,l=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(l=(o<3?i(l):o>3?i(t,n,l):i(t,n))||l);return o>3&&l&&Object.defineProperty(t,n,l),l}var r=function(){function e(){var e=this;this.section=0,this.scrollHeight=0,this.goNext=function(){return e.scroll(1)},this.goPrev=function(){return e.scroll(-1)},this.goTo=function(t){return e.scroll(t-e.section)},this.adjustSection=function(t){return e.setNumberInRange(t,0,e.sectionsNumber-1)}}return e.prototype.addWrapper=function(e,t){if(this.wrapper)throw new Error("There is already a wrapper defined");this.wrapper=e,t>0&&this.goTo(t)},e.prototype.scroll=function(e){this.sectionsNumber=this.wrapper.nativeElement.scrollHeight/this.wrapper.nativeElement.offsetHeight,this.scrollHeight+=e*this.wrapper.nativeElement.offsetHeight,this.scrollHeight=this.adjustScroll(this.scrollHeight),this.wrapper.nativeElement.scroll({top:this.scrollHeight}),this.section=this.adjustSection(Math.round(this.scrollHeight/this.wrapper.nativeElement.offsetHeight))},e.prototype.goLast=function(){this.sectionsNumber=this.sectionsNumber||this.wrapper.nativeElement.scrollHeight/this.wrapper.nativeElement.offsetHeight,this.goTo(this.sectionsNumber-1)},e.prototype.adjustScroll=function(e){var t=(this.sectionsNumber-1)*this.wrapper.nativeElement.offsetHeight;return this.setNumberInRange(e,0,t)},e.prototype.setNumberInRange=function(e,t,n){return Math.min(Math.max(e,t),n)},e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e=n([t.Injectable({providedIn:"root"})],e)}(),i=function(){function e(e,t){var n=this;this.el=e,this.justFullpageService=t,this.el.nativeElement.onclick=function(){return n.justFullpageService.goLast()}}return e.ctorParameters=function(){return[{type:t.ElementRef},{type:r}]},e=n([t.Directive({selector:"[ngx-fullpage-go-to-last]"})],e)}(),o=function(){function e(){}return e=n([t.NgModule({declarations:[i],imports:[],exports:[i]})],e)}(),l=function(){function e(e,t){var n=this;this.element=e,this.justFullpageService=t,this.section=0,this.delta=0,this.element.nativeElement.style.overflow="hidden",this.element.nativeElement.style["scroll-behavior"]="smooth",this.element.nativeElement.onwheel=function(e){return n.wheelHandler(e)},this.justFullpageService.addWrapper(e,this.section)}return e.prototype.wheelHandler=function(e){var t=this;this.delta+=e.deltaY,this.delta===e.deltaY&&setTimeout((function(){var e=Math.abs(t.delta)/t.delta;t.justFullpageService.scroll(e),setTimeout((function(){return t.delta=0}),150)}),50)},e.ctorParameters=function(){return[{type:t.ElementRef},{type:r}]},n([t.Input()],e.prototype,"section",void 0),e=n([t.Directive({selector:"[ngx-fullpage-wrapper]",providers:[r]})],e)}(),s=function(){function e(e){this.element=e,this.element.nativeElement.style.height="100%",this.element.nativeElement.style.width="100%"}return e.ctorParameters=function(){return[{type:t.ElementRef}]},e=n([t.Directive({selector:"[ngx-fullpage-section]"})],e)}(),u=function(){function e(){}return e=n([t.NgModule({declarations:[l,s],imports:[],exports:[l,s]})],e)}(),c=function(){function e(e,t){var n=this;this.el=e,this.justFullpageService=t,this.el.nativeElement.onclick=function(e){return n.justFullpageService.goNext()}}return e.ctorParameters=function(){return[{type:t.ElementRef},{type:r}]},e=n([t.Directive({selector:"[ngx-fullpage-next-button]"})],e)}(),a=function(){function e(e,t){var n=this;this.el=e,this.justFullpageService=t,this.el.nativeElement.onclick=function(e){return n.justFullpageService.goPrev()}}return e.ctorParameters=function(){return[{type:t.ElementRef},{type:r}]},e=n([t.Directive({selector:"[ngx-fullpage-prev-button]"})],e)}(),p=function(){function e(){}return e=n([t.NgModule({declarations:[c,a],imports:[],exports:[c,a]})],e)}(),f=function(){function e(e,t){var n=this;this.el=e,this.justFullpageService=t,this.el.nativeElement.onclick=function(){return n.justFullpageService.goTo(0)}}return e.ctorParameters=function(){return[{type:t.ElementRef},{type:r}]},e=n([t.Directive({selector:"[ngx-fullpage-go-to-first]"})],e)}(),h=function(){function e(){}return e=n([t.NgModule({declarations:[f],imports:[],exports:[f]})],e)}(),g=function(){function e(e,t){var n=this;this.element=e,this.justFullpageService=t,this.element.nativeElement.onclick=function(){return n.justFullpageService.goTo(n.section)}}return e.ctorParameters=function(){return[{type:t.ElementRef},{type:r}]},n([t.Input("ngx-fullpage-go-to-section")],e.prototype,"section",void 0),e=n([t.Directive({selector:"[ngx-fullpage-go-to-section]"})],e)}(),v=function(){function e(){}return e=n([t.NgModule({declarations:[g],imports:[],exports:[g]})],e)}();e.NgxFullpageGoToLastModule=o,e.NgxFullpageGoToSectionModule=v,e.NgxFullpageModule=u,e.NgxFullpageNextButtonModule=p,e.NgxFullpageService=r,e.NgxFullpageToFirstButtonModule=h,e.ɵa=i,e.ɵb=l,e.ɵc=s,e.ɵd=c,e.ɵe=a,e.ɵf=f,e.ɵg=g,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ngx-free-fullpage.umd.min.js.map