diff --git a/README.md b/README.md index 39d44cc..5580947 100644 --- a/README.md +++ b/README.md @@ -161,13 +161,20 @@ SystemJS | popperOnShown | EventEmitter| $event | | popperOnHidden | EventEmitter| $event | -8. Override default +8. Override default + Ngx-popper comes with a few default properties you can override in default to effect all instances + These are overridden by any child attributes. ```JavaScript -// Simply override PopperController baseOptions, this will apply to all popper that do not have an attribute set -// This is a static reference and should run ASAP, preferably before the angular application is bootstrapped -constructor() { - PopperController.baseOptions.disableAnimation = true; - } +NgModule({ + imports: [ + BrowserModule, + FormsModule, + NgxPopperModule.forRoot({placement: 'bottom'})], + declarations: [AppComponent], + providers: [], + bootstrap: [AppComponent] + +}) ``` | Options | Type | Default | @@ -178,7 +185,7 @@ constructor() { | boundariesElement | string(selector) | undefined| | trigger | Trigger(string) | hover | | popperModifiers | popperModifier | undefined| - + | positionFixed | boolean | false | 9. popperPlacement: diff --git a/example/app/app.component.html b/example/app/app.component.html index ca9c4d2..12e0e4a 100644 --- a/example/app/app.component.html +++ b/example/app/app.component.html @@ -6,7 +6,6 @@ [popperTrigger]="'click'" [popperTarget]="popper1" [popperShowOnStart]="true" - [popperPositionFixed]="true" [popperPlacement]="example1select" class="rel" id="example10reference1">

Hey!

Choose where to put your popper!

diff --git a/example/app/app.module.ts b/example/app/app.module.ts index 5119199..0e26701 100644 --- a/example/app/app.module.ts +++ b/example/app/app.module.ts @@ -10,7 +10,7 @@ import { Draggable } from 'ng2draggable/draggable.directive'; imports: [ BrowserModule, FormsModule, - NgxPopperModule], + NgxPopperModule.forRoot({positionFixed: false})], declarations: [ testComponent, Draggable, diff --git a/package.json b/package.json index 8ac31c1..e379177 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-popper", - "version": "1.8.1", + "version": "1.8.3", "description": "ngx-popper is an angular wrapper for popper.js", "directories": { "test": "test" diff --git a/src/popper.model.ts b/src/popper.model.ts index 22013e6..abd8da1 100644 --- a/src/popper.model.ts +++ b/src/popper.model.ts @@ -52,11 +52,11 @@ export class Placements { } export interface PopperContentOptions { - disableAnimation: boolean; - disableDefaultStyling: boolean; - placement: Placement; - boundariesElement: string; - trigger: Trigger; - positionFixed: boolean; - popperModifiers: {}; + disableAnimation?: boolean; + disableDefaultStyling?: boolean; + placement?: Placement; + boundariesElement?: string; + trigger?: Trigger; + positionFixed?: boolean; + popperModifiers?: {}; } \ No newline at end of file diff --git a/src/popper.module.ts b/src/popper.module.ts index 0170552..5d3a730 100644 --- a/src/popper.module.ts +++ b/src/popper.module.ts @@ -1,7 +1,8 @@ import {CommonModule} from "@angular/common"; -import {NgModule} from "@angular/core"; +import {ModuleWithProviders, NgModule} from "@angular/core"; import {PopperController} from './popper-directive'; import {PopperContent} from './popper-content'; +import {PopperContentOptions} from './popper.model'; @NgModule({ imports: [ @@ -20,7 +21,9 @@ import {PopperContent} from './popper-content'; ] }) export class NgxPopperModule { - ngDoBootstrap(){ - + ngDoBootstrap(){} + public static forRoot(popperBaseOptions?: PopperContentOptions): ModuleWithProviders { + PopperController.baseOptions = Object.assign(PopperController.baseOptions, popperBaseOptions || {}); + return {ngModule: NgxPopperModule, providers: []}; } } \ No newline at end of file