andys-canvys

1.0.3 • Public • Published

CMS

The main shit, you know?

CanvasManager

This is the parent for the entire canvas environment.

Constructor

The constructor has a handful of required parameters:

  1. bodyRef - a reference to the DOM node that will house the canvas
  2. story
  3. width and height

Event Handler

mousedown
canvas[this._listeners.mousedown] = function (e) {
	e.stopPropagation();
	e.preventDefault(); // 1.

	this._mousedown = true; // 2.

	const coord = mouseCoord(e); // 3.

	const child = this.tryMouseDown({ coord }); // 4.
	if (!child) return; // 5.

	this._startCoord = coord;
	this._currentChild = child; // 6.

	if (!_.isFunction(this._currentChild.mousedown)) return; // 7.

	this._currentChild.mousedown(coord); // 8.
};

Stepping through this one since it's a doozie.

  1. stopPropagation and preventDefault shit.
  2. Set tell CanvasManager the mouse is down.
  3. Get the coordinate from the mouse.
  4. Try to hit a child (hah!) with the coordinate.
  5. If we don't hit a child (hahah!) die here.
  6. If we do, save our starting coordinate and save which child we hit (hahahah!)
  7. If the child doesn't have a valid mousedown function, die here.
  8. if it does, call it immediately.

Readme

Keywords

Package Sidebar

Install

npm i andys-canvys

Weekly Downloads

31

Version

1.0.3

License

ISC

Unpacked Size

30.6 kB

Total Files

13

Last publish

Collaborators

  • jon_relay
  • jinsoorelay
  • s-sub
  • shivansh.relay
  • chriscx
  • surya-rd
  • antoine.salamitou
  • max-relay
  • relay_single