npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@a11y-ngx/responsive-image-maps

v1.1.2

Published

A responsive image map directive that updates the areas' coordinates according to the image size

Readme

Responsive Image Maps

A responsive image map Angular directive that updates the areas' coordinates according to the image size.

It will manage all shapes (rect, circle and poly).

This library was generated with Angular CLI version 12.2.0.

Index

Installation

  1. Install npm package:

    npm install @a11y-ngx/responsive-image-maps --save

  2. Import A11yResponsiveImageMapsModule into your module or standalone component:

    import { A11yResponsiveImageMapsModule } from '@a11y-ngx/responsive-image-maps';
    
    @NgModule({
        declarations: [...],
        imports: [
            ...
            A11yResponsiveImageMapsModule,
        ],
    })
    export class AppModule { }

Use

Add an image with a map in your template.

The Map Directive

  • The Map directive will pick any <map> tag with [name] attribute in it and search for the <img> with [usemap] matching that name.
  • When the image has been loaded for the first time, it will:
    • Update loaded with true.
    • Emit sizeChanged.
  • When the main <img> resizes, all <area> elements will update their coordinates based on the new image size.
  • The directive can be accessed using a template variable through the exported name of responsiveImageMap.
  • The directive will auto update sizes when the page resizes (using Window Resize Service).
  • If the image changes its size:
    • Through window resize, (sizeChanged) output will emit the new MapSize.
    • Pogrammatically, the sizes (image and areas) can be manually updated using the update() method from the exported directive.
  • The HTML <map> element can be reached through the nativeElement property.
  • The HTML <img> element can be reached through the imageElement property.

Map Directive public Properties, Getters and Methods

| Property | Type | Returns | Description | |:---------|:-----|:--------|:------------| | loaded | BehaviorSubject | boolean | Will return true when the image has been loaded | | sizeChanged | EventEmitter | MapSize | Will emit the new image's size & position when page resize and it changes the width and height values | | areas | QueryList | ResponsiveImageAreaDirective | To access all <area> children directives | | scaleFactor | get | { width: number, height: number } | The scale factor from the image's original full size and the resized size | | imageSize | MapSize | object | To access all the values (size & position) from the main image | | nativeElement | get | HTMLMapElement | To access the HTML <map> element | | imageElement | get | HTMLImageElement | To access the HTML <img> element that the <map> is attached to | | update() | method | void | Will update the image new values and all the <area>'s new coordinates accordingly |

The MapSize Type

| Property | Type | Description | |:---------|:----:|:------------| | top | number | The image DOMRect's top value | | left | number | The image DOMRect's left value | | width | number | The image DOMRect's width value | | height | number | The image DOMRect's height value | | fullWidth | number | The image's original full width size (resized or not) | | fullHeight | number | The image's original full height size (resized or not) |

The Area Directive

  • The Area directive will pick any <area> tag with [shape] and [coords] attributes.
  • This directive will manage the area size (either relative to the image or to the viewport).
  • Each directive can be accessed:
    • Using a template variable through the exported name of responsiveImageArea.
    • From the Map directive through the areas property, which will return a QueryList<ResponsiveImageAreaDirective>.
  • The HTML <area> element can be reached through the nativeElement property.

Area Directive public Properties, Getters and Methods

| Property | Type | Returns | Description | |:---------|:-----|:--------|:------------| | areaSize | AreaSize | object | To access all the values (size & position) from the area (relative to the image) | | nativeElement | get | HTMLAreaElement | To access the HTML <area> element | | getBoundingClientRect() | method | DOMRect | To get the calculated position of the <area> element (relative to the viewport) | | updateCoords() | method | void | Will update the [coords] attribute based on the image size. (NOTE: there's no need to trigger this manually, the map directive will update when needed) |

The AreaSize Type

| Property | Type | Description | |:---------|:----:|:------------| | top | number | The area's (relative to image) top value | | left | number | The area's (relative to image) left value | | width | number | The area's width value | | height | number | The area's height value |

Working Example

TypeScript

import { ResponsiveImageMapDirective, MapSize, AreaSize } from '@a11y-ngx/responsive-image-maps';

@Component({ ... })
export class MyComponent {
    @ViewChild('imageMap') imageMap: ResponsiveImageMapDirective;

    updateOtherElements(newSize: MapSize): void {
        const width = newSize.width;
        const height = newSize.height;
        ...

        this.imageMap.areas.forEach(area => {
            const areaElement = area.nativeElement;
            const areaSize: AreaSize = area.areaSize;
            ...
        });
    }

    updateMapSizes(): void {
        this.imageMap.update();
    }
}

HTML

<img src="https://www.w3schools.com/html/workplace.jpg" alt="Workplace" usemap="#workmap">

<map name="workmap" #imageMap="responsiveImageMap" (sizeChanged)="updateOtherElements($event)">
    <area shape="rect" coords="34,44,270,350" alt="Computer" href="...">
    <area shape="rect" coords="290,172,333,250" alt="Phone" href="...">
    <area shape="circle" coords="337,300,44" alt="Coffee" href="...">
</map>