2.1.0 • Published 1 year ago

vue-img-hotspot v2.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Vue Image Hotspot

This package provides functionality for putting hotspot points on an image

Table of Contents

Installation

Vue 3

Currently not supported, development will start soon

Vue 2

  1. Installation Command
npm i vue-img-hotspot
  1. Using it in main.js file, It's globally available in all components hereafter:
import ImageHotspot from 'vue-img-hotspot';
...
Vue.use( ImageHotspot );

Nuxt

  1. Installation Command
npm i vue-img-hotspot
  1. Add a custom plugin in nuxt.config.js:
  plugins: [
    // your other plugins
    '~/plugins/vue-image-hotspot',
  ],
  1. Make vue-image-hotspot.js inside plugins directory in the root of your project and put the following content inside of it:
import Vue from 'vue'
import ImageHotspot from 'vue-img-hotspot'

Vue.use(ImageHotspot)

Usage

Adding Points

Template:

<template>
  <ImageHotspot @pointsUpdated="pointsUpdated" @imageUploaded="imageUploaded"></ImageHotspot>
</template>

Script:

<script>
  data() {
    return {
      points: [],
      image: null,
    }
  },

  methods: {
    pointsUpdated(points) {
      this.points = points
    },

    imageUploaded(image) {
      this.image = image
    },
  }
</script>

Showing Points

The read-only parameter prevents the package from opening a dialog on every click. Template:

<template>
  <ImageHotspot read-only :prop-points="points" :prop-image="image"></ImageHotspot>
</template>

Script:

<script>
  data() {
    return {
      points: [
        {
          x: 370,
          y: 90,
          title: 'Lorem',
          description: 'Lorem ipsum',
          button_text: 'Google',
          button_link: 'https://google.com',
        },
        {
          x: 680,
          y: 160,
          title: 'Lorem',
          description: 'Lorem ipsum',
          button_text: null',
          button_link: null',
        },
      ],
      image: 'https://openmaptiles.org/img/home-banner-map.png'
    }
  }
</script>

Full Implementation

Additionally, you can combine both of the above-mentioned props and events and use them in case of providing update functionality Template:

<template>
  <ImageHotspot 
    @pointsUpdated="pointsUpdated" @imageUploaded="imageUploaded"
    :prop-points="points" :prop-image="image">
  </ImageHotspot>
</template>
2.0.7

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

2.1.0

1 year ago

2.0.6

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago