author import { AfterViewInit , Directive , ElementRef , Input , OnInit } from '@angular/core' ; import { MnFullpageOptions } from './mnFullpage-options.class' ; const DIRECTIVE_NAME = 'mnFullpage' ; @ Directive ( { selector : '[' + DIRECTIVE_NAME + ']' } ) export class MnFullpageDirective implements OnInit , AfterViewInit { /**
     * Prefix for directive-relative properties
     */ private static propertyPrefix : string = DIRECTIVE_NAME ; /**
     * Directive options reference
     */ @ Input ( DIRECTIVE_NAME ) public options : MnFullpageOptions ; /**
     * Index signature
     */ [ key ] : any ; see MnFullpageOptions @ Input ( ) public mnFullpageLicenseKey = 'OPEN-SOURCE-GPLV3-LICENSE' ; see MnFullpageOptions @ Input ( ) public mnFullpageMenu : string ; @ Input ( ) public mnFullpageLockAnchors : boolean ; @ Input ( ) public mnFullpageAnchors : Array < string > ; @ Input ( ) public mnFullpageNavigation : boolean ; @ Input ( ) public mnFullpageNavigationPosition : string ; @ Input ( ) public mnFullpageNavigationTooltips : Array < string > ; @ Input ( ) public mnFullpageShowActiveTooltip : boolean ; @ Input ( ) public mnFullpageSlidesNavigation : boolean ; @ Input ( ) public mnFullpageSlidesNavPosition : string ; see MnFullpageOptions @ Input ( ) public mnFullpageCss3 : boolean ; @ Input ( ) public mnFullpageScrollingSpeed : number ; @ Input ( ) public mnFullpageAutoScrolling : boolean ; @ Input ( ) public mnFullpageFitToSection : boolean ; @ Input ( ) public mnFullpageFitToSectionDelay : number ; @ Input ( ) public mnFullpageScrollBar : boolean ; @ Input ( ) public mnFullpageEasing : string ; @ Input ( ) public mnFullpageEasingcss3 : string ; @ Input ( ) public mnFullpageLoopBottom : boolean ; @ Input ( ) public mnFullpageLoopTop : boolean ; @ Input ( ) public mnFullpageLoopHorizontal : boolean ; @ Input ( ) public mnFullpageContinuousVertical : boolean ; @ Input ( ) public mnFullpageContinuousHorizontal : boolean ; @ Input ( ) public mnFullpageInterlockedSlides : boolean ; @ Input ( ) public mnFullpageDragAndMove : boolean ; @ Input ( ) public mnFullpageOffsetSections : boolean ; @ Input ( ) public mnFullpageResetSliders : boolean ; @ Input ( ) public mnFullpageFadingEffect : boolean ; @ Input ( ) public mnFullpageNormalScrollElements : string ; @ Input ( ) public mnFullpageScrollOverflow : boolean ; @ Input ( ) public mnFullpageScrollOverflowReset : boolean ; @ Input ( ) public mnFullpageScrollOverflowOptions : object ; @ Input ( ) public mnFullpageTouchSensitivity : number ; @ Input ( ) public mnFullpageNormalScrollElementTouchThreshold : number ; @ Input ( ) public mnFullpageBigSectionsDestination : object ; see MnFullpageOptions @ Input ( ) public mnFullpageKeyboardScrolling : boolean ; @ Input ( ) public mnFullpageAnimateAnchor : boolean ; @ Input ( ) public mnFullpageRecordHistory : boolean ; see MnFullpageOptions @ Input ( ) public mnFullpageControlArrows : boolean ; @ Input ( ) public mnFullpageVerticalCentered : boolean ; @ Input ( ) public mnFullpageResize : boolean ; @ Input ( ) public mnFullpageSectionsColor : Array < string > ; @ Input ( ) public mnFullpagePaddingTop : string ; @ Input ( ) public mnFullpagePaddingBottom : string ; @ Input ( ) public mnFullpageFixedElements : string ; @ Input ( ) public mnFullpageResponsiveWidth : number ; @ Input ( ) public mnFullpageResponsiveHeight : number ; @ Input ( ) public mnFullpageResponsiveSlides : boolean ; @ Input ( ) public mnFullpageParallax : boolean ; @ Input ( ) public mnFullpageParallaxOptions : object ; see MnFullpageOptions @ Input ( ) public mnFullpageSectionSelector : string ; @ Input ( ) public mnFullpageSlideSelector : string ; see MnFullpageOptions @ Input ( ) public mnFullpageLazyLoading : boolean ; see MnFullpageOptions @ Input ( ) public mnFullpageAfterLoad : ( origin : object , destination : object , direction : string ) => void ; @ Input ( ) public mnFullpageOnLeave : ( origin : object , destination : object , direction : string ) => void ; @ Input ( ) public mnFullpageAfterRender : ( ) => void ; @ Input ( ) public mnFullpageAfterResize : ( width : number , height : number ) => void ; @ Input ( ) public mnFullpageAfterResponsive : ( isResponsive : boolean ) => void ; @ Input ( ) public mnFullpageAfterSlideLoad : ( section : object , origin : object , destination : object , direction : string ) => void ; @ Input ( ) public mnFullpageOnSlideLeave : ( section : object , origin : object , destination : object , direction : string ) => void ; /**
     * ---------------------------------------------------------------------------
     * |                              Class properties                           |
     * ---------------------------------------------------------------------------
     */ private _el : ElementRef ; param property returns private static extractName ( property ) { return property [ MnFullpageDirective . propertyPrefix . length ] . toLowerCase ( ) + property . substring ( MnFullpageDirective . propertyPrefix . length + 1 ) ; } param options param el public constructor ( el , options ? ) { this . _el = el ; if ( options ) { this . options = options ; } } /**
     * Perform actions on init
     */ ngOnInit ( ) { } /**
     * Perform actions on view init
     */ ngAfterViewInit ( ) { /**
         * Initialize options object with default (empty)
         * values if it doesn't exist
         */ if ( ! this . options ) { this . options = new MnFullpageOptions ( ) ; } /**
         * Iterate over all properties of directive class
         */ for ( const property of Object . keys ( this ) ) { /**
             * If property name doesn't start with 'fullpage' prefix (it is stored in
             * FullpageDirective.propertyPrefix static property) then skip this property and
             * continue the cycle
             */ if ( ! property . startsWith ( MnFullpageDirective . propertyPrefix ) ) { continue ; } /**
             * Extract option name from the property name
             */ const option = MnFullpageDirective . extractName ( property ) ; /**
             * If options is already defined skip it
             */ if ( this . options [ option ] ) { continue ; } /**
             * Set property value to the options object property
             */ this . options [ option ] = this [ property ] ; } /**
         * Enable fullpage for the element
         */ ( < any > $ ) ( this . _el . nativeElement ) . fullpage ( < object > this . options ) ; } }