angular-breakpoints
Advanced tools
Comparing version 1.0.1 to 1.0.2
22
index.js
@@ -28,6 +28,12 @@ "use strict"; | ||
exports.breakpointsProvider = function (breakpoints) { | ||
return core_1.provide(BreakpointsService, { useValue: new BreakpointsService(breakpoints) }); | ||
return core_1.provide(BreakpointsService, { | ||
useFactory: function (ngZone) { | ||
return new BreakpointsService(ngZone, breakpoints); | ||
}, | ||
deps: [core_1.NgZone] | ||
}); | ||
}; | ||
var BreakpointsService = (function () { | ||
function BreakpointsService(breakpoints) { | ||
function BreakpointsService(ngZone, breakpoints) { | ||
this.ngZone = ngZone; | ||
this.breakpoints = defaultBreakpoints; | ||
@@ -56,3 +62,11 @@ this.setBreakpoints(breakpoints); | ||
var breakpoint = _this.getBreakpoint(size.width); | ||
_this.changesSubject.next(_this.getBreakpointEvent(breakpoint)); | ||
if (core_1.NgZone.isInAngularZone()) { | ||
_this.changesSubject.next(_this.getBreakpointEvent(breakpoint)); | ||
} | ||
else { | ||
// NgZone doesnt listen to resize window event, so we have to run this in NgZone to run change detection | ||
_this.ngZone.run(function () { | ||
_this.changesSubject.next(_this.getBreakpointEvent(breakpoint)); | ||
}); | ||
} | ||
}); | ||
@@ -95,3 +109,3 @@ }; | ||
core_1.Injectable(), | ||
__metadata('design:paramtypes', [Object]) | ||
__metadata('design:paramtypes', [Object, Object]) | ||
], BreakpointsService); | ||
@@ -98,0 +112,0 @@ return BreakpointsService; |
23
index.ts
@@ -1,2 +0,2 @@ | ||
import { Injectable, provide } from '@angular/core'; | ||
import { Injectable, provide, NgZone } from '@angular/core'; | ||
import { Observable } from 'rxjs/Observable'; | ||
@@ -44,3 +44,9 @@ import { BehaviorSubject } from 'rxjs/BehaviorSubject'; | ||
return provide(BreakpointsService, { useValue: new BreakpointsService(breakpoints) }); | ||
return provide(BreakpointsService, { | ||
useFactory (ngZone) { | ||
return new BreakpointsService(ngZone, breakpoints) | ||
}, | ||
deps: [NgZone] | ||
}); | ||
} | ||
@@ -59,3 +65,3 @@ | ||
constructor (breakpoints?: BreakpointConfig) { | ||
constructor (private ngZone, breakpoints?: BreakpointConfig) { | ||
@@ -91,3 +97,12 @@ this.setBreakpoints(breakpoints); | ||
const breakpoint: string = this.getBreakpoint(size.width); | ||
this.changesSubject.next(this.getBreakpointEvent(breakpoint)); | ||
if (NgZone.isInAngularZone()) { | ||
this.changesSubject.next(this.getBreakpointEvent(breakpoint)); | ||
} | ||
else { | ||
// NgZone doesnt listen to resize window event, so we have to run this in NgZone to run change detection | ||
this.ngZone.run(() => { | ||
this.changesSubject.next(this.getBreakpointEvent(breakpoint)); | ||
}); | ||
} | ||
}); | ||
@@ -94,0 +109,0 @@ } |
{ | ||
"name": "angular-breakpoints", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Angular 2 service to programmatically listen to breakpoints", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
14617
249
0