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

Events for selecting #491

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tsparksh
Copy link
Member

@tsparksh tsparksh commented Dec 24, 2019

Fixes #460

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with grunt
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updates
  • @mention the original creator of the issue in a comment below for help or for a review

Example:

$(img).on("deselectImage", function() {
  console.log("deselected");
});

$(img).on("selectImage", function() {
  console.log("selected");
});

select-events

@tsparksh
Copy link
Member Author

tsparksh commented Dec 24, 2019

I used selectImage because select event is already used in jQuery

(Tests works fine with #493)

@Uzay-G
Copy link
Member

Uzay-G commented Dec 31, 2019

Hey @tsparksh are you working on this? The task is open on Github

@tsparksh
Copy link
Member Author

@Uzay-G, on the gci dashboard for some reason there are two identical tasks with a link to this issue, my task is marked as accepted

@Uzay-G
Copy link
Member

Uzay-G commented Dec 31, 2019

Ok alright thanks

Copy link
Contributor

@VladimirMikulic VladimirMikulic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tsparksh 👍

@VladimirMikulic
Copy link
Contributor

VladimirMikulic commented Jan 10, 2020

This is optional, but instead of using jQuery and adding it to the test dependecies you could have done this in JavaScript:

var selectImageEvent = new Event('selectImage');
this.dispatchEvent(selectImageEvent);

Copy link
Member

@sashadev-sky sashadev-sky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VladimirMikulic thank you for reviewing! @tsparksh haven't gotten the chance to review this yet but for now can you please implement the suggestion regarding jQuery.

jQuery is already a dependency so using it was fair game but I actually have been wanting to update the few lines in the repo that use it to vanilla JS and remove it

@sashadev-sky
Copy link
Member

also I think running this and pushing will fix your travis build:

$ rm -rf package-lock.json node_modules
$ npm install

@tsparksh
Copy link
Member Author

tsparksh commented Jan 10, 2020 via email

@sashadev-sky
Copy link
Member

@tsparksh okay no problem! Please note that the mentor approved the task for you so that you could move on to others in my absence, but you still need to complete them (merged PR) to actually get the points!

@tsparksh
Copy link
Member Author

Usage:

image = img._image
image.addEventListener("selectImage", function(event) {
    console.log(event.type);
  });
image.addEventListener("deselectImage", function(event) {
    console.log(event.type);
  });

events

@tsparksh
Copy link
Member Author

@sashadev-sky, can you check, please

Copy link
Member

@sashadev-sky sashadev-sky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best thing to do here woudl be to use leaflet's fire (it's pretty much like trigger) so sorry didnt look into this more thoroughly before.

This would be an example of the sort of syntax looking for:

_onHandleDragStart: function() {
this._handled.fire('editstart');
},

so maybe something like this.fire("select") and putting it up higher in the method like after the line:

if (!edit.enabled()) { return false; }

@sagarpreet-chadha @VladimirMikulic @jywarren @sidntrivedi012 what do ya'll think
** as background ** i think these methods will be utilized by MK to allow for synchronous editing.

@VladimirMikulic
Copy link
Contributor

I agree @sashadev-sky. Consistency is important.
I didn't know that fire method existed, but know that I know we should definitely use it instead of 'manually' creating an event and dispatching it.

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

Successfully merging this pull request may close these issues.

Events for select and deselect
5 participants