Code cleanup

This commit is contained in:
Vadim
2021-01-22 20:57:08 +03:00
parent 5154887d93
commit 139695edb8
12 changed files with 28 additions and 122 deletions

View File

@@ -11,6 +11,7 @@
} from '../utils/size'
import Dots from '../Dots/Dots.svelte'
import Arrow from '../Arrow/Arrow.svelte'
import { NEXT, PREV } from '../direction'
/**
* Enable Next/Prev arrows
@@ -50,7 +51,7 @@
/**
* Auto play change direction ('next', 'prev')
*/
export let autoplayDirection = 'next'
export let autoplayDirection = NEXT
/**
* Current page indicator dots
@@ -61,16 +62,16 @@
let pagesCount = 0
let pageWidth = 0
let offset
let contentContainerElement
let innerContentContainerElement
let pageWindow
let pagesElement
const unsubscribe = store.subscribe(value => {
currentPageIndex = value.currentPageIndex
})
function applySlideSizes() {
const children = innerContentContainerElement ? innerContentContainerElement.children : []
pageWidth = contentContainerElement.clientWidth
const children = pagesElement ? pagesElement.children : []
pageWidth = pageWindow.clientWidth
const slidesCount = children.length
pagesCount = getPagesCount({ slidesCount, slidesToShow })
@@ -87,8 +88,8 @@
function applyAutoplay() {
const autoplayDirectionFnDescription = {
'next': showNextPage,
'prev': showPrevPage
[NEXT]: showNextPage,
[PREV]: showPrevPage
}
let interval
if (autoplay) {
@@ -146,28 +147,28 @@
<div class="carousel-container">
{#if arrows}
<slot name="prev" {showPrevPage}>
<div class="side-container">
<div class="arrow-container">
<Arrow direction="prev" on:click={showPrevPage} />
</div>
</slot>
{/if}
<div
class="content-container"
bind:this={contentContainerElement}
bind:this={pageWindow}
>
<div
style="
transform: translateX({offset}px);
transition-duration: {speed}ms;
"
bind:this={innerContentContainerElement}
bind:this={pagesElement}
>
<slot></slot>
</div>
</div>
{#if arrows}
<slot name="next" {showNextPage}>
<div class="side-container">
<div class="arrow-container">
<Arrow direction="next" on:click={showNextPage} />
</div>
</slot>
@@ -212,7 +213,7 @@
transition-timing-function: ease-in-out;
transition-property: transform;
}
.side-container {
.arrow-container {
height: 100%;
padding: 5px;
box-sizing: border-box;

View File

@@ -1,5 +1,6 @@
<script>
import Carousel from './Carousel.svelte'
import { NEXT } from '../direction'
/**
* Enable Next/Previos arrows
@@ -39,7 +40,7 @@
/**
* Auto play change direction ('next', 'prev')
*/
export let autoplayDirection = 'next'
export let autoplayDirection = NEXT
/**
* Current page indicator dots

View File

@@ -1,5 +1,6 @@
<script>
import Carousel from './Carousel.svelte'
import { NEXT } from '../direction'
/**
* Enable Next/Previos arrows
@@ -39,7 +40,7 @@
/**
* Auto play change direction ('next', 'prev')
*/
export let autoplayDirection = 'next'
export let autoplayDirection = NEXT
/**
* Current page indicator dots

View File

@@ -1,5 +1,6 @@
<script>
import Carousel from './Carousel.svelte'
import { NEXT } from '../direction'
/**
* Enable Next/Previos arrows
@@ -39,7 +40,7 @@
/**
* Auto play change direction ('next', 'prev')
*/
export let autoplayDirection = 'next'
export let autoplayDirection = NEXT
/**
* Current page indicator dots