Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions src/dom/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ p5.prototype._wrapElement = function (elt) {
const children = Array.prototype.slice.call(elt.children);
if (elt.tagName === 'INPUT' && elt.type === 'checkbox') {
let converted = new p5.Element(elt, this);
converted.checked = function(...args) {
converted.checked = function (...args) {
if (args.length === 0) {
return this.elt.checked;
} else if (args[0]) {
Expand Down Expand Up @@ -1101,7 +1101,7 @@ p5.prototype.createButton = function (label, value) {
* </code>
* </div>
*/
p5.prototype.createCheckbox = function(...args) {
p5.prototype.createCheckbox = function (...args) {
p5._validateParameters('createCheckbox', args);

// Create a container element
Expand All @@ -1121,7 +1121,7 @@ p5.prototype.createCheckbox = function(...args) {
//checkbox must be wrapped in p5.Element before label so that label appears after
const self = addElement(elt, this);

self.checked = function(...args) {
self.checked = function (...args) {
const cb = self.elt.firstElementChild.getElementsByTagName('input')[0];
if (cb) {
if (args.length === 0) {
Expand Down Expand Up @@ -1328,7 +1328,7 @@ p5.prototype.createCheckbox = function(...args) {
* @return {p5.Element}
*/

p5.prototype.createSelect = function(...args) {
p5.prototype.createSelect = function (...args) {
p5._validateParameters('createSelect', args);
let self;
let arg = args[0];
Expand Down Expand Up @@ -1597,7 +1597,7 @@ p5.prototype.createSelect = function(...args) {

//counter for unique names on radio button
let counter = 0;
p5.prototype.createRadio = function(...args) {
p5.prototype.createRadio = function (...args) {
// Creates a div, adds each option as an individual input inside it.
// If already given with a containerEl, will search for all input[radio]
// it, create a p5.Element out of it, add options to it and return the p5.Element.
Expand Down Expand Up @@ -2412,7 +2412,7 @@ if (navigator.mediaDevices.getUserMedia === undefined) {
* </code>
* </div>
*/
p5.prototype.createCapture = function(...args) {
p5.prototype.createCapture = function (...args) {
p5._validateParameters('createCapture', args);

// return if getUserMedia is not supported by the browser
Expand Down Expand Up @@ -2454,7 +2454,7 @@ p5.prototype.createCapture = function(...args) {
domElement.src = window.URL.createObjectURL(stream);
}
}
catch(err) {
catch (err) {
domElement.src = stream;
}
}).catch(e => {
Expand Down Expand Up @@ -2485,7 +2485,7 @@ p5.prototype.createCapture = function(...args) {

if (callback) callback(domElement.srcObject);
});
videoEl.flipped=flipped;
videoEl.flipped = flipped;
return videoEl;
};

Expand Down Expand Up @@ -2965,7 +2965,7 @@ p5.Element.prototype.center = function (align) {
* @param {boolean} [append] whether to append HTML to existing
* @chainable
*/
p5.Element.prototype.html = function(...args) {
p5.Element.prototype.html = function (...args) {
if (args.length === 0) {
return this.elt.innerHTML;
} else if (args[1]) {
Expand Down Expand Up @@ -3035,7 +3035,7 @@ p5.Element.prototype.html = function(...args) {
* @param {String} [positionType] it can be static, fixed, relative, sticky, initial or inherit (optional)
* @chainable
*/
p5.Element.prototype.position = function(...args) {
p5.Element.prototype.position = function (...args) {
if (args.length === 0) {
return { x: this.elt.offsetLeft, y: this.elt.offsetTop };
} else {
Expand All @@ -3060,7 +3060,7 @@ p5.Element.prototype.position = function(...args) {
};

/* Helper method called by p5.Element.style() */
p5.Element.prototype._translate = function(...args) {
p5.Element.prototype._translate = function (...args) {
this.elt.style.position = 'absolute';
// save out initial non-translate transform styling
let transform = '';
Expand Down Expand Up @@ -3092,7 +3092,7 @@ p5.Element.prototype._translate = function(...args) {
};

/* Helper method called by p5.Element.style() */
p5.Element.prototype._rotate = function(...args) {
p5.Element.prototype._rotate = function (...args) {
// save out initial non-rotate transform styling
let transform = '';
if (this.elt.style.transform) {
Expand Down Expand Up @@ -3479,7 +3479,7 @@ p5.Element.prototype.removeAttribute = function (attr) {
* @param {String|Number} value
* @chainable
*/
p5.Element.prototype.value = function(...args) {
p5.Element.prototype.value = function (...args) {
if (args.length > 0) {
this.elt.value = args[0];
return this;
Expand Down Expand Up @@ -4022,10 +4022,10 @@ p5.Element.prototype.draggable = function (elmMove) {
closeDragElementEvt = isTouch ? 'touchend' : 'mouseup',
elementDragEvt = isTouch ? 'touchmove' : 'mousemove';

if(elmMove === undefined){
if (elmMove === undefined) {
elmMove = this.elt;
elmDrag = elmMove;
}else if(elmMove !== this.elt && elmMove.elt !== this.elt){
} else if (elmMove !== this.elt && elmMove.elt !== this.elt) {
elmMove = elmMove.elt;
elmDrag = this.elt;
}
Expand All @@ -4036,11 +4036,11 @@ p5.Element.prototype.draggable = function (elmMove) {
function dragMouseDown(e) {
e = e || window.event;

if(isTouch){
if (isTouch) {
const touches = e.changedTouches;
px = parseInt(touches[0].clientX);
py = parseInt(touches[0].clientY);
}else{
} else {
px = parseInt(e.clientX);
py = parseInt(e.clientY);
}
Expand All @@ -4053,13 +4053,13 @@ p5.Element.prototype.draggable = function (elmMove) {
function elementDrag(e) {
e = e || window.event;

if(isTouch){
if (isTouch) {
const touches = e.changedTouches;
x = px - parseInt(touches[0].clientX);
y = py - parseInt(touches[0].clientY);
px = parseInt(touches[0].clientX);
py = parseInt(touches[0].clientY);
}else{
} else {
x = px - parseInt(e.clientX);
y = py - parseInt(e.clientY);
px = parseInt(e.clientX);
Expand Down Expand Up @@ -5386,7 +5386,6 @@ class MediaElement extends p5.Element {
removeCue(id) {
for (let i = 0; i < this._cues.length; i++) {
if (this._cues[i].id === id) {
console.log(id);
this._cues.splice(i, 1);
}
}
Expand Down