cal-heatmap
cal-heatmap copied to clipboard
Adding an onHighlight callback
I found it useful to have an onHighlight
callback function that would be run whenever dates are highlighted. I was keeping track of this myself before, but needing to hook in both on init and during update is a little clumsy, this makes the interface a little more straightforward.
I'm going to close this for now, I'm having trouble locally and I'm not sure whether or not this change is the culprit. I'll re-open later if I figure out what's going on.
I've confirmed that the issue was not caused by this change at all, I was misunderstanding how to use the update
method properly.
I have not testd it yet, but your implementation seems to trigger the highlight event on all highlighted dates, when I append some new dates to an array of already existing highlighted dates.
Yeah, that's true. I didn't see an easy way to distinguish between what was highlighted previously, so the function is called for all of them each time the list of highlighted values changes.
I could convert this into more of true event. Right now, this behaves like a "hook" (since you can only have 1 function, and it's not triggered like an event)
I could look into emitting separate events for each highlighted date, and probably adding a corresponding "unhighlighted" event for handling the reverse.
Or, maybe add an appendHighlightDates
function ...
Closing, not relevant anymore.
v4 is now using init() to update the highlighted dates