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

rwd-handler

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rwd-handler

Handling responsive website behavior.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

RwdHandler

Handling responsive behavior.

Execute given behavior under specific width, and execute rollback function when the screen width not in the specific width.


Installation

Just clone or download the zip of this repository

or via npm:

# npm install --save rwd-handler

or

$ yarn add rwd-handler

Setup

<script src='path/to/RwdHandler.min.js'></script>

or

// import in your .js file
import RwdHandler from 'rwd-handler';

RwdHandler()

  • minWidth: number Minimum width of screen.
  • maxWidth: number Maximum width of screen.
  • behavior: function
    The function going to execute under given screen width.
  • rollback: function
    The function for returning behavior to previous state.

NOTE: If rollback function is given and an event listener is added in behavior, the event should call off() in rollback function. e.g. $(element).off('event'), or call off() before bind the event in behavior. e.g. $(element).off('event').on('event', fn).

const rwdHandler = new RwdHandler({
    minWidth: 480,
    maxWidth: 720,
    behavior: rwdBehavior, //behavior function
    rollback: rollback //rollback function
});

execute()

Execute rwd behavior under specific width, and execute rollback function when the screen width not in the specific width.

rwdHandler.execute();

stopExecute()

Stop executing rwd behavior.

rwdHandler.stopExecute();

changeDetectWidth(minWidth, maxWidth)

Change rwd detect width.

  • minWidth: number Minimum width of screen.
  • maxWidth: number Maximum width of screen.
rwdHandler.changeDetectWidth(0, 720);

changeBehavior(behavior)

Change rwd behavior.

  • behavior: function
    The function going to execute under given screen width.
rwdHandler.changeBehavior(behavior);

changeRollback(rollback)

Change rwd rollback function.

  • rollback: function
    The function for returning behavior to previous state.
rwdHandler.changeRollback(rollback);

changeConfig(options)

Change all handler config.

  • options: object
    RwdHandler options.
rwdHandler.changeConfig(options);

Keywords

FAQs

Package last updated on 08 Apr 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