Skip to content

Commit

Permalink
add forRoot default
Browse files Browse the repository at this point in the history
  • Loading branch information
MrFrankel committed Jan 1, 2018
1 parent 714c820 commit 780f911
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,20 @@ SystemJS
| popperOnShown | EventEmitter<void>| $event |
| popperOnHidden | EventEmitter<void>| $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 |
Expand All @@ -178,7 +185,7 @@ constructor() {
| boundariesElement | string(selector) | undefined|
| trigger | Trigger(string) | hover |
| popperModifiers | popperModifier | undefined|
| positionFixed | boolean | false |

9. popperPlacement:

Expand Down
1 change: 0 additions & 1 deletion example/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[popperTrigger]="'click'"
[popperTarget]="popper1"
[popperShowOnStart]="true"
[popperPositionFixed]="true"
[popperPlacement]="example1select" class="rel" id="example10reference1">
<p class="bold">Hey!</p>
<p class="thin">Choose where to put your popper!</p>
Expand Down
2 changes: 1 addition & 1 deletion example/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Draggable } from 'ng2draggable/draggable.directive';
imports: [
BrowserModule,
FormsModule,
NgxPopperModule],
NgxPopperModule.forRoot({positionFixed: false})],
declarations: [
testComponent,
Draggable,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
14 changes: 7 additions & 7 deletions src/popper.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?: {};
}
9 changes: 6 additions & 3 deletions src/popper.module.ts
Original file line number Diff line number Diff line change
@@ -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: [
Expand All @@ -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: []};
}
}

0 comments on commit 780f911

Please sign in to comment.