-
Notifications
You must be signed in to change notification settings - Fork 620
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
API for adding multiple events? #432
Comments
Hi! Can you please elaborate what kind of API you were imagining for this feature? Thanks! |
What I need is that , if it was possible to add multiple events . As of now I found that the 'add' method adds only one event.In our case there are more than one event that needs to be added.What we are doing is that we are looping in each event that needs to be added.So there is a performance issue in that.The browser hangs till the loop finishes.So can you suggest something for it? Thanks! |
I had the same issue and I hacked into the library a bit...but it fails to work properly. I added just this code to my custom JS: TL.Timeline.prototype.addBatch = function (events) {
for (var i in events) {
this._addDeferred(events[i]);
}
// FIXME: Sorting destroys grouping
TL.DateUtil.sortByDate(this.config.events);
TL.DateUtil.sortByDate(this.config.eras);
this._storyslider._updateDrawSlides();
this._timenav._updateDrawTimeline(false);
for (i in events) {
this.fire("added", {unique_id: events[i].unique_id});
}
};
TL.Timeline.prototype._addDeferred = function (data) {
var unique_id = this.config.addEvent(data, true); // defer sorting
var n = this._getEventIndex(unique_id);
var d = this.config.events[n];
this._storyslider.createSlide(d, this.config.title ? n+1 : n);
this._timenav.createMarker(d, n);
}; From the outside just call
Maybe you can give me a hint where I made a mistake. |
@shaula were you able to come up with a solution that worked? I am currently facing the same issue. |
We will readily admit that TimelineJS was not really developed with a full MVC model. That is, when event "model objects" are added or changed, the corresponding views don't automatically update. Support for that was not a primary use case, and to correct the data/lifecycle issues in the current codebase would be no small project, especially given that our design target for TimelineJS is storytelling, which is usually not so dynamic. You are almost certainly better off just manipulating a JSON representation of the timeline and instantiating a new timeline when you need it. If you wanted the viewer to stay on the same slide they were at, you'd need to take some more steps, but that would still probably be easier than reimplementing the existing codebase as proper MVC. |
Is there an API for adding multiple events?
The text was updated successfully, but these errors were encountered: