You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/event-handler-custom/main.html

30 lines
486 B

<button on:tap='set({ x: event.x, y: event.y })'>{{x}}, {{y}}</button>
<script>
export default {
data: () => ({
x: 0,
y: 0
}),
events: {
tap ( node, callback ) {
function clickHandler ( event ) {
callback({
x: event.clientX,
y: event.clientY
});
}
node.addEventListener( 'click', clickHandler, false );
return {
destroy () {
node.addEventListener( 'click', clickHandler, false );
}
};
}
}
};
</script>