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

we-scroll

v1.1.3

Published

Touch scroll library for Muti Touch, Zooming, based on IScroll-zom 5

Downloads

19

Readme

weScroll

Touch scroll library for Muti Touch, Zooming, based on IScroll-zom 5

Features

  • IScroll API

  • Support Canvas

Usage


import WeScroll from 'we-scroll'

const defaultConfig = {
    zoom: true,
    zoomMin: 0.5,
    startZoom: 1,
    tap: true,
    zoomMax: 2,
    contentWidth: 2000, //width of scrolling area, Canvas needs it
    contentHeight: 1000, //height of scrolling area, Canvas needs it
    render: renderFunc //render function for updating Canvas
}
const scroller = new WeScroll(wrapper, defaultConfig)
scroller.zoom(2)

Some Configs

options.render

This is a callback function for weScroll. WeScroll calls render function when data ( offset , scale ) change. This function take three arguments: offsetX, offsetY, scale.

offsetX, offsetY represents scroller current offset, scale represents scroller current zoom ratio.

Style change like css transform or Canvas redraw logic should run in this function. Such as:

function(offsetX, offsetY, scale){
  var transformStyle = "translate3d(" + offsetX + "px," + offsetY +"px, 0px) scale("+ scale +")";
    target.style.transform = transformStyle;
}

Please make sure the origin for transformations of an element need to be set to:

transform-origin: 0px 0px 0px;

options.contentWidth

Scroll content width,default value is wrapper's client width.

options.contentHeight

Scroll content height,default value is wrapper's client height.

Examples

See examples: npm run static

  • simple

  • canvas zoom

  • css transform

  • transform preview

API reference

WeScroll

weScroll: Canvas scroll library for Muti Touch, Zooming, based on IScroll-zom 5

Kind: global class

new WeScroll(el, options)

create a WeScroll instance

| Param | Type | Description | | --- | --- | --- | | el | String | HTMLElement | wrapper of Canvas | | options | Obect | options for settings |

weScroll.resetPosition()

reset scroller's position, if out of boundary, reset it back

Kind: instance method of WeScroll

weScroll.disable()

set disable

Kind: instance method of WeScroll

weScroll.enable()

set enable

Kind: instance method of WeScroll

weScroll.refresh()

refresh scroller setttings

Kind: instance method of WeScroll

weScroll.scrollTo(x, y, time, easing)

scroll to specific postion of scroller

Kind: instance method of WeScroll

| Param | Type | Description | | --- | --- | --- | | x | Number | offset x | | y | Number | offset y | | time | Number | transition time | | easing | function | easing funtions |

weScroll.zoom(scale, x, y, duration)

zoom to specific postion of scroller and scale Canvas

Kind: instance method of WeScroll

| Param | Type | Description | | --- | --- | --- | | scale | Number | scale | | x | Number | offset x | | y | Number | offset y | | duration | Number | transition time |

docs autogenerated via jsdoc2md