cal-heatmap icon indicating copy to clipboard operation
cal-heatmap copied to clipboard

Adding an onHighlight callback

Open dominicbarnes opened this issue 10 years ago • 6 comments

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.

dominicbarnes avatar May 20 '14 22:05 dominicbarnes

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.

dominicbarnes avatar May 21 '14 02:05 dominicbarnes

I've confirmed that the issue was not caused by this change at all, I was misunderstanding how to use the update method properly.

dominicbarnes avatar May 22 '14 15:05 dominicbarnes

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.

wa0x6e avatar Jun 13 '14 12:06 wa0x6e

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.

dominicbarnes avatar Jun 13 '14 15:06 dominicbarnes

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.

dominicbarnes avatar Jun 13 '14 15:06 dominicbarnes

Or, maybe add an appendHighlightDates function ...

wa0x6e avatar Jun 18 '14 14:06 wa0x6e

Closing, not relevant anymore.

v4 is now using init() to update the highlighted dates

wa0x6e avatar Dec 15 '22 22:12 wa0x6e