Implemented this simple drag feature in Svelte. However, the drag seems a little laggy as the div doesn't move smoothly with the mouse drag.
<script>
import {drag} from 'd3-drag'
import {select} from 'd3-selection'
function dd({x}) {
select(this).style('transform', `translate3d(${x}px, 0, 0)`)
}
function d(node) {
const handler = drag().on('drag', dd)
handler(select(node))
}
</script>
<div use:d />
<style>
div {
width: 20px;
height: 90vh;
background: lightblue;
}
</style>