Skip to content

Commit

Permalink
adding example for removeCLass issue #1954
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauren McCarthy committed Dec 15, 2017
1 parent e346dff commit d6ebba0
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions lib/addons/p5.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,19 @@
* enough data has been loaded to play the media
* up to its end without having to stop for
* further buffering of content
* @return {p5.MediaElement|p5.Element} pointer to audio p5.Element
* @return {p5.MediaElement|p5.Element} pointer to audio p5.Element /**
* @example
* <div><code>
* var ele;
* function setup() {
* ele = createAudio('assets/beat.mp3');
*
* // here we set the element to autoplay
* // The element will play as soon
* // as it is able to do so.
* ele.autoplay(true);
* }
* </code></div>
*/
p5.prototype.createAudio = function(src, callback) {
return createMedia(this, 'audio', src, callback);
Expand Down Expand Up @@ -1154,7 +1166,23 @@
*
* @method removeClass
* @param {String} class name of class to remove
* @return {Object|p5.Element}
* @return {Object|p5.Element} * @example
* <div class='norender'><code>
* // In this example, a class is set when the div is created
* // and removed when mouse is pressed. This could link up
* // with a CSS style rule to toggle style properties.
*
* var div;
*
* function setup() {
* div = createDiv('div');
* div.addClass('myClass');
* }
*
* function mousePressed() {
* div.removeClass('myClass');
* }
* </code></div>
*/
p5.Element.prototype.removeClass = function(c) {
var regex = new RegExp('(?:^|\\s)' + c + '(?!\\S)');
Expand Down Expand Up @@ -2203,7 +2231,6 @@
* }
* </code></div>
*/

p5.MediaElement.prototype.duration = function() {
return this.elt.duration;
};
Expand Down

0 comments on commit d6ebba0

Please sign in to comment.