8000 GitHub - zendamacf/popcorn: Quick & easy Javascript seat selection
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

zendamacf/popcorn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

popcorn

Online demo TODO

CDN

Currently just hosted on GitHub here.

Get Started

First, you'll need an array of seats. Each seats needs to be an object with the following keys (all keys are optional):

  • id: (string) The label for the seat (e.g. A1). If this isn't provided, an empty space is added instead of a seat.
  • booked: (boolean) If the seat has been booked already.
  • unavailable: (boolean) If the seat is unavailable.

Next, initialise with the minimum required parameters:

const popcorn = new window.Popcorn({
    elem: '#elem',  // Selector for your element
    width: 1000,  // Width of the canvas
    height: 500,  // Height of the canvas
    rowWidth: 12,  // Maximum number of seats per row
    maxSeats: 2,  // Maximum number of seats to select
    seatList: seats,
});

Events

popcorn.on(eventName, callbackFunction);

The callback function will receive an event object with the detail property populated with relevant data.

There are 3 types of events available:

  • popcorn.selectseat: Triggered when selecting a seat. Event data contains seat label (id) & total count of selected seats (total).
  • popcorn.deselectseat: Triggering when deselecting a seat. Event data contains seat label (id) & total count of selected seats (total).
  • popcorn.maxseats: Triggered when clicking on a seat, but the maximum number of seats has already been reached. Event data contains total count of selected seats (total).

Additional Properties & Methods

// Get an array of seat labels selected
popcorn.selected;

// Set the selected seats
popcorn.selected = ['A1', 'A2', 'A3'];

// Destroy this popcorn instance
popcorn.destroy();

About

Quick & easy Javascript seat selection

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
0