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 scrollable, zoomable stage for PIXI.js with pinch-to-zoom and accelerated swiping
A highly configurable viewport/2D camera designed to work with pixi.js
I wanted to improve my work on yy-viewport with a complete rewrite of a viewport/2D camera for use with pixi.js. I added options that I need in my games, including edges that bounce, deceleration, and highly configurable options to tweak the feel of the viewport.
const Viewport = require('pixi-viewport')
const container = new PIXI.Container()
const viewport = new Viewport(container)
https://davidfig.github.io/pixi-viewport/
npm i pixi-viewport
/**
* @param {PIXI.Container} container
* @param {number} screenWidth
* @param {number} screenHeight
* @param {PIXI.Rectangle} [worldBoundaries] - only needed for options.noOverDrag or options.bounce
*
* @param {object} [options]
* @param {boolean} [options.dragToMove]
* @param {boolean} [options.pinchToZoom] automatically turns on dragToMove
*
* @param {boolean} [options.noOverDrag] stops scroll beyond boundaries
* @param {boolean} [options.noOverZoom] don't zoom smaller than screen size
* @param {object} [options.minZoom] {x, y} don't zoom smaller than world zoom x and/or y
* @param {object} [options.maxZoom] {x, y} don't zoom larger than world zoom x and/or y
*
* @param {boolean||object} [options.bounce] bounce back if pulled beyond boundaries
* @param {number} [options.bounce.time=150] number is milliseconds to bounce back
* @param {string} [options.bounce.ease=easeInOutSine] easing function to use when bouncing (see https://github.com/bcherny/penner)
*
* @param {boolean|object} [options.decelerate] decelerate after scrolling
* @param {number} [options.decelerate.friction=0.95] percent to decelerate after movement
* @param {number} [options.decelerate.frictionBounce=0.5] percent to decelerate after movement while inside a bounce
*
* @param {number} [options.minVelocity=0.01] minimum velocity before stopping deceleration
*
* @param {boolean|object} [options.lockOn] keep camera centered on an object
* @param {PIXI.DisplayObject|PIXI.Point} [options.lockOn.object] lock onto this object
* @param {PIXI.Rectangle} [options.lockOn.frame] stay within this frame (in screen coordinates)
*
* @param {boolean} [options.noUpdate] turn off internal calls to requestAnimationFrame() -- update() must be called manually on each loop
*/
constructor(container, screenWidth, screenHeight, worldBoundaries, options)
/**
* @param {number} screenWidth
* @param {number} screenHeight
*/
resize(screenWidth, screenHeight)
/**
* change coordinates from screen to world
* @param {number|PIXI.Point} x
* @param {number} [y]
* @returns {PIXI.Point}
*/
toWorld()
/**
* change coordinates from world to screen
* @param {number|PIXI.Point} x
* @param {number} [y]
* @returns {PIXI.Point}
*/
toScreen()
/**
* call this manually if setting options.noUpdate = true
*/
update()
MIT License
(c) 2017 YOPEY YOPEY LLC by David Figatner
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.
The npm package pixi-viewport receives a total of 9,423 weekly downloads. As such, pixi-viewport popularity was classified as popular.
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.