insert crossfade effect

master
Peter Babič 3 years ago
parent 6c3ff2b904
commit f5b7a7101c
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 76
      src/App.svelte

@ -1,9 +1,13 @@
<script context="module">
import Graph from "./Graph.js"
</script>
<script> <script>
import Graph from "./Graph.js"
import { onMount } from "svelte" import { onMount } from "svelte"
import { crossfade, scale } from "svelte/transition"
const [send, receive] = crossfade({
duration: 400,
fallback: scale,
})
const pole = 0 const pole = 0
const hole = 1 const hole = 1
const pick = 2 const pick = 2
@ -144,15 +148,6 @@
</script> </script>
<style> <style>
.triangle {
width: 600px;
height: 450px;
display: grid;
grid-template-columns: repeat(9, 1fr);
grid-template-rows: repeat(5, 1fr);
grid-column-gap: 0px;
grid-row-gap: 0px;
}
.div0 { .div0 {
grid-area: 5 / 1 / 6 / 2; grid-area: 5 / 1 / 6 / 2;
} }
@ -199,27 +194,41 @@
grid-area: 1 / 5 / 2 / 6; grid-area: 1 / 5 / 2 / 6;
} }
.triangle {
width: 600px;
height: 450px;
display: grid;
grid-template-columns: repeat(9, 1fr);
grid-template-rows: repeat(5, 1fr);
grid-column-gap: 0px;
grid-row-gap: 0px;
}
.circle { .circle {
width: 30px; width: 50px;
height: 30px; height: 50px;
clip-path: circle(); clip-path: circle();
text-align: center; text-align: center;
color: white; color: white;
} }
.red { .red {
cursor: pointer;
background-color: red; background-color: red;
} }
.gray { .gray {
cursor: default;
background-color: gray; background-color: gray;
} }
.green { .green {
cursor: pointer;
background-color: green; background-color: green;
} }
.blue { .blue {
cursor: pointer;
background-color: blue; background-color: blue;
} }
@ -243,15 +252,34 @@
</div> </div>
<div class="triangle"> <div class="triangle">
{#each circles as _, i} {#each circles as _, i}
<div {#if circles[i] == hole}
class="circle div{i}" <div
class:gray={circles[i] == hole} in:receive={{ key: i }}
class:red={circles[i] == pole} out:send={{ key: i }}
class:green={circles[i] == pick} class="circle div{i} gray"
class:blue={circles[i] == dest} on:click={() => change(i)} />
on:click={() => change(i)}> {/if}
{i} {#if circles[i] == pole}
</div> <div
in:receive={{ key: i }}
out:send={{ key: i }}
class="circle div{i} red"
on:click={() => change(i)} />
{/if}
{#if circles[i] == pick}
<div
in:receive={{ key: i }}
out:send={{ key: i }}
class="circle div{i} green"
on:click={() => change(i)} />
{/if}
{#if circles[i] == dest}
<div
in:receive={{ key: i }}
out:send={{ key: i }}
class="circle div{i} blue"
on:click={() => change(i)} />
{/if}
{/each} {/each}
</div> </div>
</main> </main>

Loading…
Cancel
Save