From 6b13868eb6ac1394e8f3e4718b0cd0dfe33f289d Mon Sep 17 00:00:00 2001 From: Javier Godoy <11554739+javier-godoy@users.noreply.github.com> Date: Fri, 8 Mar 2024 09:44:46 -0300 Subject: [PATCH 1/2] style: apply code formatter --- .../vaadin/addons/carousel/Carousel.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/flowingcode/vaadin/addons/carousel/Carousel.java b/src/main/java/com/flowingcode/vaadin/addons/carousel/Carousel.java index bd6e80a..74480a5 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/carousel/Carousel.java +++ b/src/main/java/com/flowingcode/vaadin/addons/carousel/Carousel.java @@ -53,23 +53,23 @@ public class Carousel extends Component implements HasSize { private Slide[] slides; public Carousel(Slide... paperSlides) { - this.setSlides(paperSlides); + setSlides(paperSlides); updateSlides(paperSlides); initProperties(); } private void updateSlides(Slide... paperSlides) { for (Slide slide : paperSlides) { - this.getElement().appendChild(slide.getElement()); + getElement().appendChild(slide.getElement()); } } private void initProperties() { - this.setAutoProgress(false); - this.setSlideDuration(DEFAULT_SLIDE_DURATION); - this.setStartPosition(0); - this.setDisableSwipe(false); - this.setHideNavigation(false); + setAutoProgress(false); + setSlideDuration(DEFAULT_SLIDE_DURATION); + setStartPosition(0); + setDisableSwipe(false); + setHideNavigation(false); } // PROPERTIES @@ -83,68 +83,68 @@ public void setSlides(Slide[] slides) { } public boolean isAutoProgress() { - return this.getElement().getProperty(AUTO_PROGRESS, false); + return getElement().getProperty(AUTO_PROGRESS, false); } public void setAutoProgress(boolean autoProgress) { - this.getElement().setAttribute(AUTO_PROGRESS, autoProgress); + getElement().setAttribute(AUTO_PROGRESS, autoProgress); } public int getSlideDuration() { - return this.getElement().getProperty(SLIDE_DURATION, 0); + return getElement().getProperty(SLIDE_DURATION, 0); } public void setSlideDuration(int slideDuration) { - this.getElement().setProperty(SLIDE_DURATION, slideDuration); + getElement().setProperty(SLIDE_DURATION, slideDuration); } public int getStartPosition() { - return this.getElement().getProperty(POSITION, 0); + return getElement().getProperty(POSITION, 0); } public void setStartPosition(int startPosition) { - this.getElement().setAttribute(POSITION, "" + startPosition); + getElement().setAttribute(POSITION, "" + startPosition); } public boolean isDisableSwipe() { - return this.getElement().getProperty(DISABLE_SWIPE, false); + return getElement().getProperty(DISABLE_SWIPE, false); } public void setDisableSwipe(boolean disableSwipe) { - this.getElement().setAttribute(DISABLE_SWIPE, disableSwipe); + getElement().setAttribute(DISABLE_SWIPE, disableSwipe); } public boolean isHideNavigation() { - return this.getElement().getProperty(HIDE_NAV, false); + return getElement().getProperty(HIDE_NAV, false); } public void setHideNavigation(boolean hideNavigation) { - this.getElement().setAttribute(HIDE_NAV, hideNavigation); + getElement().setAttribute(HIDE_NAV, hideNavigation); } // FLUENT API public Carousel withAutoProgress() { - this.setAutoProgress(true); + setAutoProgress(true); return this; } public Carousel withoutSwipe() { - this.setDisableSwipe(true); + setDisableSwipe(true); return this; } public Carousel withoutNavigation() { - this.setHideNavigation(true); + setHideNavigation(true); return this; } public Carousel withSlideDuration(int slideDuration) { - this.setSlideDuration(slideDuration); + setSlideDuration(slideDuration); return this; } public Carousel withStartPosition(int startPosition) { - this.setStartPosition(startPosition); + setStartPosition(startPosition); return this; } @@ -163,12 +163,12 @@ public String getHeight() { // METHODS /** Move to the next slide */ public void moveNext() { - this.getElement().callJsFunction("moveNext"); + getElement().callJsFunction("moveNext"); } /** Move to the previous slide */ public void movePrev() { - this.getElement().callJsFunction("movePrev"); + getElement().callJsFunction("movePrev"); } /** @@ -177,7 +177,7 @@ public void movePrev() { * @param slide */ public void movePos(int slide) { - this.getElement().callJsFunction("movePos", "" + slide); + getElement().callJsFunction("movePos", "" + slide); } // EVENTS From 3acace7b6988b504c89793b46c909f8d704c9dfe Mon Sep 17 00:00:00 2001 From: Javier Godoy <11554739+javier-godoy@users.noreply.github.com> Date: Fri, 8 Mar 2024 09:51:22 -0300 Subject: [PATCH 2/2] fix: use setProperty instead of setAttribute Close #38 --- .../vaadin/addons/carousel/Carousel.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/flowingcode/vaadin/addons/carousel/Carousel.java b/src/main/java/com/flowingcode/vaadin/addons/carousel/Carousel.java index 74480a5..ae0e938 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/carousel/Carousel.java +++ b/src/main/java/com/flowingcode/vaadin/addons/carousel/Carousel.java @@ -43,11 +43,11 @@ @JsModule("@xpertsea/paper-slider/l2t-paper-slider.js") public class Carousel extends Component implements HasSize { - private static final String HIDE_NAV = "hide-nav"; - private static final String DISABLE_SWIPE = "disable-swipe"; + private static final String HIDE_NAV = "hideNav"; + private static final String DISABLE_SWIPE = "disableSwipe"; private static final String POSITION = "position"; - private static final String SLIDE_DURATION = "slide-duration"; - private static final String AUTO_PROGRESS = "auto-progress"; + private static final String SLIDE_DURATION = "slideDuration"; + private static final String AUTO_PROGRESS = "autoProgress"; private static final int DEFAULT_SLIDE_DURATION = 2; private Slide[] slides; @@ -87,7 +87,7 @@ public boolean isAutoProgress() { } public void setAutoProgress(boolean autoProgress) { - getElement().setAttribute(AUTO_PROGRESS, autoProgress); + getElement().setProperty(AUTO_PROGRESS, autoProgress); } public int getSlideDuration() { @@ -103,7 +103,7 @@ public int getStartPosition() { } public void setStartPosition(int startPosition) { - getElement().setAttribute(POSITION, "" + startPosition); + getElement().setProperty(POSITION, startPosition); } public boolean isDisableSwipe() { @@ -111,7 +111,7 @@ public boolean isDisableSwipe() { } public void setDisableSwipe(boolean disableSwipe) { - getElement().setAttribute(DISABLE_SWIPE, disableSwipe); + getElement().setProperty(DISABLE_SWIPE, disableSwipe); } public boolean isHideNavigation() { @@ -119,7 +119,7 @@ public boolean isHideNavigation() { } public void setHideNavigation(boolean hideNavigation) { - getElement().setAttribute(HIDE_NAV, hideNavigation); + getElement().setProperty(HIDE_NAV, hideNavigation); } // FLUENT API