MCPcopy
hub / github.com/processing/p5.js / position

Method position

src/dom/p5.Element.js:746–768  ·  view source on GitHub ↗

* @param {Number} [x] x-position relative to top-left of window (optional) * @param {Number} [y] y-position relative to top-left of window (optional) * @param {String} [positionType] it can be static, fixed, relative, sticky, initial or inherit (optional) * @chainable

(...args)

Source from the content-addressed store, hash-verified

744 * @chainable
745 */
746 position(...args) {
747 if (args.length === 0) {
748 return { x: this.elt.offsetLeft, y: this.elt.offsetTop };
749 } else {
750 let positionType = 'absolute';
751 if (
752 args[2] === 'static' ||
753 args[2] === 'fixed' ||
754 args[2] === 'relative' ||
755 args[2] === 'sticky' ||
756 args[2] === 'initial' ||
757 args[2] === 'inherit'
758 ) {
759 positionType = args[2];
760 }
761 this.elt.style.position = positionType;
762 this.elt.style.left = args[0] + 'px';
763 this.elt.style.top = args[1] + 'px';
764 this.x = args[0];
765 this.y = args[1];
766 return this;
767 }
768 }
769
770 /**
771 * Shows the current element.

Callers 15

centerMethod · 0.95
setupFunction · 0.80
setupFunction · 0.80
setupFunction · 0.80
sketch0Function · 0.80
setupFunction · 0.80
setupFunction · 0.80
sketchFunction · 0.80
setupFunction · 0.80
setupFunction · 0.80
setupFunction · 0.80
setupFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected