andys-canvys
v1.0.3
Published
A canvas library from your old pal andy.
Downloads
4
Keywords
Readme
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:
bodyRef
- a reference to the DOM node that will house the canvasstory
width
andheight
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.
stopPropagation
andpreventDefault
shit.- Set tell
CanvasManager
the mouse is down. - Get the coordinate from the mouse.
- Try to hit a child (hah!) with the coordinate.
- If we don't hit a child (hahah!) die here.
- If we do, save our starting coordinate and save which child we hit (hahahah!)
- If the child doesn't have a valid mousedown function, die here.
- if it does, call it immediately.