npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

radjs-drawer

v1.0.1

Published

Drawer widget for web page

Downloads

9

Readme

Drawer

Organize widgets as drawer and content layers inside wrapper layer.

Example

###Dependency

Drawer can work with different devices and support different user input method such as mouse or touch. Therefore your wrapper layer should support point and tap events, it is needed for compatibility with different devices. Drawer uses next events:

  • tap
  • pointerup
  • pointermove
  • pointerdown
  • pointercancel
  • fling

so before instance drawer you should add support pointer and tap events for wrapper layer. We recommend use our modules Pointer and Gesture. ###Initialization At first You should make wrapper layer with two layers first layer will be used as drawer, second one as content.

<div class = "wrapper_layer">
    <div class="drawer_layer">

    </div>
    <div class="content_layer">
        
    </div>
</div>

GitHub Logo

Next step - make instance of Drawer with wrapper element.

var wrapper = document.querySelector('.wrapper_layer'),
    tracker = new PointerTracker(wrapper),
    gesture = new GestureTracker(wrapper);
drawer = new Drawer(wrapper);

Now your widget will have next view when drawer is close

GitHub Logo

and such view when drawer is open

GitHub Logo ####Options parameters You can customize behavior of drawer for this you should initialize drawer with options object

    drawer = new Drawer(wrapper, {
        align: 'right',
        maxWidth: '30%',
        startTrackingZone: '50',
        animationTime: 1000,
        onActionEnd: function (drawerState) {
            console.log(drawerState ? 'close' : 'open');
        }
    });

Here is list of options object fields. if you don't set one or more fields they will be set with default value. If you init drawer without options object,

drawer = new Drawer(wrapper);

drawer will be init with default parameters from this list.

|Parametr| Default value |Description| |--------|:-------------------------:|-----------| |align|left| set align for drawer: left/right/top/bottom| |overlay|true | Add overlay layer over content layout| |overlayOpacity| true|Makes overlay layer opaque if set as true or transparent if set false| |overlayBackground| rgba(0, 0, 0, 0.4)| Color which will be filled overlay layer| |swipe| true| Enable/Disable swiping content layout| |preventMove| true| Enable/Disable native scroll in drover layout for Android OS| |resizeEvent| true| Allows automatically resizes drawer and content layouts| |maxWidth| 70%|Percent value of drawer layout width| |startTrackingZone| 20%| Percent value of area width which allows swipe content layout| |animationTime| 350|Duration of animation close/open drawer bar in ms| |onActionEnd| empty function| Callback functions will be called after drawer changes state from close to open or conversely| |onActionStart|empty function| Callback functions will be called before drawer changes state from closed to open or conversely| ###Methods ####setEnableSwipe(isEnable) Enable/Disable reaction for swipe gesture. You can change state of swipe any time, this key has the same behavior as swipe field of options object.

drawer.setEnableSwipe(false);

####isEnableSwipe() Return boolean value is swipe mode enabled or disabled.

var isEnable = drawer.isEnableSwipe();

####isClosed() Return boolean value about drawer state true - if is close, false - if is open.

var isDrawerClose =drawer.isClosed();

####setOnActionStartCallback(onActionStartCallback) Method takes as parameter callback function. It rewrites callback function that was set in options parameter onActionStart and has the same behavior.

      drawer.setOnActionStartCallback(function (state) {
          console.log("Action start");
      });

####setOnActionEndCallback(onActionEndCallback) Method takes as parameter callback function. It rewrites callback function that was set in options parameter onActionEnd and has the same behavior.

      drawer.setOnActionEndCallback(function (state) {
          console.log("Action end");
      });

####refresh() Updates size parameters of wrapper, drawer and content layers. This method will be automatically called when content layer will be resized. It need for correct work of drawer after size was changed.

drawer.refresh();