Public Lab

Add a #replaceTool method

Problem

We already have methods #addTool, #removeTool and #hasTool for the L.DistortableImage.Edit class:

https://github.com/publiclab/Leaflet.DistortableImage/blob/0a162b57aac8be4644a878901567f306c3c006ee/src/edit/DistortableImage.Edit.js#L211-L238

We would like a #replaceTool method now. It should take in 2 tools: the 1st gets removed from the toolbar, the 2nd takes its place.

Solution

You can use the other methods mentioned above for reference.

Part 1:

  • add a #replaceTool method
  • document it in the README (just follow the current documentation pattern - see other tool related methods documented for reference)
  • add a test for it - test that it adds the tool in the same index position as the old tool, not to the end of the array
  • bump the package 1 minor version "x" given "0.0.x" so we can pull the new version into our MapKnitter repository, which uses this library for some of its core functionality, and use this function!

Additional Information

Please find further information on installation, solving, & getting help on the linked issue.

Thank you 😊

Task tags

  • npm
  • medium
  • javascript

Students who completed this task

NotDeGhost

Task type

  • code Code
  • chrome_reader_mode Documentation / Training
close

2019