Fix elements init, add package config

This commit is contained in:
Vadim
2021-01-24 00:03:02 +03:00
parent 0e9afa20fa
commit c395f096c2
9 changed files with 30 additions and 193 deletions

View File

@@ -1,6 +1,5 @@
<script>
// TODO: rename image carousel to just carousel
import { onDestroy, onMount } from 'svelte'
import { onDestroy, onMount, tick } from 'svelte'
import { store } from '../store'
import Dots from '../Dots/Dots.svelte'
import Arrow from '../Arrow/Arrow.svelte'
@@ -71,7 +70,7 @@
})
function applyPageSizes() {
const children = pagesElement ? pagesElement.children : []
const children = pagesElement.children
pageWidth = pageWindowElement.clientWidth
pagesCount = children.length
@@ -80,6 +79,9 @@
children[pageIndex].style.minWidth = `${pageWidth}px`
children[pageIndex].style.maxWidth = `${pageWidth}px`
}
store.init(initialPageIndex + Number(infinite))
offsetPage(false)
}
function applyAutoplay() {
@@ -103,11 +105,12 @@
pagesElement.append(first.cloneNode(true))
}
onMount(() => {
infinite && addClones()
applyPageSizes()
store.init(initialPageIndex + Number(infinite))
offsetPage(false)
onMount(async () => {
await tick()
if (pagesElement && pageWindowElement) {
infinite && addClones()
applyPageSizes()
}
const { teardownAutoplay } = applyAutoplay()
@@ -252,7 +255,6 @@
transition-property: transform;
}
.arrow-container {
height: 100%;
padding: 5px;
box-sizing: border-box;
display: flex;

View File

@@ -1,2 +1,3 @@
// TODO:
export default null;
import Carousel from './Carousel/Carousel.svelte'
export default Carousel;