Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gondel/plugin-media-queries

Package Overview
Dependencies
Maintainers
3
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gondel/plugin-media-queries

Provide a custom gondel event which will fire once a given media query is met

  • 1.2.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
416
increased by42.96%
Maintainers
3
Weekly downloads
 
Created
Source

MediaQueries Plugin

NPM version Size License Commitizen friendly Prettier

Installation

import {initMediaQueriesPlugin} from '@gondel/plugin-media-queries';

initMediaQueriesPlugin({ 
  breakPoints: {
    xxsmall: 480,
    xsmall: 768,
    small: 992,
    medium: 1240,
    large: 1440,
    xlarge: 1920,
    xxlarge: Infinity,
  }
});

Please note: the provided breakpoints need to be the maximum value of each viewport in px.

Viewport entered

  import { VIEWPORT_ENTERED } from '@gondel/plugin-media-queries';

The general viewport entered event is fired if the viewport switches into one of the provided breakpoints

  @EventListener(VIEWPORT_ENTERED)
  handleViewportChange(event) {
     console.log(event.viewport);
  }

Restrict to certain viewport

Additionally, the event listener can be restricted to just one specific viewport

  @EventListener(VIEWPORT_ENTERED, 'medium')
  handleViewportChange(event) {
     console.log('You are now on the medium viewport');
  }

getCurrentViewport

  import { getCurrentViewport } from '@gondel/plugin-media-queries';

Additionally you can always get the current viewport name by using the getCurrentViewport helper.

start() {
  console.log(getCurrentViewport());
  // output's e.g. "medium"
}

Known Issues

The initMediaQueriesPlugin has to be called before you call startComponents.

License

MIT license

FAQs

Package last updated on 19 May 2023

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc