Pass transition speed
This commit is contained in:
@@ -31,8 +31,14 @@
|
|||||||
*/
|
*/
|
||||||
export let initialPage = 1
|
export let initialPage = 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transition speed (ms)
|
||||||
|
*/
|
||||||
|
export let speed = 500
|
||||||
|
|
||||||
let pagesCount = 0
|
let pagesCount = 0
|
||||||
let contentContainerWidth = 0
|
let contentContainerWidth = 0
|
||||||
|
let offset
|
||||||
let contentContainerElement
|
let contentContainerElement
|
||||||
let innerContentContainerElement
|
let innerContentContainerElement
|
||||||
|
|
||||||
@@ -69,7 +75,6 @@
|
|||||||
applyOffset()
|
applyOffset()
|
||||||
}
|
}
|
||||||
|
|
||||||
let offset
|
|
||||||
function applyOffset() {
|
function applyOffset() {
|
||||||
offset = -$store.currentItemIndex * contentContainerWidth
|
offset = -$store.currentItemIndex * contentContainerWidth
|
||||||
}
|
}
|
||||||
@@ -98,7 +103,10 @@
|
|||||||
bind:this={contentContainerElement}
|
bind:this={contentContainerElement}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style="transform: translateX({offset}px);"
|
style="
|
||||||
|
transform: translateX({offset}px);
|
||||||
|
transition-duration: {speed}ms;
|
||||||
|
"
|
||||||
bind:this={innerContentContainerElement}
|
bind:this={innerContentContainerElement}
|
||||||
>
|
>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
@@ -128,7 +136,8 @@
|
|||||||
.content-container > div {
|
.content-container > div {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex; /* to put child elements in one row */
|
display: flex; /* to put child elements in one row */
|
||||||
transition: transform 1s ease-in-out; /* pass transition duration as param */
|
transition-timing-function: ease-in-out;
|
||||||
|
transition-property: transform;
|
||||||
}
|
}
|
||||||
.side-container {
|
.side-container {
|
||||||
background-color: cornflowerblue;
|
background-color: cornflowerblue;
|
||||||
|
|||||||
@@ -21,6 +21,11 @@
|
|||||||
*/
|
*/
|
||||||
export let initialPage = 1
|
export let initialPage = 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transition speed (ms)
|
||||||
|
*/
|
||||||
|
export let speed = 500
|
||||||
|
|
||||||
const colors = [
|
const colors = [
|
||||||
'#e5f9f0',
|
'#e5f9f0',
|
||||||
'#ccf3e2',
|
'#ccf3e2',
|
||||||
@@ -41,6 +46,7 @@
|
|||||||
{infinite}
|
{infinite}
|
||||||
{perPage}
|
{perPage}
|
||||||
{initialPage}
|
{initialPage}
|
||||||
|
{speed}
|
||||||
>
|
>
|
||||||
{#each colors as color (color)}
|
{#each colors as color (color)}
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user