clicky_image.js 739 B

12345678910111213141516171819202122
  1. Vue.component("clicky_image", {
  2. template: `<img v-bind:id="jp_props.id" :src="jp_props.options.source"></div>`,
  3. mounted() {
  4. console.log(this.$props.jp_props);
  5. const image = document.getElementById(this.$props.jp_props.id);
  6. image.addEventListener("click", (e) => {
  7. const event = {
  8. event_type: "onClick",
  9. vue_type: this.$props.jp_props.vue_type,
  10. id: this.$props.jp_props.id,
  11. page_id: page_id,
  12. websocket_id: websocket_id,
  13. image_x: (e.offsetX * e.target.naturalWidth) / e.target.clientWidth,
  14. image_y: (e.offsetY * e.target.naturalHeight) / e.target.clientHeight,
  15. };
  16. send_to_server(event, "event");
  17. });
  18. },
  19. props: {
  20. jp_props: Object,
  21. },
  22. });