npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

phaser3-flex

v0.1.1

Published

Flex containers for Phaser

Downloads

3

Readme

Phaser3 Flex

This small library implements some CSS Flexbox features in JavaScript for use in Phaser 3. The "Flex" object is a container inspired by the CSS Flexbox system, which facilitates the placement and alignment of objects (very useful for creating the GUI of our game).
Important: Still in early development phase.

Main features:

  • 4 types of alignment regarding the cross-axis (alignItems): flexStart, center, flexEnd, stretch (only applicable to other flex objects).
  • 4 types of alignment regarding the main axis (justifyContent): flexStart, center, flexEnd, spaceBetween, spaceAround.
  • 2 types of orientation (flexDirection): row, column.
  • flexGrow property: determines how the free space is distributed (only applicable to flex objects).
  • flexShrink property: determines how the lacking space is removed (only applicable to flex objects).
  • Nested containers: a flex object can be inside other flex objects.

Demo: https://jjcapellan.github.io/phaser3-flex/
Api: https://jjcapellan.github.io/phaser3-flex/docs/

Installation

NPM

npm i phaser3-flex

CDN

Web minified version

<script src="https://cdn.jsdelivr.net/gh/jjcapellan/[email protected]/dist/flex.min.js"></script>

Important: Package is exposed as global Fbx

Module version

<script type="module" src="https://cdn.jsdelivr.net/gh/jjcapellan/[email protected]/dist/flex.js"></script>

Quick start

This is the most basic example:

import { Flex } from "phaser3-flex";
// Inside your Phaser.Scene ...

// Create a Flex object with default values
const flexContainer = new Flex(this);

// Create some content
const item1 = this.add.text(0, 0, "text1");
const item2 = this.add.image(0, 0, "image1");
const item3 = this.add.text(0, 0, "text2");

// Add content to the container
flexContainer.add(item1).add(item2).add(item3);

These are the container properties by default:

  • x: 0
  • y: 0
  • width: scene.scale.width
  • height: 0 (the height changes width the content)
  • padding: 10
  • itemsMargin: 4
  • alignItems: AlignItems.CENTER
  • justifyContent: JustifyContent.FLEX_START
  • flexDirection: FlexDirection.ROW

We can change all or some of this properties at creation time:

const flexContainer = new Flex(scene, { padding: 6, justifyContent: JustifyContent.SPACE_BETWEEN });

Some properties can be changed after Flex object creation:

flexContainer.setAlignItems(AlignItems.FLEX_END);
flexContainer.setY(100);
flexContainer.setWidth(400);
// ...

License

This library is licensed under the terms of the MIT open source license.