diff --git a/.npmignore b/.npmignore
index dedd122..3a835e6 100644
--- a/.npmignore
+++ b/.npmignore
@@ -3,5 +3,5 @@ example
node_modules
/src
/*.*
-dist/dist-tsc
-dist/example
\ No newline at end of file
+./dist/dist-tsc
+./dist/example
\ No newline at end of file
diff --git a/README.md b/README.md
index d8459b0..d8ae272 100644
--- a/README.md
+++ b/README.md
@@ -188,6 +188,8 @@ NgModule({
| trigger | Trigger(string) | hover |
| popperModifiers | popperModifier | undefined|
| positionFixed | boolean | false |
+ | hideOnClickOutside | boolean | true |
+ | hideOnScroll | boolean | false |
9. popperPlacement:
diff --git a/example/app/app.component.html b/example/app/app.component.html
index b974bf0..6ef3644 100644
--- a/example/app/app.component.html
+++ b/example/app/app.component.html
@@ -5,7 +5,6 @@
[popper]="popper1Content"
[popperTrigger]="'click'"
[popperTarget]="popper1"
- [popperCloseOnClickOutside]="false"
[popperShowOnStart]="true"
[popperPlacement]="example1select" class="rel" id="example10reference1">
Pop
on the bottom
diff --git a/example/app/app.module.ts b/example/app/app.module.ts
index f45023a..3ebf1b7 100644
--- a/example/app/app.module.ts
+++ b/example/app/app.module.ts
@@ -2,17 +2,18 @@ import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {BrowserModule} from '@angular/platform-browser';
import {AppComponent} from './app.component';
-import {NgxPopperModule} from '../../dist/ngx-popper.js';
-import {testComponent} from './test/test';
-import { Draggable } from 'ng2draggable/draggable.directive';
+import {NgxPopperModule, Triggers} from '../../dist/ngx-popper.js';
+import {Draggable} from 'ng2draggable/draggable.directive';
@NgModule({
imports: [
BrowserModule,
FormsModule,
- NgxPopperModule.forRoot({trigger: 'hover'})],
+ NgxPopperModule.forRoot({
+ trigger: Triggers.NONE,
+ hideOnClickOutside: false
+ })],
declarations: [
- testComponent,
Draggable,
AppComponent],
providers: [],
diff --git a/example/app/test/test.ts b/example/app/test/test.ts
deleted file mode 100644
index 1c543e3..0000000
--- a/example/app/test/test.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import {Component, ElementRef, OnInit} from '@angular/core';
-@Component({
- selector: 'test-comp',
- template: `
-
test
- `
-})
-
-export class testComponent implements OnInit{
-
- constructor(private element: ElementRef){
-
- }
-
- ngOnInit(){
-
- }
-
-}
\ No newline at end of file
diff --git a/package.json b/package.json
index c28983c..85215a2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ngx-popper",
- "version": "1.9.0",
+ "version": "1.9.4",
"description": "ngx-popper is an angular wrapper for popper.js",
"directories": {
"test": "test"
@@ -8,7 +8,7 @@
"scripts": {
"test": "",
"build": "ng-packagr -p ng-package.json",
- "deploy": "npm run build && standard-version && npm publish --access=public dist",
+ "deploy": "npm run build && npm publish --access=public dist",
"dev": "webpack-dev-server"
},
"repository": {
diff --git a/src/popper-directive.ts b/src/popper-directive.ts
index 3755657..6f4e4ef 100644
--- a/src/popper-directive.ts
+++ b/src/popper-directive.ts
@@ -8,7 +8,7 @@ import {
OnChanges,
SimpleChange,
Output,
- EventEmitter, OnInit, Renderer2, ChangeDetectorRef
+ EventEmitter, OnInit, Renderer2, ChangeDetectorRef, Inject
} from '@angular/core';
import {PopperContent} from './popper-content';
import {Placement, Placements, PopperContentOptions, Trigger, Triggers} from './popper.model';
@@ -30,10 +30,12 @@ export class PopperController implements OnInit, OnChanges {
constructor(private viewContainerRef: ViewContainerRef,
private changeDetectorRef: ChangeDetectorRef,
private resolver: ComponentFactoryResolver,
- private renderer: Renderer2) {
+ private renderer: Renderer2,
+ @Inject('popperDefaults') private popperDefaults: PopperContentOptions) {
+ PopperController.baseOptions = {...this.popperDefaults, ...PopperController.baseOptions}
}
- static baseOptions: PopperContentOptions =
{};
+ public static baseOptions: PopperContentOptions = {};
@Input('popper')
content: string | PopperContent;
@@ -45,7 +47,7 @@ export class PopperController implements OnInit, OnChanges {
placement: Placement = Placements.Auto;
@Input('popperTrigger')
- showTrigger: Trigger;
+ showTrigger: Trigger | undefined;
@Input('popperTarget')
targetElement: HTMLElement;
@@ -66,13 +68,13 @@ export class PopperController implements OnInit, OnChanges {
showOnStart: boolean;
@Input('popperCloseOnClickOutside')
- closeOnClickOutside: boolean = true;
+ closeOnClickOutside: boolean;
@Input('popperHideOnClickOutside')
- hideOnClickOutside: boolean;
+ hideOnClickOutside: boolean | undefined;
@Input('popperHideOnScroll')
- hideOnScroll: boolean = false;
+ hideOnScroll: boolean | undefined;
@Input('popperPositionFixed')
positionFixed: boolean;
@@ -267,7 +269,9 @@ export class PopperController implements OnInit, OnChanges {
}
private setDefaults(){
- this.showTrigger = this.showTrigger || PopperController.baseOptions.trigger;
+ this.showTrigger = typeof this.showTrigger === 'undefined' ? PopperController.baseOptions.trigger : this.showTrigger;
+ this.hideOnClickOutside = typeof this.hideOnClickOutside === 'undefined' ? PopperController.baseOptions.hideOnClickOutside : this.hideOnClickOutside;
+ this.hideOnScroll = typeof this.hideOnScroll === 'undefined' ? PopperController.baseOptions.hideOnScroll : this.hideOnScroll;
}
private clearEventListeners() {
diff --git a/src/popper.model.ts b/src/popper.model.ts
index abd8da1..e4073e0 100644
--- a/src/popper.model.ts
+++ b/src/popper.model.ts
@@ -58,5 +58,7 @@ export interface PopperContentOptions {
boundariesElement?: string;
trigger?: Trigger;
positionFixed?: boolean;
+ hideOnClickOutside?: boolean;
+ hideOnScroll?: boolean;
popperModifiers?: {};
}
\ No newline at end of file
diff --git a/src/popper.module.ts b/src/popper.module.ts
index 5d3a730..65428c0 100644
--- a/src/popper.module.ts
+++ b/src/popper.module.ts
@@ -22,8 +22,7 @@ import {PopperContentOptions} from './popper.model';
})
export class NgxPopperModule {
ngDoBootstrap(){}
- public static forRoot(popperBaseOptions?: PopperContentOptions): ModuleWithProviders {
- PopperController.baseOptions = Object.assign(PopperController.baseOptions, popperBaseOptions || {});
- return {ngModule: NgxPopperModule, providers: []};
+ public static forRoot(popperBaseOptions: PopperContentOptions = {}): ModuleWithProviders {
+ return {ngModule: NgxPopperModule, providers: [{provide: 'popperDefaults', useValue: popperBaseOptions}]};
}
}
\ No newline at end of file