-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add support for multiple class names in utils add/remove class methods. #3079
Add support for multiple class names in utils add/remove class methods. #3079
Conversation
Reset subgroup heights in resetSubgroups method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good. Needs a small revision
lib/util.js
Outdated
| classes.splice(index, 1); // remove the class from the array | ||
| elem.className = classes.join(' '); | ||
| var oldClasses = classNames.split(' '); | ||
| for (var i = 0; i < oldClasses.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could do this better:
classes = classes.concat(oldClasses.filter(function (className) {
return classes.indexOf(className) < 0;
}));…ithub.com:BTMorton/vis into fixResetSubgroupHeightsAndAllowMultipleClassNames
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a problem with this PR.
You've added 2 changes that are unrelated and do not reference any issue.
I can understand the this.subgroups[subgroup].height = 0; But not the rest.
Where do you use addition od multi classNames? Why is this in the same PR? I would implement it by allowing an array of classes and not a string of classes. It seems dirty to me...
|
You make fair points. These are issues that I came across while trying to add dynamic heights to the Timeline for our use case. Each group/item has a class that adds various CSS properties to them based on the type of event, and I was trying to add a second class that changes things based upon the height. I could have done it using more complex single classes or with partial class selectors, but that seemed wrong. I could have changed it to allow for an array of class names, but that would change the timeline options and affect larger parts of the code base, whereas this adds support for it without breaking any existing functionality. The reason they're together was because I encountered them while working on the same thing, and I was being lazy and trying to sneak them in before the release :P |
|
Look, I'll approve them for now because the release is tomorrow and I think this PR is important enough to go in. Please don't let this happen again. I don;t like lazy PRs =P |
|
Fair enough, apologies for that. And thanks for accepting it anyway. :) |
Reset subgroup heights in resetSubgroups method.