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

ribcage-switcher

v0.4.1

Published

A left and right view switcher for ribcage-ui

Downloads

8

Readme

Ribcage Switcher

A left and right swiping view switcher for ribcage-ui.

Install

npm install ribcage-switcher

Use


  var Switcher = require('ribcage-switcher')
    , ribcage = require('ribcage-view')
    , FirstView
    , NextView = require('NextView')

  FirstView = ribcage.extend({
    events: {'click a': 'push'}
  , template: '<a href="#">Push</a>'
  , push: function () {
      this.trigger('push', new NextView({rootView: this}))
    }
  })

  var switcher = new Switcher({
    rootView: new FirstView()
  })

  // See tests for a more complex example

Events

Triggering these events on a pane will cause the switcher to respond

  • push - Pass a view as the first argument, and the switcher will push it onto the stack and move to the new view
  • pop - Goes to the previous view and pops the last one off the stack
  • goToView - Pass a view as the first argument, and the switcher will backtrack there, popping off views as it goes
  • replace - Pass a view as the first argument, and the switcher will replace the current pane with that view

Legacy Use


  var Switcher = require('ribcage-switcher')

  var switcher = new Switcher({
    depth: 2
  })

  switcher.setPane(0, myView)
  switcher.setPane(1, myOtherView)

  switcher.goToPane(0)
  switcher.next()
  switcher.previous()

Transition Events

The switcher will send panes transition:start and transition:end events.

  // Fires `transition:start` immediately, and `transition:end` approx. 270-300ms later.
  switcher.next()

  // You can disable these events on a per-call basis
  switcher.goToPane(0, true)
  switcher.next(true)
  switcher.prev(true)

The switcher itself also emits transition:start and transition:end events.

  switcher.on('transition:end', function (paneIndex, paneView) {
    // Do something
  })

Throttling Pane Renders

Rendering subviews in the middle of a transition can result in interface lag. Avoiding this issue is easy with panes that extend from ribcage-view.

  var myPane = require('ribcage-view').extend({
    throttle: true  // Defaults to false
  })

  switcher.setPane(1, myPane)

  myPane.render() // Will run immediately

  switcher.next() // Start moving to the next pane

  setTimeout(function () {
    myPane.render() // Will run only after the switcher has transitioned
  }, 100)