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.control.resizer

v0.0.1

Published

Control to resize a Leaflet map

Downloads

1,012

Readme

Leaflet.Control.Resizer

NPM version License Leaflet 1.x compatible!

Control to resize a Leaflet map

Simple example in action

Description

This plugin creates a control to resize your map on the right or bottom side. See that top and left are not a 'resize' but a 'move' inside your DOM... that is another story.

Installation

Using npm for browserify npm install leaflet.control.resizer (and require('leaflet.control.resizer')), or just download L.Control.Resizer.js and L.Control.Resizer.css and add a script and link tag for it in your html.

Compatibility

Tested with Leaflet 1.0.3 and 1.3.1. It does not work with 0.7 due to deprecated functionalities. However it is easy to change the code to make it compatible (come on, it is time to update to Leaflet 1.x)

Usage

Just add a control as usual.

  var osm = L.tileLayer(
      '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
      {attribution: '© OpenStreetMap contributors'}
  );
  var map = L.map('map', {
      layers: [osm],
      center: [40, 0],
      zoom: 3
  });


  L.control.resizer({ direction: 'e' }).addTo(map);

API

L.Control.Resizer

The main (and only) 'class' involved in this plugin. It exteds L.Control, so most of its methods are available.

L.control.resizer(options)

Creates the control. The arguments are:

  • options: <Object> specific options for this control.
constructor options
  • direction: <String> Direction of the resizer. Valid values are 'e', 's', 'se'. Default 'e'.
  • onlyOnHover: <Boolean> Shows the control only when the mouse is over. Default 'false'.
  • updateAlways: <Boolean> Determines if invalidateSize is called on every mouse movement. Default 'true'.
  • pan: <Boolean> Specifies if the fixed point during the resize is the center. If not, it is the top left corner (that means that the map doesn't move. Default 'false'.

If you don't like the style of the handles, overwrite the css styles ;)

enable()

Enables the control. Run by default on construction. Returns this.

disable()

Disables the control. Returns this.

fakeHover(ms)

Fakes the hover effect during ms milliseconds, that is, when the mouse passes over the control. Useful when onlyOnHover is true, and you want to show where is the control.

Events

This class fires the same events as L.Draggable. You can get them as usual. For example:

var southResizer = L.control.resizer({ direction: 's' }).addTo(map);
L.DomEvent.on(southResizer, 'dragstart', function(e){ console.log(e.type, e) });

The events are:

  • down: When the mouse is clicked over the control.
  • dragstart: When the drag starts.
  • predrag: On every movement, just before the map resize.
  • drag: On every movement, just after the map resize.
  • dragend: At the end of the resize.