• Stars
    star
    169
  • Rank 217,422 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a scrollbox built for pixi.js using a masked box that scrolls vertically and/or horizontally with optional scrollbars

pixi-scrollbox

A configurable scrollbox designed for pixi.js.

Features:

  • scrollbox uses a mask to clip to desired boxWidth/boxHeight size
  • scrollbox scrolls with scrollbars (options.overflow=scroll)
  • scrollbox's scrollbars may be hidden when not needed (options.overflow=auto or hidden)
  • scrollbox may also be scrolled by dragging on the content window (options.dragScroll=true)

Live Example

davidfig.github.io/pixi-scrollbox/

Rationale

I needed a scrollbox for the UI of my game and since I had this nifty pixi-viewport, I figured it wouldn't be much work to create it. Five hours later and I realized I was a bit off on my estimates. Hopefully others will find it useful.

Migration from v1 to v2

Scrollbox no longer exports a default object. Instead you need to use:

const Scrollbox = require('pixi-scrollbox').Scrollbox

or

import { Scrollbox } from 'pixi-scrollbox'

There were some minor name changes to the fade options. See documentation.

Simple Example

const PIXI = require('pixi.js')
const Scrollbox = require('pixi-scrollbox').Scrollbox

// create the scrollbox
const scrollbox = new Scrollbox({ boxWidth: 200, boxHeight: 200})

// add a sprite to the scrollbox's content
const sprite = scrollbox.content.addChild(new PIXI.Sprite(PIXI.Texture.WHITE))
sprite.width = sprite.height = 500
sprite.tint = 0xff0000

// force an update of the scrollbox's calculations after updating the children
scrollbox.update()

// add the viewport to the stage
const app = new PIXI.Application()
document.body.appendChild(app.view)
app.stage.addChild(scrollbox)

Installation

npm i pixi-scrollbox pixi-viewport pixi.js

or

yarn add pixi-scrollbox pixi-viewport pixi.js

Note: pixi-viewport and pixi.js are listed as peerDependency, which means you will need to manually install them if they're not already installed (this is to ensure you don't have two versions of these libraries).

or download the latest build from github

<script src="/external-directory/pixi.js"></script>
<script src="/external-directory/pixi-viewport.js"></script>
<script src="/external-directory/scrollbox.js"></script>
<script>
    const Scrollbox = new Scrollbox(options)
</script>

API Documentation

https://davidfig.github.io/pixi-scrollbox/jsdoc/

license

MIT License
(c) 2019 YOPEY YOPEY LLC by David Figatner

More Repositories

1

pixi-viewport

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

intersects

a simple collection of 2d collision/intersects functions. Supports points, circles, ellipses, lines, axis-aligned boxes, and polygons
JavaScript
530
star
3

pixi-cull

a library to visibly cull objects designed to work with pixi.js
TypeScript
105
star
4

pixi-ease

pixi.js animation library using easing functions
JavaScript
96
star
5

window-manager

A javascript-only Window Manager
JavaScript
62
star
6

pixi-intersects

shape collision / intersects library for pixi.js
JavaScript
46
star
7

pixi-dashed-line

TypeScript
33
star
8

tree

vanilla-javascript drag-and-drop UI tree
JavaScript
29
star
9

angle

Library for calculating angles in javascript
TypeScript
16
star
10

moonshot

Game Off 2020 - Shoot the Moon (like literally)
JavaScript
13
star
11

rendersheet

renders a canvas spritesheet for use with pixi.js
JavaScript
11
star
12

shape-points

Generate points for simple shapes and curves: arcs, rectangles, rounded rectangles, bezierCurveTo, bezierCurveThrough (i.e., bezier curves through specific points)
JavaScript
11
star
13

pixi-pixelate

draw proper pixelated graphic primitives (i.e., point, points, line, circle, ellipse, arc, polygon, and fill versions)
JavaScript
8
star
14

pixel-editor

An Electron-based pixel editor/animator
JavaScript
7
star
15

sortable

Vanilla drag-and-drop sortable list(s)
JavaScript
6
star
16

bezierpoints

PIXI graphics function to generate a smooth line through specific points
JavaScript
6
star
17

random

a javascript random number API with seeded support. not cryptographically sound. useful for games
JavaScript
6
star
18

viewport

viewport designed to work with pixi.js
JavaScript
5
star
19

fps

Yet another FPS indicator with graph
TypeScript
5
star
20

cordova-allow-background-audio

Cordova plugin that allows background audio to continue to play while app is running
Objective-C
4
star
21

animate

Javascript animation library for use with PIXI.js
JavaScript
4
star
22

loop

Simple and configurable game/main loop
JavaScript
4
star
23

spotlight

a simple canvas-based spotlight that can be used to highlight elements
JavaScript
4
star
24

pixel

Javascript library to generate pixel art and animated scenes
JavaScript
3
star
25

clicked

Javascript: create click event for both mouse and touch
TypeScript
3
star
26

ui

UI/windows library built on pixi.js
JavaScript
3
star
27

input

basic input support for touch, mouse, and keyboard
JavaScript
3
star
28

vanilla-gesture

JavaScript
3
star
29

renderer

wrapper for pixi.js renderer with automatic loop & clean/dirty settings
JavaScript
3
star
30

pixi-tile

A simple tile library for use with pixi.js and pixi-viewport.
JavaScript
2
star
31

vec2-recycle

another vanilla vec-2 library with recycling
JavaScript
2
star
32

calc-fontsize

calculate font-size for a given bounding box and optionally a font
JavaScript
2
star
33

json-bump

bumps the "version" entry for a JSON file
JavaScript
2
star
34

falldown

a vanilla javascript combobox (combination of dropdown and input box)
JavaScript
2
star
35

time-tracker

[WIP] A self-hosted Time Tracker using node.js, sqlite3, and HTML5
JavaScript
2
star
36

tooltip

Simple vanilla-javascript tooltip replacement.
JavaScript
2
star
37

noise

Simple 1D Noise generator in javascript
JavaScript
1
star
38

easyedit

inline editing of a single HTMLElement
JavaScript
1
star
39

yy-menu

A menu system for web apps inspired by Electron
JavaScript
1
star
40

name-generator

Yopey Yopey's Name Generator
PHP
1
star
41

dom-ease

a simple and super fast DOM animation library
JavaScript
1
star
42

settingspanel

Creates hideable UI to change settings during runtime
JavaScript
1
star
43

atom-autocorrect-text

atom.io plugin for simple autocorrects
CoffeeScript
1
star
44

debug

Javascript Debug Panels (useful for game development)
JavaScript
1
star
45

color

color javascript library
JavaScript
1
star
46

spatialHash

Javascript implementation of a 2D Spatial Hash (ES6 class and module.exports used)
JavaScript
1
star
47

jsdoc-template

jsdoc-template for my projects based on @pixi/jsdoc-template
JavaScript
1
star
48

update

update API for javascript apps
JavaScript
1
star
49

file-older-than

node.js: checks if a file modify date is older than a duration (useful for cache checks)
JavaScript
1
star