1.0.5 • Published 2 years ago

spritesheet-animate v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

spritesheet-animate

Demo

https://sher-s7.github.io/js-spritesheet-animator/

Usage

import { animateSpritesheet, METHODS } from "spritesheet-animate";
const spritesheet = document.getElementById("spritesheet");

const settings = {
  path: "./spritesheet.png",
  mobile_path: "./spritesheet_small.png",
  method: METHODS.auto,
  sprite_width: 500,
  sprite_height: 500,
  sprite_width_mobile: 300,
  sprite_height_mobile: 300,
  sprites_per_line: 7,
  number_of_sprites: 47,
};

const animation = animateSpritesheet(spritesheet, settings);

animateSpritesheet

ParameterDefaultTypeDescription
elementnullHTMLElementThe target element you want to display the animation in
settingssee settings belowObjectSettings for initializing the animation

settings

FieldDefaultTypeDescription
pathnullstringPath to the spritesheet
mobile_pathnullstring (optional)Path to the mobile version of the spritesheet (should be the same spritesheet, but scaled down)
method"auto"string"auto": autoplay the animation"onScroll": animate on scroll
sprite_widthnullnumberWidth of an individual sprite (px)
sprite_heightnullnumberHeight of an individual sprite (px)
sprite_width_mobilenullnumberWidth of an individual sprite in the mobile spritesheet (if provided)
sprite_height_mobilenullnumberHeight of an individual sprite in the mobile spritesheet (if provided)
sprites_per_linenullnumberNumber of sprites in each line of the spritesheet
number_of_spritesnullnumberTotal number of sprites in the spritesheet
fps24numberFrames per second of the animation
onScrollSensitivity0.1numberNumber greater than 0. Increase this if you want the animation to play faster on scroll
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago