Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

pixi-viewport

> 编程语言
Open source

A highly configurable viewport/2D camera designed to work with pixi.js

1.2K stars0 likes0 views
WebsiteGitHub

About

A highly configurable viewport/2D camera designed to work with pixi.js

pixi-viewport

A highly configurable viewport/2D camera designed to work with pixi.js.

Features include dragging, pinch-to-zoom, mouse wheel zooming, decelerated dragging, follow target, animate, snap to point, snap to zoom, clamping, bouncing on edges, and move on mouse edges. See the live examples below to try out all of these features.

All features are configurable and removable, so set up the viewport to be exactly what you need.

v6.0.0

Moves pixi-viewport to pixi.js v8+ - sorry for the confusion.

v5.0.2

Moves pixi-viewport to pixi.js v7.2+.

NOTE: there is a breaking change since in pixi.js v7.2 interactive (boolean) was deprecated in favor of eventMode.

v5

Moves pixi-viewport to pixi.js v7 (thanks @cuire!).

NOTE: there is a breaking change since pixi-viewport moved to pixi's new event system. options.interaction is removed and you need pass options.events to the viewport for it to work properly. The events object can be found at pixi's renderer.events or app.renderer.events.

javascript
const viewport = new Viewport({ events: renderer.events });

// or
// const viewport = new Viewport({ events: app.renderer.events });

v4.30.0+

This project was migrated to Typescript (thanks @ShukantPal!). All functionality should be the same. The live Example has been updated.

Live Examples

  • New: https://viewport.pixijs.io/ (using flems.io)
  • Original: https://viewport.pixijs.io/original/

API Documentation

https://viewport.pixijs.io/jsdoc/

Simple Example

…

Installation

bash
yarn add pixi-viewport

or

bash
npm i pixi-viewport

or grab the latest release and use it:

xml

Migration from pixi-viewport v3 to v4

Viewport needs to be imported or required as follows:

javascript
import { Viewport } from "pixi-viewport";

// or

const Viewport = require("pixi-viewport").Viewport;

Plugins have been moved to their own object:

javascript
// viewport.pausePlugin('drag')
viewport.plugins.pause("drag");

// viewport.resumePlugin('drag')
viewport.plugins.resume("drag");

// viewport.removePlugin('drag')
viewport.plugins.remove("drag");

// viewport.userPlugin('name', plugin, index)
viewport.plugins.add("name", plugin, index);

Tests

  1. Clone repository
  2. yarn install
  3. yarn test (for Mocha test code)
  4. yarn coverage (for Instanbul coverage)

Development Recipe

  1. clone repository
  2. yarn install
  3. yarn dev
  4. open browser to http://localhost:5173

PRs are more than welcome!

Other Libraries

If you liked pixi-viewport, please try my other open source libraries:

  • pixi-scrollbox - pixi.js scrollbox: a masked box that can scroll vertically or horizontally with scrollbars (uses pixi-viewport)
  • pixi-ease - pixi.js animation library using easing functions
  • intersects - a simple collection of 2d collision/intersects functions. Supports points, circles, lines, axis-aligned boxes, and polygons

license

MIT License (c) 2024 YOPEY YOPEY LLC by David Figatner ([email protected])

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript2d-camerabouncepixitouch

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言