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

storyscroll

v3.8.6

Published

The javascript library for story scroll interactions with html5 canvas

Downloads

13

Readme

StoryScroll

The javascript library for story scroll interactions with html5 canvas.

Example

Example - Time

Example - Train

Example - Moutain

See more with: npm run demo

Installation

Option 1: npm
If you prefer the node package manager, feel free to use it.
Keep in mind that like with bower non-crucial files will be ignored (see above).

npm install storyscroll

Option 2: Bower
Please mind that since they are not core dependencies, you will have to add frameworks like GSAP, PIXI manually, should you choose to use them.

Include the core library in your HTML file:

<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/5.1.3/pixi.min.js"></script>
<script src="https://unpkg.com/[email protected]/lib/storyscroll.min.js"></script>

Usage

import StoryScroll from 'storyscroll'

// init controller
const story = new StoryScroll ({
	direction: 'x',
	width: 750,
	length: 20000,
	bgcolor: 0x000000
});

// create a sprite
const sprite = story.sprite(require('./images/sprite.png'), {x:40, y:540}).actionByStep({x: 0,y:400}, 300, 100);

Parameters

  • direction: x|y scroll direction, default: y
  • width: (number) design width, default: 750
  • length: (number) design length, default: 10000
  • bgcolor: 0xFFFFFF background color, default is tranparent
  • container: #id DOM selector, default: body
  • loader: (boolean) enable loader, default: false
  • delay: (number) delays of first animation with 0 position after loader loaded, default: 500(ms)
  • antialias: (boolean) HD quality with more GPU, default: false
  • progressive: (boolean) incremental loading of sprite to stage, default: false
  • debug: (boolean) output scroll position in console, default: false

Create sprite:

story.sprite(image, props);
  • image: (string) image URL
  • props: (json) target props of PIXI.Sprite

Create video sprite:

story.spriteVideo(video, props);
  • video: (string) video URL
  • props: (json) target props of PIXI.Sprite
    • props.hasVideoButton: (boolean) add play button, default: true

Create animated sprite:

story.spriteAnimated(source, props, autoPlay);
  • source: (string|array) texture json URL, or images URL array
  • props: (json) initial props of PIXI.AnimatedSprite
  • autoPlay: (boolean) default: false

Create chapter for sprites:

let chapter = story.chapter(props).actionByStep({x:-800}, 3200-310, 310);
	let sprite1 = chapter.sprite(require("@/images/part1/telegraph_pole1.png"), {x:0, y:0,});
	let sprite2 = chapter.sprite(require("@/images/part1/telegraph_pole21.png"), {x:2000, y:0,});

Action by moving a position:

sprite.actionByStep(props, section, triggerPosition);
  • props: (json) target props of sprite or container
  • section: (number) section distance of moving with animation
  • triggerPosition: (number) move to where to trigger the animation, default: (position of this sprite)

Play animatedSprite by moving a position:

let sprite = story.spriteAnimated("man.json", {x:0,y:100}, false);
sprite.playByStep({from, to[, speed]}, section, triggerPosition);
  • from: (number) start frame of the animatedSprite
  • to: (number) end frame of the animatedSprite
  • speed: (number) section distance of from - to. If set, animatedSprite will repeat animating
  • section: (number) section distance of moving with animation
  • triggerPosition: (number) move to where to trigger the animation, default: (position of this sprite)

Plugins

Loader

Support to setup a progressor with PIXI.Loader.

// init controller
const story = new StoryScroll ({
	loader: true,
	delay: 800
});

// create a sprite
const sprite1 = story.sprite(require('./images/sprite.png'), {x:40, y:540});
const sprite2 = story.sprite(require('./images/sprite.png'), {x:80, y:540});

// start loading for all sprites ABOVE
story.loader.onProgress.add((loader, resource) => {
	console.log("Progress: " + (loader.progress|0) + "%");
});
story.loader.load((loader, resource) => {
	console.log("All files loaded");
});

The loader is implemented with PIXI.Loader, see more API in TweenMax docs: https://pixijs.download/release/docs/PIXI.Loader.html

Action Plugin

Support to do .action() with TweenMax animation.

Parameters

Animate by moving position:

sprite.action(props, duration, triggerPosition);

Animate immediately:

sprite.act(props, duration);
  • props: (json) See the Vars of TweenMax.to()
  • duration: (number)
  • triggerPosition: (number) move to where to trigger the animation, default: (position of this sprite)
import StoryScroll from 'storyscroll'
import {act, action} from 'storyscroll/action';

// Add a action to trigger by scroll to some position
const doubleAnimation = sprite.action({x:100, reverse:false, onComplete:function(){
	sprite.act({alpha:0}, .3);	// act animation immediately
}}, 3, 100);

The action is implemented with TweenMax.to(), see more API in TweenMax docs: https://www.tweenmax.com.cn/api/tweenmax/TweenMax.to()

Projection Plugin

Support to do .sprite2d() with PIXI.projection.

import StoryScroll from 'storyscroll'
import {sprite2d, chapter2d} from 'storyscroll/projection'

// create a 2D sprite
const chapter2d = story.chapter2d({x:100, y:10});	
const sprite2d = chapter2d.sprite2d(require('./images/sprite_2d.png'),{x:900, y: 30, affine:'AXIS_X', factor:1})

Browser Support

StoryScroll aims to support all major browsers even in older versions:
Firefox 26+, Chrome 30+, Safari 5.1+, Opera 10+, IE 9+

About the Author

I am a creative coder based in Xiamen, China.

Learn more on my website or Follow me on Weibo

License

StoryScroll is dual licensed under the GPL.
For more information click here.

Thanks

This library was made possible by many people who have supported it with passion, donations or advice. Special thanks go out to: Esone MacGhilleseatheanaich.