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

lefleat_smooth_marker_bouncing

v1.1.3

Published

Smooth animation of marker bouncing for Leaflet.

Downloads

7

Readme

Leaflet.SmoothMarkerBouncing

Plugin for Leaflet that will make you markers bounce!

It provides smooth, lightweight and customisable animation of marker bouncing. Allows the bouncing of multiple markers on the map, without lose of performance. Plugin shows it's best performances on the 3D-able modern browsers, using hardware acceleration.
On old browsers plugin provides simplified animation.

Demo

Check out the demo.

Usage

Add Javascript file on your page:

<script type="text/javascript" src="js/leaflet.smoothmarkerbouncing.js" />

Plugin provides additional methods:

/* Methods of L.Marker class */
L.Marker.setBouncingOptions({..}); // sets options of bouncing of all markers
L.Marker.getBouncingMarkers();     // gets all bouncing markers
L.Marker.stopAllBouncingMarkers(); // asks all bouncing markers to stop

/* Methods of marker instances */
var marker = L.marker([lat, lng]);
marker.setBouncingOptions({..});   // sets options of bouncing of this marker
marker.isBouncing();               // checks if marker is bouncing
marker.bounce();                   // starts the bouncing
marker.bounce(n);                  // makes marker bounce "n" times
marker.stopBouncing();             // stops bouncing marker
marker.toggleBouncing();           // starts/stops bouncing of this marker

Plugin respects fluent API. All marker instance methods (except isBouncing) return the marker object.
Some usage examples:

/* Create a marker and make it bounce immediately */
var marker = L.marker([lat, lng]).bounce();

/* Create a marker and define it's bouncing options.
 * Bouncing can be started/stoped by the click on the marker.
 */
var marker = L.marker([lat, lng])
    .setBouncingOptions({
        bounceHeight : 60,    // height of the bouncing
        bounceSpeed  : 54,    // bouncing speed coefficient
        exclusive    : true,  // if this marker bouncing all others must stop
    }).on('click', function() {
        this.toggleBouncing();
    });

/* Define options of bouncing for all markers */
L.Marker.setBouncingOptions({
        bounceHeight : 60,   // height of the bouncing
        bounceSpeed  : 54,   // bouncing speed coefficient
});

/* Create 10 markers and each of them will bounce 3 times when clicked */
for (var i = 0; i < 10; i++) {
    var marker = L.marker([lat, lng])
        .on('click', function() {
            this.bounce(3); // bounce 3 times
        });
}

Options of bouncing

You can easily customize bouncing animation supplying options in method setBouncingOptions. This method available on the marker class L.Marker and on each of marker instances.
It's highly recommended to define options for all markers via L.Marker.setBouncingOptions instead of define them on each marker individually. The animation performance highly increases when all markers have the same options.
Method setBouncingOptions accepts an object with options as parameter. Animation can be customized with following properties:

  • bounceHeight - how high marker will bounce (px), default: 15
  • contractHeight - how much marker will contract when it touch the ground (px), default: 12
  • bounceSpeed - bouncing speed coefficient, value used to calculate the speed of bounce animation, more it becomes high, more animation becomes slow, default: 52
  • contractSpeed - contracting speed coefficient, default: 52
  • shadowAngle - shadow inclination angle, if set to null shadow animation is disabled (radians), default: - Math.PI / 4
  • elastic - activate contract animation when marker touch the ground, default: true
  • exclusive - when it's true, stops the bouncing of other markers when this one starts to bounce. If another marker start to bounce after, this marker stops. default: false

Tested on

:white_check_mark: Chrome 40.0
:white_check_mark: Firefox 35.0
:white_check_mark: IE 11
:white_check_mark: Android 4.4/5.0
:white_check_mark: Safari

License

Plugin distributed under BSD license.