New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/sprite-animated

Package Overview
Dependencies
Maintainers
3
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/sprite-animated - npm Package Compare versions

Comparing version 7.0.0-alpha to 7.0.0-alpha.2

26

dist/cjs/sprite-animated.js
/*!
* @pixi/sprite-animated - v7.0.0-alpha
* Compiled Fri, 09 Sep 2022 16:09:18 UTC
* @pixi/sprite-animated - v7.0.0-alpha.2
* Compiled Sun, 18 Sep 2022 20:45:04 UTC
*

@@ -55,14 +55,6 @@ * @pixi/sprite-animated is licensed under the MIT License.

this.stop();
const previousFrame = this.currentFrame;
this._currentTime = frameNumber;
if (previousFrame !== this.currentFrame) {
this.updateTexture();
}
this.currentFrame = frameNumber;
}
gotoAndPlay(frameNumber) {
const previousFrame = this.currentFrame;
this._currentTime = frameNumber;
if (previousFrame !== this.currentFrame) {
this.updateTexture();
}
this.currentFrame = frameNumber;
this.play();

@@ -182,2 +174,12 @@ }

}
set currentFrame(value) {
if (value < 0 || value > this.totalFrames - 1) {
throw new Error(`[AnimatedSprite]: Invalid frame index value ${value}, expected to be between 0 and totalFrames ${this.totalFrames}.`);
}
const previousFrame = this.currentFrame;
this._currentTime = value;
if (previousFrame !== this.currentFrame) {
this.updateTexture();
}
}
get playing() {

@@ -184,0 +186,0 @@ return this._playing;

"use strict";/*!
* @pixi/sprite-animated - v7.0.0-alpha
* Compiled Fri, 09 Sep 2022 16:09:18 UTC
* @pixi/sprite-animated - v7.0.0-alpha.2
* Compiled Sun, 18 Sep 2022 20:45:04 UTC
*
* @pixi/sprite-animated is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/Object.defineProperty(exports,"__esModule",{value:!0});var o=require("@pixi/sprite"),s=require("@pixi/core");class h extends o.Sprite{constructor(t,e=!0){super(t[0]instanceof s.Texture?t[0]:t[0].texture),this._textures=null,this._durations=null,this._autoUpdate=e,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=t}stop(){!this._playing||(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(s.Ticker.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(s.Ticker.shared.add(this.update,this,s.UPDATE_PRIORITY.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop();const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this.updateTexture()}gotoAndPlay(t){const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this.updateTexture(),this.play()}update(t){if(!this._playing)return;const e=this.animationSpeed*t,i=this.currentFrame;if(this._durations!==null){let r=this._currentTime%1*this._durations[this.currentFrame];for(r+=e/60*1e3;r<0;)this._currentTime--,r+=this._durations[this.currentFrame];const n=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);r>=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*n,this._currentTime+=n;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=e;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):i!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<i?this.onLoop():this.animationSpeed<0&&this.currentFrame>i&&this.onLoop()),this.updateTexture())}updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this._texture=this._textures[t],this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this.uvs=this._texture._uvs.uvsFloat32,this.updateAnchor&&this._anchor.copyFrom(this._texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t){this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(s.Texture.from(t[i]));return new h(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(s.Texture.from(t[i]));return new h(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof s.Texture)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let e=0;e<t.length;e++)this._textures.push(t[e].texture),this._durations.push(t[e].time)}this._previousFrame=null,this.gotoAndStop(0),this.updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(s.Ticker.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(s.Ticker.shared.add(this.update,this),this._isConnectedToTicker=!0))}}exports.AnimatedSprite=h;
*/Object.defineProperty(exports,"__esModule",{value:!0});var o=require("@pixi/sprite"),s=require("@pixi/core");class h extends o.Sprite{constructor(t,e=!0){super(t[0]instanceof s.Texture?t[0]:t[0].texture),this._textures=null,this._durations=null,this._autoUpdate=e,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=t}stop(){!this._playing||(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(s.Ticker.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(s.Ticker.shared.add(this.update,this,s.UPDATE_PRIORITY.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=this.animationSpeed*t,i=this.currentFrame;if(this._durations!==null){let r=this._currentTime%1*this._durations[this.currentFrame];for(r+=e/60*1e3;r<0;)this._currentTime--,r+=this._durations[this.currentFrame];const n=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);r>=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*n,this._currentTime+=n;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=e;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):i!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<i?this.onLoop():this.animationSpeed<0&&this.currentFrame>i&&this.onLoop()),this.updateTexture())}updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this._texture=this._textures[t],this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this.uvs=this._texture._uvs.uvsFloat32,this.updateAnchor&&this._anchor.copyFrom(this._texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t){this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(s.Texture.from(t[i]));return new h(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(s.Texture.from(t[i]));return new h(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof s.Texture)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let e=0;e<t.length;e++)this._textures.push(t[e].texture),this._durations.push(t[e].time)}this._previousFrame=null,this.gotoAndStop(0),this.updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this.updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(s.Ticker.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(s.Ticker.shared.add(this.update,this),this._isConnectedToTicker=!0))}}exports.AnimatedSprite=h;
//# sourceMappingURL=sprite-animated.min.js.map

