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

enquire.js

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

enquire.js

Awesome Media Queries in JavaScript

  • 2.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1M
increased by7.07%
Maintainers
1
Weekly downloads
 
Created

What is enquire.js?

enquire.js is a lightweight, pure JavaScript library for handling media queries in a responsive design. It allows developers to register and unregister callbacks for media query changes, making it easier to manage responsive behaviors in web applications.

What are enquire.js's main functionalities?

Registering a Media Query

This feature allows you to register a media query and define callbacks for when the media query is matched or unmatched. In this example, a message is logged to the console when the screen width is less than or equal to 600px and another message when it is greater.

enquire.register("(max-width: 600px)", {
  match: function() {
    console.log("Screen width is less than or equal to 600px");
  },
  unmatch: function() {
    console.log("Screen width is greater than 600px");
  }
});

Unregistering a Media Query

This feature allows you to unregister a previously registered media query. In this example, the media query for a screen width of 600px is first registered and then unregistered.

var handler = {
  match: function() {
    console.log("Screen width is less than or equal to 600px");
  },
  unmatch: function() {
    console.log("Screen width is greater than 600px");
  }
};
enquire.register("(max-width: 600px)", handler);
enquire.unregister("(max-width: 600px)", handler);

Using Multiple Handlers

This feature allows you to register multiple handlers for a single media query. In this example, two handlers are registered for the same media query, each logging different messages to the console.

enquire.register("(max-width: 600px)", [
  {
    match: function() {
      console.log("Handler 1: Screen width is less than or equal to 600px");
    },
    unmatch: function() {
      console.log("Handler 1: Screen width is greater than 600px");
    }
  },
  {
    match: function() {
      console.log("Handler 2: Screen width is less than or equal to 600px");
    },
    unmatch: function() {
      console.log("Handler 2: Screen width is greater than 600px");
    }
  }
]);

Other packages similar to enquire.js

Keywords

FAQs

Package last updated on 14 Mar 2017

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