From d9311cec6eda9a106a2d8b8b019211891818e82d Mon Sep 17 00:00:00 2001 From: WillSimao Date: Sat, 26 Nov 2022 10:48:23 -0300 Subject: [PATCH] =?UTF-8?q?feat(TouristAttractionsAutoJs):=20Cria=20condi?= =?UTF-8?q?=C3=A7=C3=A3o=20para=20aplicar=20o=20slick=20somente=20com=20o?= =?UTF-8?q?=20class=20do=20slick?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/components/TouristAttractions.js | 47 +++++++++++--------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/scripts/components/TouristAttractions.js b/src/scripts/components/TouristAttractions.js index 7f9959b..bb34b00 100644 --- a/src/scripts/components/TouristAttractions.js +++ b/src/scripts/components/TouristAttractions.js @@ -28,7 +28,7 @@ export class TouristAttractions { this.events(); this.carrossel(); this.renderListItems(); - this.removeSlick(); + this.slickAdd(); } selectors () { @@ -71,6 +71,25 @@ export class TouristAttractions { } }; + addProperty (e) { + e.preventDefault(); + + const spotImg = this.spanInput.children[0].src + const spotTitle = e.target['input-title'].value + const spotDescription = e.target['input-description'].value + + if (spotImg != '' && spotTitle != '' && spotDescription != '') { + + const spot = { + image: spotImg, + titulo: spotTitle, + description: spotDescription, + }; + this.list.push(spot); + this.renderListItems(); + this.resetInputs(); + } + }; renderListItems () { let spotStructure = ''; @@ -111,26 +130,14 @@ export class TouristAttractions { } }; - - addProperty (e) { - e.preventDefault(); - - const spotImg = this.spanInput.children[0].src - const spotTitle = e.target['input-title'].value - const spotDescription = e.target['input-description'].value - - if (spotImg != '' && spotTitle != '' && spotDescription != '') { - - const spot = { - image: spotImg, - titulo: spotTitle, - description: spotDescription, - }; - this.list.push(spot); - this.renderListItems(); - this.resetInputs(); + slickAdd () { + const ulListSlick = this.ulList; + if (ulListSlick.classList.value === 'slick-initialized') { + this.carrossel(); + }else { + this.removeSlick(); } - }; + } resetInputs () { this.inputTitle.value = '';