angular-breakpoints
Advanced tools
Comparing version 1.1.2 to 1.2.0
31
index.js
@@ -19,3 +19,3 @@ "use strict"; | ||
require("rxjs/add/operator/distinctUntilChanged"); | ||
var defaultBreakpoints = { | ||
exports.defaultBreakpoints = { | ||
xs: { max: 768 }, | ||
@@ -29,9 +29,22 @@ sm: { min: 768, max: 992 }, | ||
}; | ||
exports.breakpointsProvider = function (breakpoints) { | ||
return { | ||
provide: BreakpointsService, | ||
useFactory: function (ngZone) { return new BreakpointsService(ngZone, breakpoints); }, | ||
deps: [core_1.NgZone] | ||
}; | ||
}; | ||
exports.BREAKPOINTS_CONFIG = new core_1.InjectionToken('breakpoints.config'); | ||
function breakpointsFactory(ngZone, breakpoints) { | ||
return new BreakpointsService(ngZone, breakpoints); | ||
} | ||
exports.breakpointsFactory = breakpointsFactory; | ||
function breakpointsProvider(breakpoints) { | ||
if (breakpoints === void 0) { breakpoints = exports.defaultBreakpoints; } | ||
return [ | ||
{ | ||
provide: exports.BREAKPOINTS_CONFIG, | ||
useValue: breakpoints | ||
}, | ||
{ | ||
provide: BreakpointsService, | ||
useFactory: breakpointsFactory, | ||
deps: [core_1.NgZone, exports.BREAKPOINTS_CONFIG] | ||
} | ||
]; | ||
} | ||
exports.breakpointsProvider = breakpointsProvider; | ||
var BreakpointsService = /** @class */ (function () { | ||
@@ -41,3 +54,3 @@ function BreakpointsService(ngZone, breakpoints) { | ||
this.lastBreakpoint = null; | ||
this.breakpoints = defaultBreakpoints; | ||
this.breakpoints = exports.defaultBreakpoints; | ||
this.setBreakpoints(breakpoints); | ||
@@ -44,0 +57,0 @@ this.resize = Observable_1.Observable.fromEvent(window, 'resize').map(this.getWindowSize).distinctUntilChanged(); |
30
index.ts
@@ -1,2 +0,2 @@ | ||
import { Injectable, NgZone } from '@angular/core'; | ||
import { Injectable, NgZone, InjectionToken, Provider } from '@angular/core'; | ||
import { Observable } from 'rxjs/Observable'; | ||
@@ -31,3 +31,3 @@ import { BehaviorSubject } from 'rxjs/BehaviorSubject'; | ||
const defaultBreakpoints: BreakpointConfig = { | ||
export const defaultBreakpoints: BreakpointConfig = { | ||
xs: { max: 768 }, | ||
@@ -43,12 +43,24 @@ sm: { min: 768, max: 992 }, | ||
export const breakpointsProvider = function (breakpoints?: BreakpointConfig) { | ||
return { | ||
provide: BreakpointsService, | ||
useFactory: (ngZone) => new BreakpointsService(ngZone, breakpoints), | ||
deps: [NgZone] | ||
} | ||
export const BREAKPOINTS_CONFIG = new InjectionToken<BreakpointConfig>('breakpoints.config'); | ||
export function breakpointsFactory (ngZone: NgZone, breakpoints: BreakpointConfig) { | ||
return new BreakpointsService(ngZone, breakpoints) | ||
} | ||
export function breakpointsProvider (breakpoints: BreakpointConfig = defaultBreakpoints): Provider[] { | ||
return [ | ||
{ | ||
provide: BREAKPOINTS_CONFIG, | ||
useValue: breakpoints | ||
}, | ||
{ | ||
provide: BreakpointsService, | ||
useFactory: breakpointsFactory, | ||
deps: [NgZone, BREAKPOINTS_CONFIG] | ||
} | ||
]; | ||
} | ||
@Injectable() | ||
@@ -55,0 +67,0 @@ export class BreakpointsService { |
{ | ||
"name": "angular-breakpoints", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "Angular 2 service to programmatically listen to breakpoints", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"typings-install": "npm run typings install", | ||
"prepublish": "npm run typings-install && npm run tsc" | ||
"prepare": "npm run tsc" | ||
}, | ||
@@ -14,0 +14,0 @@ "repository": { |
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
15703
269
6