-
Notifications
You must be signed in to change notification settings - Fork 1
/
Overlay.svelte
84 lines (75 loc) · 2.36 KB
/
Overlay.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<script lang="ts">
/* You can write your own custom overlay by using this one as a template. */
import { fade } from 'svelte/transition';
import type { OverlayOptions } from './overlay';
export let shape: 'round' | 'rect';
export let options: OverlayOptions;
export let gesture_in_progress: boolean; // controlled by CropMediaView
</script>
<div
class="crop-window"
class:round={shape == 'round'}
style={`--outline-color:${options.line_color};
--overlay-color:${options.overlay_color};`}
>
{#if gesture_in_progress && options.show_third_lines}
<div class="lines-wrapper" class:round={shape == 'round'}>
<div class="vertical-lines" in:fade={{ duration: 100 }} out:fade={{ duration: 1000 }} />
</div>
<div class="lines-wrapper" class:round={shape == 'round'}>
<div
class="horizontal-lines"
in:fade={{ duration: 100 }}
out:fade={{ duration: 1000 }}
/>
</div>
{/if}
<div class:round={shape == 'round'} class="outline" />
</div>
<style>
.round {
border-radius: 50%;
}
.crop-window {
position: absolute;
height: var(--crop-window-height);
width: var(--crop-window-width);
left: calc((var(--outer-width) - var(--crop-window-width)) / 2);
top: calc((var(--outer-height) - var(--crop-window-height)) / 2);
box-shadow: 0 0 0 9999em;
color: var(--overlay-color);
}
.outline {
position: absolute;
height: var(--crop-window-height);
width: var(--crop-window-width);
left: 0;
top: 0;
box-sizing: border-box;
border: 2px solid var(--outline-color);
}
.lines-wrapper {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
height: calc(100% - 3px);
width: calc(100% - 3px);
overflow: hidden;
top: 2px;
left: 2px;
}
.horizontal-lines {
border-top: 1px solid var(--outline-color);
border-bottom: 1px solid var(--outline-color);
box-sizing: border-box;
height: 33%;
width: 100%;
}
.vertical-lines {
border-left: 1px solid var(--outline-color);
border-right: 1px solid var(--outline-color);
height: 100%;
width: 33%;
}
</style>