Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
<script>
let zoom = 100
let duration = 1000
const levels = new Map([
[[0, 40], {major: 20, minor: 5}],
[[40, 80], {major: 20, minor: 2}],
[[80, 100], {major: 5, minor: 0}],
[[100, 200], {major: 5, minor: 1}],
[[200, 1000], {major: 10, minor: 1}],
])
let innerWidth = 0
$: width = Math.max(innerWidth, duration * 0.1)
$: stepSize = (zoom/100.0)*5
$: level = findLevel(zoom)
function findLevel(zoom) {
let result = null
levels.forEach((rules, [from, to]) => {
if (zoom >= from && zoom < to) {
result = rules
return
}
})
return result
}
function formatSeconds(value) {
if (value == 0)
return "0s"
if (value < 1)
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */