From 89d272fa6fdd49256cc7363328d2bf51c4e245a3 Mon Sep 17 00:00:00 2001 From: TheJoseScream Date: Mon, 3 Jun 2019 21:48:02 -0600 Subject: [PATCH 1/3] allows to change an array of classes for the parameters of 'from' and 'to'. --- src/iconate.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/iconate.js b/src/iconate.js index c3bc4dd..49864e7 100644 --- a/src/iconate.js +++ b/src/iconate.js @@ -45,11 +45,24 @@ } function changeClasses(element, from, to) { - if (element.classList.contains(from)) { - element.classList.remove(from); + if(Array.isArray(from) && Array.isArray(to)){ + console.log(from,to) + if(from.length>0){ + from.forEach(className => { + console.log(className) + element.classList.remove(className); + }); + } + to.forEach(className => { + element.classList.add(className); + }); + }else{ + if (element.classList.contains(from)) { + element.classList.remove(from); + } + + element.classList.add(to); } - - element.classList.add(to); } function iconate(el, options, callback) { From f9cfcb5a62909035ec9cc1211c77212b255eee10 Mon Sep 17 00:00:00 2001 From: TheJoseScream Date: Wed, 5 Jun 2019 08:56:26 -0600 Subject: [PATCH 2/3] closing comment on ./dist/iconate.min.js --- dist/iconate.min.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/iconate.min.js b/dist/iconate.min.js index a2c6ffa..5ad7479 100644 --- a/dist/iconate.min.js +++ b/dist/iconate.min.js @@ -1,3 +1,4 @@ /*! iconate.js - v0.2.7 - 2018-01-16 * http://bitshadow.github.io/iconate -* Copyright (c) 2018 Jignesh Kakadiya;!function(){"use strict";var t,n,e,o=600,i=1e3,a="zoomOut",r=void 0!==(e=document.documentElement.style).animation||void 0!==e.webkitAnimation;n=void 0===window.onanimationend&&void 0!==window.onwebkitanimationend?"webkitAnimationEnd":"animationend",t=void 0===window.onanimationstart&&void 0!==window.onwebkitanimationstart?"webkitAnimationStart":"animationstart";var m=Date.now||function(){return(new Date).getTime()};function s(t,n,e){t.classList.contains(n)&&t.classList.remove(n),t.classList.add(e)}function d(e,d,w){var u,v,c,f,y,l;if(!e)throw new Error('Iconate > "element" is required');if(!r)return s(e,d.from,d.to),void("function"==typeof w&&w());function p(){var t=m(),n=u/2;v=window.setTimeout(function(){m()-t>=n&&s(e,d.from,d.to)},n)}c=(d=d||{}).animation||a,u=d.duration||o,e.addEventListener(t,p,!1),e.addEventListener(n,function o(){var i;window.clearTimeout(v),(i=e).style.removeProperty("-webkit-animation"),i.style.removeProperty("animation"),i.style.removeProperty("-moz-animation"),i.style.removeProperty("-o-animation"),e.removeEventListener(n,o),e.removeEventListener(t,p),"function"==typeof w&&w()},!1),y=c,l=u/i,(f=e).style.setProperty("-webkit-animation",y+" "+l+"s"),f.style.setProperty("animation",y+" "+l+"s"),f.style.setProperty("-moz-animation",y+" "+l+"s"),f.style.setProperty("-o-animation",y+" "+l+"s")}"object"==typeof exports?module.exports=d:"function"==typeof define&&define.amd?define(function(){return d}):window.iconate=d}(); \ No newline at end of file +* Copyright (c) 2018 Jignesh Kakadiya;!function(){"use strict";var t,n,e,o=600,i=1e3,a="zoomOut",r=void 0!==(e=document.documentElement.style).animation||void 0!==e.webkitAnimation;n=void 0===window.onanimationend&&void 0!==window.onwebkitanimationend?"webkitAnimationEnd":"animationend",t=void 0===window.onanimationstart&&void 0!==window.onwebkitanimationstart?"webkitAnimationStart":"animationstart";var m=Date.now||function(){return(new Date).getTime()};function s(t,n,e){t.classList.contains(n)&&t.classList.remove(n),t.classList.add(e)}function d(e,d,w){var u,v,c,f,y,l;if(!e)throw new Error('Iconate > "element" is required');if(!r)return s(e,d.from,d.to),void("function"==typeof w&&w());function p(){var t=m(),n=u/2;v=window.setTimeout(function(){m()-t>=n&&s(e,d.from,d.to)},n)}c=(d=d||{}).animation||a,u=d.duration||o,e.addEventListener(t,p,!1),e.addEventListener(n,function o(){var i;window.clearTimeout(v),(i=e).style.removeProperty("-webkit-animation"),i.style.removeProperty("animation"),i.style.removeProperty("-moz-animation"),i.style.removeProperty("-o-animation"),e.removeEventListener(n,o),e.removeEventListener(t,p),"function"==typeof w&&w()},!1),y=c,l=u/i,(f=e).style.setProperty("-webkit-animation",y+" "+l+"s"),f.style.setProperty("animation",y+" "+l+"s"),f.style.setProperty("-moz-animation",y+" "+l+"s"),f.style.setProperty("-o-animation",y+" "+l+"s")}"object"==typeof exports?module.exports=d:"function"==typeof define&&define.amd?define(function(){return d}):window.iconate=d}(); +*/ \ No newline at end of file From a076cd2f5ff8da343dce6b18a3ac7ea781de1a8d Mon Sep 17 00:00:00 2001 From: TheJoseScream Date: Wed, 5 Jun 2019 11:02:02 -0600 Subject: [PATCH 3/3] allows to send several classes per parameter concatenated in a string and separated by a space --- src/iconate.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/iconate.js b/src/iconate.js index 49864e7..d3df953 100644 --- a/src/iconate.js +++ b/src/iconate.js @@ -45,23 +45,13 @@ } function changeClasses(element, from, to) { - if(Array.isArray(from) && Array.isArray(to)){ - console.log(from,to) - if(from.length>0){ - from.forEach(className => { - console.log(className) - element.classList.remove(className); - }); - } - to.forEach(className => { + if(from!==null && to!==null){ + from.split(' ').forEach(className => { + element.classList.remove(className); + }); + to.split(' ').forEach(className => { element.classList.add(className); }); - }else{ - if (element.classList.contains(from)) { - element.classList.remove(from); - } - - element.classList.add(to); } }