twinssbc / Ionic-Calendar

A calendar directive for Ionic framework
http://twinssbc.github.io/Ionic-Calendar/demo
MIT License
159 stars 73 forks source link

Request: Event for user-initiated range change #94

Closed zeiphon closed 8 years ago

zeiphon commented 8 years ago

Hi,

Thanks for writing this particularly useful calendar control. I'm using it in a context where the user may either interact with the control itself, or some external controls that will trigger a change of date that the calendar is using. The problem I'm having is that changing this date externally will cause the calendar control to fire the rangeChanged event. I'm using the rangeChanged event to determine when the user has changed month slide (previous/next) since the timeSelected event is not triggered in this instance, and I need to load data for the new month. However the behaviour of my code is differs between program-initiated changes (e.g. external controls) and user-initiated changes (e.g. this calendar control's month slider).

Having an event that is triggered only if the user has directly manipulated the control (e.g. by swiping left/right) would be extremely useful.

twinssbc commented 8 years ago

@zeiphon Since your code triggers the change, I think you should be able to tell the difference by yourself? For example, when you trigger the change, you can also set a flag and check that flag in the rangeChanged callback. I think in normal case, even the change is triggered externally, you still want the event get fired. For example, if you change the current date to one day in next month programatically, the calendar will slide to next month and fires the rangeChanged event to allow you populate the events for next month.

zeiphon commented 8 years ago

Thanks for the response.

I was hoping to avoid a messy situation involving the use of flags and relying on often confusing digest cycles, but I can do this anyway.