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

Delete all links/plots using 'update' event #106

Merged

Conversation

Indigo744
Copy link
Collaborator

Allows to refresh the entire map (#104)

Usage:

var deletedPlots = "all", 
opt = {
    animDuration : 1000,
    deletedLinks : "all"
    };

$(".mapcontainer").trigger('update', [{}, {}, deletedPlots, opt]);

Working JSFiddle : http://jsfiddle.net/q0mdfxvr/2/

Allow delete all plots/links in the `update` event.
fnRemoveElement(elem);
});
// Empty plots array
plots.length = 0;
Copy link
Owner

Choose a reason for hiding this comment

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

Why haven't you wrote "plots = {};" for resetting the object ? Is your way faster ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question. I actually did some research because I wasn't sure. Turned out = {}is not the best way to do it: it will keep any referenced array as is. See this SO answer: http://stackoverflow.com/a/1232046

Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, in any case, I think it shouldn't work properly because the variables plots and areas are objects and not arrays, so they shouldn't have the 'length' property.

Moreover, by using this way for resetting an array, I wonder how the garbage collector behaves ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh right, I don't know why I supposed that plots or links were array! They are object! I will change it.
For array, setting length to 0 will shrink the array size automatically.

@neveldo
Copy link
Owner

neveldo commented Nov 14, 2015

Hello,

Thank you for the change, and the explanation :) I merge your PR !

neveldo added a commit that referenced this pull request Nov 14, 2015
…all-links-plots

Delete all links/plots using 'update' event
@neveldo neveldo merged commit 2c219cb into neveldo:master Nov 14, 2015
@Indigo744 Indigo744 deleted the Indigo744-patch-update-delete-all-links-plots branch November 14, 2015 15:13
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

Successfully merging this pull request may close these issues.

2 participants