72 lines
1.7 KiB
HTML
72 lines
1.7 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Event Propagator</title>
|
|
<style>
|
|
html {
|
|
height: 100%;
|
|
}
|
|
|
|
body {
|
|
min-height: 100%;
|
|
position: relative;
|
|
margin: 0;
|
|
}
|
|
|
|
pinch-zoom {
|
|
position: absolute;
|
|
inset: 0;
|
|
|
|
> div {
|
|
display: block;
|
|
position: absolute;
|
|
inset: 0px;
|
|
}
|
|
}
|
|
|
|
folk-shape {
|
|
background-color: black;
|
|
border-radius: 5px;
|
|
color: white;
|
|
padding: 0px 5px;
|
|
z-index: 10;
|
|
}
|
|
|
|
folk-event-propagator {
|
|
&::part(trigger) {
|
|
align-self: center;
|
|
font-size: clamp(1rem, calc(3rem * (1.05 - var(--scale))), 3rem);
|
|
}
|
|
|
|
&::part(expression) {
|
|
opacity: clamp(0, calc(var(--scale) - 0.3), 1);
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pinch-zoom>
|
|
<!-- Pinch zoom applies transforms on child elements instead of itself which breaks folk shape -->
|
|
<div>
|
|
<folk-shape id="box3" x="350" y="200" width="30" height="30"></folk-shape>
|
|
<folk-shape id="box4" x="500" y="250" width="30" height="30"></folk-shape>
|
|
<folk-event-propagator
|
|
source="#box3"
|
|
target="#box4"
|
|
trigger="transform"
|
|
expression="y: from.x,
|
|
rotation: from.x/10"
|
|
></folk-event-propagator>
|
|
</div>
|
|
</pinch-zoom>
|
|
|
|
<script type="module">
|
|
import 'https://esm.sh/pinch-zoom-element@1.1.1';
|
|
import '@labs/standalone/folk-shape.ts';
|
|
import '@labs/standalone/folk-event-propagator.ts';
|
|
</script>
|
|
</body>
|
|
</html>
|