adds transition utility to the client sdk
This commit is contained in:
parent
abba6727ca
commit
856e80fce2
|
@ -7,6 +7,7 @@ import {
|
||||||
builderStore,
|
builderStore,
|
||||||
} from "./store"
|
} from "./store"
|
||||||
import { styleable } from "./utils/styleable"
|
import { styleable } from "./utils/styleable"
|
||||||
|
import transition from "./utils/transition"
|
||||||
import { linkable } from "./utils/linkable"
|
import { linkable } from "./utils/linkable"
|
||||||
import Provider from "./components/Provider.svelte"
|
import Provider from "./components/Provider.svelte"
|
||||||
import { ActionTypes } from "./constants"
|
import { ActionTypes } from "./constants"
|
||||||
|
@ -19,6 +20,7 @@ export default {
|
||||||
screenStore,
|
screenStore,
|
||||||
builderStore,
|
builderStore,
|
||||||
styleable,
|
styleable,
|
||||||
|
transition,
|
||||||
linkable,
|
linkable,
|
||||||
Provider,
|
Provider,
|
||||||
ActionTypes,
|
ActionTypes,
|
||||||
|
|
|
@ -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})
|
||||||
|
}
|
|
@ -291,6 +291,13 @@
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"label": "URL",
|
"label": "URL",
|
||||||
"key": "url"
|
"key": "url"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "select",
|
||||||
|
"key": "transitionType",
|
||||||
|
"label": "Transition",
|
||||||
|
"options": ["fade", "blur", "slide", "fly"],
|
||||||
|
"defaultValue": ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
|
|
||||||
const { styleable } = getContext("sdk")
|
const { styleable, transition } = getContext("sdk")
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
|
|
||||||
export let className = ""
|
export let className = ""
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
export let description = ""
|
export let description = ""
|
||||||
export let height
|
export let height
|
||||||
export let width
|
export let width
|
||||||
|
export let transitionType = ""
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
|
@ -17,4 +18,5 @@
|
||||||
class={className}
|
class={className}
|
||||||
src={url}
|
src={url}
|
||||||
alt={description}
|
alt={description}
|
||||||
use:styleable={$component.styles} />
|
use:styleable={$component.styles}
|
||||||
|
in:transition={{type: transitionType}} />
|
||||||
|
|
Loading…
Reference in New Issue