Carousel: Create a bigger hover/click area for controls
This commit is contained in:
@@ -20,12 +20,15 @@
|
||||
// Hover function
|
||||
hover = event => {
|
||||
const to = event.currentTarget.dataset.to
|
||||
const button = event.currentTarget.querySelector('button')
|
||||
const photoActive = document.querySelector('.gallery .active')
|
||||
const photoToHover = (to === 'prev') ? photoActive.previousSibling : photoActive.nextSibling
|
||||
if (event.type === 'mouseenter') {
|
||||
photoToHover.classList.add('hover')
|
||||
button.focus()
|
||||
} else {
|
||||
photoToHover.classList.remove('hover')
|
||||
button.blur()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,22 +65,19 @@
|
||||
</div>
|
||||
|
||||
<div class="carousel__controls">
|
||||
<button class="button-control button-control--white dir-left" data-to="prev" aria-label="Previous"
|
||||
on:click={photoPrev}
|
||||
on:mouseenter={hover}
|
||||
on:mouseleave={hover}
|
||||
>
|
||||
<IconArrow direction="left" color="#ff6c89" className="icon" />
|
||||
<IconArrow direction="left" color="#fff" className="icon" hidden="true" />
|
||||
</button>
|
||||
<button class="button-control button-control--white dir-right" data-to="next" aria-label="Next"
|
||||
on:mouseenter={hover}
|
||||
on:mouseleave={hover}
|
||||
on:click={photoNext}
|
||||
>
|
||||
<IconArrow direction="right" color="#ff6c89" className="icon" />
|
||||
<IconArrow direction="right" color="#fff" className="icon" hidden="true" />
|
||||
</button>
|
||||
<div class="carousel__controls--area prev" data-to="prev" on:mouseenter={hover} on:mouseleave={hover} on:click={photoPrev}>
|
||||
<button class="button-control button-control--white dir-left" aria-label="Previous">
|
||||
<IconArrow direction="left" color="#ff6c89" className="icon" />
|
||||
<IconArrow direction="left" color="#fff" className="icon" hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="carousel__controls--area next" data-to="next" on:mouseenter={hover} on:mouseleave={hover} 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="#fff" className="icon" hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if viewer}
|
||||
|
||||
Reference in New Issue
Block a user