Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
pixi-viewport
Advanced tools
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, snap to point, snap to zoom, clamping, bouncing on edges, and move on mouse edges.
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.
With your support, I can make pixi-viewport even better! Please consider making a donation:
https://davidfig.github.io/pixi-viewport/jsdoc/
import * as PIXI from 'pixi.js'
import { Viewport } from 'pixi-viewport'
// or with require
// const PIXI = require('pixi.js')
// const Viewport = require('pixi-viewport').Viewport
const app = new PIXI.Application()
document.body.appendChild(app.view)
// create viewport
const viewport = new Viewport({
screenWidth: window.innerWidth,
screenHeight: window.innerHeight,
worldWidth: 1000,
worldHeight: 1000,
interaction: app.renderer.plugins.interaction // the interaction module is important for wheel to work properly when renderer.view is placed or scaled
})
// add the viewport to the stage
app.stage.addChild(viewport)
// activate plugins
viewport
.drag()
.pinch()
.wheel()
.decelerate()
// add a red box
const sprite = viewport.addChild(new PIXI.Sprite(PIXI.Texture.WHITE))
sprite.tint = 0xff0000
sprite.width = sprite.height = 100
sprite.position.set(100, 100)
yarn add pixi-viewport
or
npm i pixi-viewport
or grab the latest release and use it:
<script src="/directory-to-file/pixi.js"></script>
<script src="/directory-to-file/viewport.min.js"></script>
<!-- or <script type="module" src="/directory-to-file/esm/viewport.es.js"></script> -->
<script>
const Viewport = new pixi_viewport.Viewport(options)
</script>
I've included the following build examples in the docs/ directory:
You can see the live demos at https://davidfig.github.io/pixi-viewport/builds/.
Viewport needs to be imported or required as follows:
import { Viewport } from 'pixi-viewport'
// or
const Viewport = require('pixi-viewport').Viewport
Plugins have been moved to their own object:
// 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)
PRs are more than welcome!
This project was migrated to Typescript (thanks @sukantpal!). All functionality should be the same. The live Example has been updated.
If you liked pixi-viewport, please try my other open source libraries:
MIT License (c) 2021 YOPEY YOPEY LLC by David Figatner (david@yopeyopey.com)
FAQs
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, snap to point, snap to zoom, clamping, bouncing on edges, and move on mouse edges.
We found that pixi-viewport demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.