1
0
Fork 0
mirror of synced 2024-10-03 02:27:06 +13:00

adds transition utility to the client sdk

This commit is contained in:
Keviin Åberg Kultalahti 2021-03-01 12:59:27 +01:00
parent bf1b249468
commit 0ce7da93a7
4 changed files with 27 additions and 2 deletions

View file

@ -7,6 +7,7 @@ import {
builderStore,
} from "./store"
import { styleable } from "./utils/styleable"
import transition from "./utils/transition"
import { linkable } from "./utils/linkable"
import Provider from "./components/Provider.svelte"
import { ActionTypes } from "./constants"
@ -19,6 +20,7 @@ export default {
screenStore,
builderStore,
styleable,
transition,
linkable,
Provider,
ActionTypes,

View file

@ -0,0 +1,14 @@
import { fade, blur, slide, fly } from 'svelte/transition'
// Default options
const transitions = new Map([
["fade", { tn: fade, opt: {} }],
["blur", { tn: blur, opt: {} }],
["slide", { tn: slide, opt: {} }],
["fly", { tn: fly, opt: { y: 30 } }],
])
export default function transition(node, {type, options = {}}) {
const { tn, opt } = transitions.get(type) || {}
return tn ? tn(node, {...opt, ...options}) : fade(node, { duration: 0})
}

View file

@ -291,6 +291,13 @@
"type": "text",
"label": "URL",
"key": "url"
},
{
"type": "select",
"key": "transitionType",
"label": "Transition",
"options": ["fade", "blur", "slide", "fly"],
"defaultValue": ""
}
]
},

View file

@ -1,7 +1,7 @@
<script>
import { getContext } from "svelte"
const { styleable } = getContext("sdk")
const { styleable, transition } = getContext("sdk")
const component = getContext("component")
export let className = ""
@ -9,6 +9,7 @@
export let description = ""
export let height
export let width
export let transitionType = ""
</script>
<img
@ -17,4 +18,5 @@
class={className}
src={url}
alt={description}
use:styleable={$component.styles} />
use:styleable={$component.styles}
in:transition={{type: transitionType}} />