Skip to content

restart animation  #46

@jeremymauro

Description

@jeremymauro

I needed to restart the animation when a user clicks a button. I added this to the AnimatedMarker.js file

  reStart: function(latlngs){
    this.initialize(latlngs);
    // Don't show CSS transition back to initial position
    this._icon.style[L.DomUtil.TRANSITION] = ('all ' + 0 + 'ms linear')
    this._shadow.style[L.DomUtil.TRANSITION] = ('all ' + 0 + 'ms linear')
    // Reset marker to initial position
    this.setLatLng(this._latlngs[0]);
    var that = this;
    setTimeout(function(){
      that.start();
    }, 200)
  }

...and this to my onclick handler

animatedMarker.reStart(line.getLatLngs());

There may be a better solution, but this is working for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions