Carousel: Create a bigger hover/click area for controls
This commit is contained in:
@@ -20,12 +20,15 @@
|
|||||||
// Hover function
|
// Hover function
|
||||||
hover = event => {
|
hover = event => {
|
||||||
const to = event.currentTarget.dataset.to
|
const to = event.currentTarget.dataset.to
|
||||||
|
const button = event.currentTarget.querySelector('button')
|
||||||
const photoActive = document.querySelector('.gallery .active')
|
const photoActive = document.querySelector('.gallery .active')
|
||||||
const photoToHover = (to === 'prev') ? photoActive.previousSibling : photoActive.nextSibling
|
const photoToHover = (to === 'prev') ? photoActive.previousSibling : photoActive.nextSibling
|
||||||
if (event.type === 'mouseenter') {
|
if (event.type === 'mouseenter') {
|
||||||
photoToHover.classList.add('hover')
|
photoToHover.classList.add('hover')
|
||||||
|
button.focus()
|
||||||
} else {
|
} else {
|
||||||
photoToHover.classList.remove('hover')
|
photoToHover.classList.remove('hover')
|
||||||
|
button.blur()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,23 +65,20 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="carousel__controls">
|
<div class="carousel__controls">
|
||||||
<button class="button-control button-control--white dir-left" data-to="prev" aria-label="Previous"
|
<div class="carousel__controls--area prev" data-to="prev" on:mouseenter={hover} on:mouseleave={hover} on:click={photoPrev}>
|
||||||
on:click={photoPrev}
|
<button class="button-control button-control--white dir-left" aria-label="Previous">
|
||||||
on:mouseenter={hover}
|
|
||||||
on:mouseleave={hover}
|
|
||||||
>
|
|
||||||
<IconArrow direction="left" color="#ff6c89" className="icon" />
|
<IconArrow direction="left" color="#ff6c89" className="icon" />
|
||||||
<IconArrow direction="left" color="#fff" className="icon" hidden="true" />
|
<IconArrow direction="left" color="#fff" className="icon" hidden="true" />
|
||||||
</button>
|
</button>
|
||||||
<button class="button-control button-control--white dir-right" data-to="next" aria-label="Next"
|
</div>
|
||||||
on:mouseenter={hover}
|
|
||||||
on:mouseleave={hover}
|
<div class="carousel__controls--area next" data-to="next" on:mouseenter={hover} on:mouseleave={hover} on:click={photoNext}>
|
||||||
on:click={photoNext}
|
<button class="button-control button-control--white dir-right" aria-label="Next">
|
||||||
>
|
|
||||||
<IconArrow direction="right" color="#ff6c89" className="icon" />
|
<IconArrow direction="right" color="#ff6c89" className="icon" />
|
||||||
<IconArrow direction="right" color="#fff" className="icon" hidden="true" />
|
<IconArrow direction="right" color="#fff" className="icon" hidden="true" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{#if viewer}
|
{#if viewer}
|
||||||
<div class="carousel__number">05</div>
|
<div class="carousel__number">05</div>
|
||||||
|
|||||||
@@ -46,21 +46,21 @@
|
|||||||
&--white {
|
&--white {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
|
|
||||||
&:hover {
|
&:hover, &:focus {
|
||||||
background-color: $color-secondary;
|
background-color: $color-secondary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&--pink {
|
&--pink {
|
||||||
background-color: rgba($color-secondary, 0.4);
|
background-color: rgba($color-secondary, 0.4);
|
||||||
|
|
||||||
&:hover {
|
&:hover, &:focus {
|
||||||
background-color: rgba($color-secondary, 0.75);
|
background-color: rgba($color-secondary, 0.75);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&--gray {
|
&--gray {
|
||||||
background-color: $color-gray;
|
background-color: $color-gray;
|
||||||
|
|
||||||
&:hover {
|
&:hover, &:focus {
|
||||||
background-color: $color-text;
|
background-color: $color-text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
transform: translate3d(100%, -50%, 0);
|
transform: translate3d(100%, -50%, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover, &:focus {
|
||||||
.icon:not([aria-hidden]) {
|
.icon:not([aria-hidden]) {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translate3d(-100%, 0, 0);
|
transform: translate3d(-100%, 0, 0);
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
transform: translate3d(-150%, -50%, 0);
|
transform: translate3d(-150%, -50%, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover, &:focus {
|
||||||
.icon:not([aria-hidden]) {
|
.icon:not([aria-hidden]) {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translate3d(100%, 0, 0);
|
transform: translate3d(100%, 0, 0);
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
transform: translate3d(0, -150%, 0);
|
transform: translate3d(0, -150%, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover, &:focus {
|
||||||
.icon:not([aria-hidden]) {
|
.icon:not([aria-hidden]) {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translate3d(0, 100%, 0);
|
transform: translate3d(0, 100%, 0);
|
||||||
@@ -128,7 +128,7 @@
|
|||||||
transform: translate3d(0, 150%, 0);
|
transform: translate3d(0, 150%, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover, &:focus {
|
||||||
.icon:not([aria-hidden]) {
|
.icon:not([aria-hidden]) {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translate3d(0, -100%, 0);
|
transform: translate3d(0, -100%, 0);
|
||||||
@@ -178,7 +178,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hover
|
// Hover
|
||||||
&:hover {
|
&:hover, &:focus {
|
||||||
background-color: rgba($color-lightpurple, 0.65);
|
background-color: rgba($color-lightpurple, 0.65);
|
||||||
|
|
||||||
* {
|
* {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
&__images {
|
&__images {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 0;
|
height: 0;
|
||||||
padding-bottom: calc(100% / 1.5);
|
padding-bottom: calc(100% / 1.5); // Ratio 3.2
|
||||||
|
|
||||||
// Photo
|
// Photo
|
||||||
&--photo {
|
&--photo {
|
||||||
@@ -118,25 +118,35 @@
|
|||||||
display: none;
|
display: none;
|
||||||
|
|
||||||
@include breakpoint (sm) {
|
@include breakpoint (sm) {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 11;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
pointer-events: none;
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
width: 100%;
|
|
||||||
z-index: 11;
|
|
||||||
|
|
||||||
.dir-left {
|
|
||||||
transform: translateX(-50%);
|
|
||||||
}
|
}
|
||||||
.dir-right {
|
|
||||||
transform: translateX(50%);
|
// Hover and clicking area
|
||||||
|
&--area {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 12%;
|
||||||
|
height: 100%;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&.prev {
|
||||||
|
margin-left: -6%;
|
||||||
|
}
|
||||||
|
&.next {
|
||||||
|
margin-right: -6%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
button {
|
||||||
box-shadow: 0 2px 21px rgba(#000, 0.15);
|
box-shadow: 0 2px 20px rgba(#000, 0.15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user