Skip to content

Commit

Permalink
move carousel styles #161
Browse files Browse the repository at this point in the history
  • Loading branch information
rjeeb committed Dec 7, 2018
1 parent cac2f77 commit 1c0af8e
Show file tree
Hide file tree
Showing 4 changed files with 227 additions and 249 deletions.
34 changes: 14 additions & 20 deletions src/main/java/org/dominokit/domino/ui/carousel/Carousel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import elemental2.dom.HTMLAnchorElement;
import elemental2.dom.HTMLDivElement;
import elemental2.dom.HTMLOListElement;
import org.dominokit.domino.ui.icons.Icons;
import org.dominokit.domino.ui.style.Style;
import org.dominokit.domino.ui.style.Styles;
import org.dominokit.domino.ui.utils.BaseDominoElement;
import org.dominokit.domino.ui.utils.DominoElement;
import org.dominokit.domino.ui.utils.ElementUtil;
import org.dominokit.domino.ui.utils.SwipeUtil;
import org.gwtproject.timer.client.Timer;
import org.jboss.gwt.elemento.core.IsElement;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -26,20 +27,19 @@ public class Carousel extends BaseDominoElement<HTMLDivElement, Carousel> {
private HTMLAnchorElement prevElement = a()
.css("left", "carousel-control")
.attr("role", "button")
.add(span()
.css("glyphicon", "glyphicon-chevron-left")
.attr("aria-hidden", "true"))
.add(span().css("sr-only").textContent("Previous"))
.add(Icons.ALL.chevron_left()
.styler(style -> style
.add(Styles.vertical_center)
.setFontSize("60px")))
.asElement();


private HTMLAnchorElement nextElement = a()
.css("right", "carousel-control")
.attr("role", "button")
.add(span()
.css("glyphicon", "glyphicon-chevron-right")
.attr("aria-hidden", "true"))
.add(span().css("sr-only").textContent("Next"))
.add(Icons.ALL.chevron_right()
.styler(style -> style
.add(Styles.vertical_center)
.setFontSize("60px")))
.asElement();

private HTMLDivElement element = div()
Expand All @@ -50,7 +50,6 @@ public class Carousel extends BaseDominoElement<HTMLDivElement, Carousel> {
.css("carousel", "slide")
.asElement();


private List<Slide> slides = new ArrayList<>();
private Slide activeSlide;
private Slide targetSlide;
Expand All @@ -63,23 +62,18 @@ public Carousel() {
resetTimer();
nextSlide();
});

prevElement.addEventListener("click", evt -> {
resetTimer();
prevSlide();
});

timer = new Timer() {
@Override
public void run() {
nextSlide();
}
};

addAttachListener();

addDetachListener();

init(this);
}

