Socket
Book a DemoInstallSign in
Socket

ngx-media-query-watcher

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-media-query-watcher

An angular directive to easy listen and handle media query changes.

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
1
-75%
Maintainers
1
Weekly downloads
 
Created
Source

ngx-media-query-watcher Build Status

An angular directive to easy listen and handle on media query changes.

Donate/Support

If you like my work, feel free to support it. Donations to the project are always welcomed :)

Buy Me A Coffee

PayPal: PayPal.Me/bengtler

BTC Wallet Address: 3QVyr2tpRLBCw1kBQ59sTDraV6DTswq8Li

ETH Wallet Address: 0x394d44f3b6e3a4f7b4d44991e7654b0cab4af68f

LTC Wallet Address: MFif769WSZ1g7ReAzzDE7TJVqtkFpmoTyT

XRP Wallet Address: rXieaAC3nevTKgVu2SYoShjTCS2Tfczqx?dt=159046833

Installation

  • npm install ngx-media-query-watcher
  • install @angular/core, @angular/platform-browser and rxjs - they are peer dependencies

For standard webpack, angular-cli and tsc builds

  • import MediaQueryWatcherModule from ngx-media-query-watcher:
import { MediaQueryWatcherModule } from 'ngx-media-query-watcher'
  • add MediaQueryWatcherModule to the imports of your NgModule:
@NgModule({
  imports: [
    ...,

    MediaQueryWatcherModule
  ],
  ...
})
class YourModule { ... }
  • use <divmedia-query-watcher query="(min-width: 992px)" (mediaMatchChanged)="handleChange($event)"></div> in your templates to listen on a media query and handle a media query change.

For SystemJS builds (Config)

  • add ngx-media-query-watcher to your paths:
paths: {
  ...
  'ngx-media-query-watcher': 'node_modules/ngx-media-query-watcher/bundles/ngx-media-query-watcher.umd.js'
}
  • set format and dependencies in packages:
packages: {
  'ngx-media-query-watcher': {
    format: 'cjs'
  }
}
  • follow the steps of For standard webpack and tsc builds

MediaQueryWatcher Directive

Usage

  • selector: media-query-watcher - add it as attribute to a html-tag
  • property/input: query - pass a css media query here
  • output: mediaMatchChanged - get notified when a media query matchs or not

Example

<div
  media-query-watcher
  query="(min-width: 992px)"
  (mediaMatchChanged)="handleChange($event)"
>
  <p>hello</p>
</div>
class MyComponent {
  handleChange(match: boolean) {
    // handle match
  }
}

Keywords

angular

FAQs

Package last updated on 18 Aug 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