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

js-viewpane

v0.2.0

Published

> simple, feelgood, pan and zoomable image or HTML container

Downloads

4

Readme

Viewpane

simple, feelgood, pan and zoomable image or HTML container

Viewpane enables an image or any HTML Container to be pan- and zoomable within a given parent container. In some way this is a subset of iScroll or comparable script, but it offers a smoother scrolling experience and a more natural (iOS) rubberband. Additional, viewpane toys with being in 3D space, enabling perspective experiments with css or js.

bower install viewpane

You can checkout the demos page to get an impression what it does.

usage


    #camera {
        position: relative;
        width: 100%;
        height: 100%;
        overflow: hidden;    
    }

    #viewpane {
        position: absolute;
        transform-style: preserve-3d
    }

    <div id="camera">
        <div id="viewpane"></div>
    </div>

    var viewpane = new Viewpane("camera", "viewpane", options);

options

    {
        // friction used on animation to stop user input. Values [0, 1[
        friction: 0.91,             
        // type of valid positions. May also be "fitBothDimensions"
        // Also `Viewpane.FOCUS_TYPE.BOTH` or `Viewpane.FOCUS_TYPE.LARGEST`
        typeOfFocus: "fitLargestDimension",     
        // The area to focus camera (bound, rubberband)
        // Default: viewpane-element dimensions
        focus: {x: 2048, y: 1024},
        // perspective of camera. Values [0, Infinity[. Default 1000  
        perspective: 1000,      
        // perspective origin. Values [0, 1]. Default (0.5, 0.5)    
        origin: {x: 0.5, y: 0.5},
        // enable rubberband on z-axis. Default true
        rubberZ: true
    }

events

Event names are also accessible view Viewpane.EVENT_*

    
    var viewpane = new Viewpane("camera", "viewpane", options);

    viewpane.addObserver("onClick", function (event, clickOrigin) {
        // viewpane has been clicked
    });

    viewpane.addObserver("onRender", function (position) {
        // viewpane has updated visually
    });

    viewpane.addObserver("onUpdate", function (position) {
        // viewpane has updated calculations
    });

    viewpane.addObserver("onInputStart", function () {
        // user input starts
    });

    viewpane.addObserver("onInputStop", function () {
        // user input has ended
    });

    viewpane.addObserver("onEnd", function () {
        // all animations and input has stopped
    });

api

viewpane

method | description ------------------------------------|-------------------------------------------------------------------- activate() | activate userinteraction (default) deactivate() | deactivate user interaction fit() | centers the contents (position, scale) to the viewport addObserver(eventName, callback) | add an event listener (@see events) repaint() | redraws viewpane addEntity(Viewpane.Entity) | adds another entity which is translated by the viewpane (camera)

requirements

exported utilities

for details see the corresponding sourcefiles.

    // viewpane entity (renderable)
    Viewpane.Entity
    // animation loop
    Viewpane.Loop
    // vector class
    Viewpane.Vector
    // types of viewpane bounds
    Viewpane.FOCUS_TYPE

performance

  • ensure images are a multiple of 2 (i.e. use 2048x1024, but NOT 2048x1025). Especially on iOS

known bugs

  • sometimes zoomIn does not trigger rubberband animation

  • Browserbugs

    • iOS 9.0.x, transform-style: preserve-3d flickering 3d layers

      • Currently there is no css workaround @see Stackoverflow. The attribute overflow: hidden does not work with the transform-style: preserve3d options.

      • for the viewpane, the only workaround is to use js entities instead of css. See the demos page for details.