Expand All @@ -98,7 +92,7 @@ private void addDetachListener() {
private void addAttachListener() {
ElementUtil.onAttach(this.asElement(), mutationRecord -> {
this.attached = true;
if(autoSlide){
if (autoSlide) {
timer.scheduleRepeating(autoSlideDuration);
}

Expand Down Expand Up @@ -190,15 +184,15 @@ private void gotToSlide(Slide slide, String source) {
}

private String getPostionStyle(Slide target, String source) {
if ((slides.indexOf(target) > slides.indexOf(activeSlide) && !"prev".equals(source)) || ("next".equals(source) && !"".equals("source"))) {
if ((slides.indexOf(target) > slides.indexOf(activeSlide) && !"prev".equals(source)) || ("next".equals(source))) {
return "next";
} else {
return "prev";
}
}

private String getDirectionStyle(Slide target, String source) {
if ((slides.indexOf(target) > slides.indexOf(activeSlide) && !"prev".equals(source)) || ("next".equals(source) && !"".equals("source"))) {
if ((slides.indexOf(target) > slides.indexOf(activeSlide) && !"prev".equals(source)) || ("next".equals(source))) {
return "left";
} else {
return "right";
Expand All @@ -225,7 +219,7 @@ private void removeMotionStyles() {
public Carousel startAutoSlide(int slideDuration) {
this.autoSlide = true;
this.autoSlideDuration = slideDuration;
if(attached){
if (attached) {
timer.scheduleRepeating(slideDuration);
}

Expand Down
211 changes: 211 additions & 0 deletions src/main/java/org/dominokit/domino/ui/public/css/carousel/carousel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
.carousel {
position: relative;
}

.carousel-indicators {
position: absolute;
bottom: 10px;
left: 50%;
z-index: 10;
width: 60%;
padding-left: 0;
margin-left: -30%;
text-align: center;
list-style: none;
}

.carousel-indicators li {
display: inline-block;
width: 10px;
height: 10px;
margin: 3px;
text-indent: -999px;
cursor: pointer;
background-color: #000 \9;
background-color: rgba(0, 0, 0, 0);
border: 1px solid #fff;
border-radius: 10px;
}

.carousel-indicators .active {
width: 12px;
height: 12px;
margin: 2px;
background-color: #fff;
}

.carousel-inner {
position: relative;
width: 100%;
overflow: hidden;
}

.carousel-inner>.item {
position: relative;
display: none;
-webkit-transition: .6s ease-in-out left;
-o-transition: .6s ease-in-out left;
transition: .6s ease-in-out left;
}

.carousel-inner>.item>img,
.carousel-inner>.item>a>img {
line-height: 1;
}

@media all and (transform-3d),
(-webkit-transform-3d) {

.carousel-inner>.item {
-webkit-transition: -webkit-transform .6s ease-in-out;
-o-transition: -o-transform .6s ease-in-out;
transition: transform .6s ease-in-out;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-perspective: 1000px;
perspective: 1000px;
}

.carousel-inner>.item.next,
.carousel-inner>.item.active.right {
left: 0;
-webkit-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0);
}

.carousel-inner>.item.prev,
.carousel-inner>.item.active.left {
left: 0;
-webkit-transform: translate3d(-100%, 0, 0);
transform: translate3d(-100%, 0, 0);
}

.carousel-inner>.item.next.left,
.carousel-inner>.item.prev.right,
.carousel-inner>.item.active {
left: 0;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}

.carousel-inner>.active,
.carousel-inner>.next,
.carousel-inner>.prev {
display: block;
}

.carousel-inner>.active {
left: 0;
}

.carousel-inner>.next,
.carousel-inner>.prev {
position: absolute;
top: 0;
width: 100%;
}

.carousel-inner>.next {
left: 100%;
}

.carousel-inner>.prev {
left: -100%;
}

.carousel-inner>.next.left,
.carousel-inner>.prev.right {
left: 0;
}

.carousel-inner>.active.left {
left: -100%;
}

.carousel-inner>.active.right {
left: 100%;
}

.carousel-inner>.item>img,
.carousel-inner>.item>a>img {
display: block;
max-width: 100%;
height: auto;
vertical-align: middle;
border: 0;
}

.carousel-control {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 15%;
font-size: 20px;
color: #fff;
text-align: center;
text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
background-color: rgba(0, 0, 0, 0);
filter: alpha(opacity=50);
opacity: .5;
cursor: pointer !important;
}

.carousel-control.left {
background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%);
background-image: -o-linear-gradient(left, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%);
background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, .5)), to(rgba(0, 0, 0, .0001)));
background-image: linear-gradient(to right, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1);
background-repeat: repeat-x;
}

.carousel-control.right {
right: 0;
left: auto;
background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%);
background-image: -o-linear-gradient(left, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%);
background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, .0001)), to(rgba(0, 0, 0, .5)));
background-image: linear-gradient(to right, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1);
background-repeat: repeat-x;
}

.carousel-control:hover,
.carousel-control:focus {
color: #fff;
text-decoration: none;
filter: alpha(opacity=90);
outline: 0;
opacity: .9;
}

.carousel-caption {
position: absolute;
right: 15%;
bottom: 20px;
left: 15%;
z-index: 10;
padding-top: 20px;
padding-bottom: 20px;
color: #fff;
text-align: center;
text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

.carousel-caption .btn {
text-shadow: none;
}

@media screen and (min-width: 768px) {
.carousel-indicators {
bottom: 20px;
}

.carousel-caption {
right: 20%;
left: 20%;
padding-bottom: 30px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
@import url(breadcrumb/breadcrumb.css);
@import url(button/button.css);
@import url(cards/card.css);
@import url(carousel/carousel.css);
@import url(style.css);
@import url(colors.css);
Loading

0 comments on commit 1c0af8e

Please sign in to comment.