1.0.6 • Published 12 months ago

responsive-image-map v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

responsive-image-map

npm license downloads

responsive-image-map make map to responsive map according to image size

Installation

# Node Package Manager
npm install responsive-image-map

# CDN
# Opting unpkg or jsdelivr
<script src="https://unpkg.com/responsive-image-map/dist/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/responsive-image-map/dist/index.min.js"></script>

Usage

JavaScript

// case1
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="dist/index.js"></script>
  </head>
  <body>
    <img
      src="https://github.com/user-attachments/assets/6cf473f8-5004-4972-884b-d5436fece34b"
      usemap="#image-map-1"
      class="class1"
      style="width: 100%; height: 100%"
    />
    <map name="image-map-1">
      <area
        shape="rect"
        coords="100,100,200,200"
        href="https://github.com/geongupark/responsive-image-map/issues/new"
        alt="Example 1"
      />
    </map>
    <script>
      document.addEventListener("DOMContentLoaded", function () {
        ResponsiveImageMap.makeResponsiveImageMap("class1"); // Add your class names here
      });
    </script>
  </body>
</html>

// case2
import { makeResponsiveImageMap } from "responsive-image-map";

document.addEventListener("DOMContentLoaded", function () {
  ResponsiveImageMap.makeResponsiveImageMap("class1", "class2"); // Add your class names here
});

React

import React, { useEffect } from "react";
import { makeResponsiveImageMap } from "responsive-image-map";

const App = () => {
  useEffect(() => {
    makeResponsiveImageMap("class1", "class2"); // Add your class names here
  }, []);

  return (
    <>
      <img src="image1.jpg" useMap="#image-map-1" className="class1" />
      <map name="image-map-1">
        <area
          shape="rect"
          coords="50,50,150,150"
          href="https://example.com"
          alt="Example"
        />
      </map>
    </>
  );
};

export default App;

Vue

<template>
  <div>
    <img src="image1.jpg" useMap="#image-map-1" class="class1" />
    <map name="image-map-1">
      <area shape="rect" coords="50,50,150,150" href="https://example.com" alt="Example" />
    </map>
  </div>
</template>

<script setup>
import { onMounted } from 'vue';
import { makeResponsiveImageMap } from 'responsive-image-map';

onMounted(() => {
  makeResponsiveImageMap('class1', 'class2'); // Add your class names here
});
</script>

Contributing

We welcome contributions!

License

This project is licensed under the MIT License

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago