Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restart animation #46

Open
jeremymauro opened this issue Dec 19, 2016 · 0 comments
Open

restart animation #46

jeremymauro opened this issue Dec 19, 2016 · 0 comments

Comments

@jeremymauro
Copy link

jeremymauro commented Dec 19, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant