Created
January 13, 2018 16:25
-
-
Save brayoh/d072d7fd0b0c1e843eb40499e705e366 to your computer and use it in GitHub Desktop.
Revisions
-
brayoh created this gist
Jan 13, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ addClass(el, clas, callback) { if (el) { const contains = el.classList.contains(clas); if (contains) { // dont add the class again } else { el.classList.add(clas); } if (typeof callback === 'function') { callback.call(); } } } removeClass(el, clas, callback) { const contains = (el !== undefined) ? el.classList.contains(clas) : false; if (contains) { el.classList.remove(clas) } if (typeof callback === 'function') { callback.call(); } }