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 🙏

© 2024 – Pkg Stats / Ryan Hefner

leaflet-responsive-popup

v1.0.0

Published

Removes the need to move the map to be able to see the content of a L.Popup

Downloads

84,377

Readme

Leaflet Responsive Popup

This plugin removes the need to move the map to be able to see the content of the popup. This happens when opening a popup near an edge of the map. The implementation overrides L.Popup.

Leaflet L.Popup Leaflet L.ResponsivePopup

Here is a demo and a use case.

Usage

include leaflet and leaflet-responsive-popup

<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
	
<script src="https://unpkg.com/[email protected]/leaflet.responsive.popup.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/leaflet.responsive.popup.css" />

RTL support

If your pages use rtl (right to left) direction, add leaflet.responsive.popup.rtl.css

<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
	
<script src="https://unpkg.com/[email protected]/leaflet.responsive.popup.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/leaflet.responsive.popup.css" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/leaflet.responsive.popup.rtl.css" />

bind a L.ResponsivePopup to your markers

var popup = L.responsivePopup().setContent('A pretty CSS3 responsive popup.<br> Easily customizable.');
L.marker([48.850258, 2.351074], { icon: myIcon }).addTo(map).bindPopup(popup);

Angular support

See examples:

  • https://github.com/yafred/ng-leaflet-responsive-popup (Angular)
  • https://github.com/yafred/ngx-leaflet-responsive-popup (Angular @asymmetrik/ngx-leaflet)

Options

offset

The offset of the popup position.

As the position of the popup is not always above, it is slightly different from the L.Popup option.

offset.x is used when the popup is either left or right. offset.y is used when the popup is either top or bottom.

var popup = L.responsivePopup({ offset: [10,10] }).setContent('A pretty CSS3 responsive popup.<br> Easily customizable.');
L.marker([48.850258, 2.351074], { icon: myIcon }).addTo(map).bindPopup(popup);

autoPanPadding

Space (in pixels) we allow between the popup and the border of the map before we consider the popup is overflowing. autoPanPadding.x is used to prevent left and right overflows, autoPanPadding.y is used to prevent top and bottom overflows.

var popup = L.responsivePopup({ autoPanPadding: [10,10] }).setContent('A pretty CSS3 responsive popup.<br> Easily customizable.');
L.marker([48.850258, 2.351074], { icon: myIcon }).addTo(map).bindPopup(popup);

hasTip

var popup = L.responsivePopup({ hasTip: false }).setContent('A pretty CSS3 responsive popup.<br> Easily customizable.');
L.marker([48.850258, 2.351074], { icon: myIcon }).addTo(map).bindPopup(popup);

If you don't show the tips, you can either change the icon of the marker like here.

Changing marker icon to highlight position

or add another marker to highlight the marker's position.

Adding a marker icon to highlight position

map.on('popupopen',function(e) {
  e.popup.highlight = L.circleMarker(e.popup.getLatLng(), { radius: 15 , opacity: 0, fillColor: "#000000", fillOpacity: .3 }).addTo(map);
});
    	
map.on('popupclose',function(e) {
  map.removeLayer(e.popup.highlight);
});

Notes

Leaflet 1.0 to 1.7: you need to use leaflet-responsive-popup 0.6.4

Leaflet 1.8: you need to use leaflet-responsive-popup 1.0.0

This was inspired by Rrose: A Leaflet Plugin for Edge Cases.