@@ -9,12 +9,19 @@ import type { IDestroyOptions } from '@pixi/display';

* ```js
* let alienImages = ["image_sequence_01.png","image_sequence_02.png","image_sequence_03.png","image_sequence_04.png"];
* let textureArray = [];
* import { Texture, AnimatedSprite } from 'pixi.js';
*
* for (let i=0; i < 4; i++)
* const alienImages = [
* "image_sequence_01.png",
* "image_sequence_02.png",
* "image_sequence_03.png",
* "image_sequence_04.png"
* ];
* const textureArray = [];
*
* for (let i = 0; i < 4; i++)
* {
* let texture = PIXI.Texture.from(alienImages[i]);
* const texture = Texture.from(alienImages[i]);
* textureArray.push(texture);
* };
*
* let animatedSprite = new PIXI.AnimatedSprite(textureArray);
* const animatedSprite = new AnimatedSprite(textureArray);
* ```

@@ -24,12 +31,7 @@ *

* containing the animation definitions:
* @example
* import { Assets, AnimatedSprite } from 'pixi.js';
*
* ```js
* PIXI.Loader.shared.add("assets/spritesheet.json").load(setup);
*
* function setup() {
* let sheet = PIXI.Loader.shared.resources["assets/spritesheet.json"].spritesheet;
* animatedSprite = new PIXI.AnimatedSprite(sheet.animations["image_sequence"]);
* ...
* }
* ```
* const sheet = await Assets.load("assets/spritesheet.json");
* animatedSprite = new AnimatedSprite(sheet.animations["image_sequence"]);
* @memberof PIXI

@@ -62,3 +64,3 @@ */

* @example
* animation.onComplete = function () {
* animation.onComplete = () => {
* // finished!

@@ -71,3 +73,3 @@ * };

* @example
* animation.onFrameChange = function () {
* animation.onFrameChange = () => {
* // updated!

@@ -81,3 +83,3 @@ * };

* @example
* animation.onLoop = function () {
* animation.onLoop = () => {
* // looped!

@@ -163,7 +165,5 @@ * };

set textures(value: Texture[] | FrameObject[]);
/**
* The AnimatedSprites current frame index.
* @readonly
*/
/** The AnimatedSprites current frame index. */
get currentFrame(): number;
set currentFrame(value: number);
/**

@@ -170,0 +170,0 @@ * Indicates if the AnimatedSprite is currently playing.

{
"name": "@pixi/sprite-animated",
"version": "7.0.0-alpha",
"version": "7.0.0-alpha.2",
"main": "dist/cjs/sprite-animated.js",

@@ -42,3 +42,3 @@ "module": "dist/esm/sprite-animated.mjs",

],
"gitHead": "da993226df64b804a9c00ed9ee4d011191467b8a"
"gitHead": "439f6c1606ba63b26a93173284d25c35a7682b17"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc