Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Support PixiJS v8 #17

Merged
merged 12 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Automation
on:
push:
branches: [ '**' ]
tags: [ '**' ]
release:
types: [ 'created' ]
pull_request:
branches: [ '**' ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Run Unit Tests
uses: coactions/setup-xvfb@v1
with:
run: npm test
- name: Upload to Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: dist/*

28 changes: 0 additions & 28 deletions .github/workflows/nodejs.yml

This file was deleted.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ fetch('image.gif')
.then(AnimatedGIF.fromBuffer)
.then(image => app.stage.addChild(image));
```

### Version Compatiblity

| PixiJS | PixiJS GIF |
|--------|------------|
| v6.x | v1.x |
| v7.x | v2.x |
| v8.x | v3.x |
25 changes: 13 additions & 12 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
gtag('js', new Date());
gtag('config', 'UA-103772589-10');
</script>
<script src="https://pixijs.download/dev/pixi-legacy.min.js"></script>
<script src="https://pixijs.download/next-v8/pixi.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
<script src="../dist/pixi-gif.js"></script>
<style>
Expand Down Expand Up @@ -67,7 +67,7 @@ <h2 class="mb-3">Original GIF</h2>

const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
const $view = $('#root');
const $canvas = $('#root');
const $preview = $('#preview');
const $buttons = Array.from($$('button[data-src]'));
const $play = $('#play');
Expand All @@ -77,13 +77,7 @@ <h2 class="mb-3">Original GIF</h2>
const $fileInput = $('#file-input');

// Boilerplate create application
const app = new PIXI.Application({
width: 476,
height: 280,
view: $view,
backgroundAlpha: 0,
hello: true,
});
const app = new PIXI.Application();

let currentAnimation = null;
const sources = $buttons.map(i => i.dataset.src);
Expand Down Expand Up @@ -111,9 +105,9 @@ <h2 class="mb-3">Original GIF</h2>
function playAnimation(imageName, imagePath) {
clearAnimation();
animation = animations[imageName];
$view.width = animation.width;
$view.height = animation.height;
app.renderer.resize($view.width, $view.height);
$canvas.width = animation.width;
$canvas.height = animation.height;
app.renderer.resize($canvas.width, $canvas.height);
$preview.src = imagePath || imageName;
$slider.max = animation.totalFrames - 1;
currentAnimation = animation;
Expand All @@ -135,6 +129,13 @@ <h2 class="mb-3">Original GIF</h2>
}

const main = async () => {
await app.init({
width: 476,
height: 280,
canvas: $canvas,
backgroundAlpha: 0,
hello: true,
});
const resources = await PIXI.Assets.load(sources);
$buttons.forEach($button =>
$button.addEventListener('click', () => playAnimation($button.dataset.src), false));
Expand Down
Loading
Loading