Socket
Book a DemoInstallSign in
Socket

@impactdk/ngx-breakpoints

Package Overview
Dependencies
Maintainers
5
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@impactdk/ngx-breakpoints

An Angular wrapper for `@impactdk/breakpoints`

1.2.0
latest
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
5
Weekly downloads
 
Created
Source

ngx-breakpoints

This module gives you some tools to subscribe to viewport changes

Configuration

The module acts on certain breakpoints that you provide to it. If you don't provide any breakpoints, the module will fall back to some built-in breakpoints. You should configure the module with your own breakpoints by providing a list of the Breakpoint type:

export const breakpoints: Breakpoints = [
    Breakpoint.fromWidth('small', { maxWidth: 567 }),
    Breakpoint.fromWidth('medium', { minWidth: 568, maxWidth: 767 }),
    Breakpoint.fromWidth('large', { minWidth: 768, maxWidth: 1024 }),
    Breakpoint.fromWidth('xlarge', { minWidth: 1025 }),
    Breakpoint.fromQuery(
        'small retina',
        'only screen and (min-resolution: 192dpi) and (max-width: 567px)'
    ),
    Breakpoint.fromQuery(
        'medium retina',
        'only screen and (min-resolution: 192dpi) and (min-width: 568px) and (max-width: 767px)'
    ),
    Breakpoint.fromQuery(
        'large retina',
        'only screen and (min-resolution: 192dpi) and (min-width: 768px) and (max-width: 1024px)'
    ),
    Breakpoint.fromQuery(
        'xlarge retina',
        'only screen and (min-resolution: 192dpi) and (min-width: 1025px)'
    ),
];

@NgModule({
    imports: [BreakpointsModule.withConfiguration(breakpoints)],
})
class AppModule {}

Additionally you can provide a set of SSR options:

{
    defaultSize {
        width: 375;
        height: 667;
    }
}

Usage

Import the BreakpointService in a component and subscribe to the breakpoint observable:

breakpoint$: Observable that provides you with objects of the type Breakpoint that matches the breakpoints you provided in the configuration.

class Breakpoint {
    name: string;
    mediaQuery: string;
}

Or you can check the viewport size and scrollbar width:

getScrollbarWidth(): The width of the scrollbar in pixels

getSize(): The size in pixels of the viewport represented as a ScreenSize object

class ScreenSize {
    width: number;
    height: number;
}

FAQs

Package last updated on 15 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.