Where to invoke my code which sets timeline center date.

94 views
Skip to first unread message

kasaba

unread,
Jul 16, 2012, 9:55:14 AM7/16/12
to simile-...@googlegroups.com
Hi, fellows

I wrote that code which set center of my timeline bands. If minDate is 1000 and max date is 2000 from filtered data, my logic set center date 1500.

First I added that code as onclick with timeout 2000ms on facet link, but when some click are done quickly, timeline gets broken.
May be it's problem with the synchronization with the animation of timeline.

So, do you know where I can invoke my function, so timeline to work properly

My code is:

function setTimelineCenterDate() {
    var arr = exhibit.getDefaultCollection().getRestrictedItems().toArray();
    var min;
    var max;
    if (arr.length > 0) {
        min = exhibit.getDatabase().getObject(arr[0], "creationDate");
        max = min;
        var id;
        var val;
        for ( var i = 1; i < arr.length; i++) {
            val = exhibit.getDatabase().getObject(arr[i], "creationDate");
            if (val < min) {
                min = val;
            }
            if (val > max) {
                max = val;
            }
        }
        var intMin = parseInt(min);
        var intMax = parseInt(max);
        var middle = intMin + (intMax - intMin) / 2;
        timelineCenterDate = Timeline.DateTime.parseGregorianDateTime(middle);
    } else {
        timelineCenterDate = Timeline.DateTime
                .parseGregorianDateTime(getCurrentDate());
    }
    if (nuxeoTimeline != undefined) {
        setTimelineBandsCenterDate(nuxeoTimeline, timelineCenterDate)
    }
}

function setTimelineBandsCenterDate(nuxeo_timline) {
    nuxeo_timline.getBand(0).setCenterVisibleDate(timelineCenterDate);
    nuxeo_timline.getBand(1).setCenterVisibleDate(timelineCenterDate);
}

Thanks in advance.

Ryan Lee

unread,
Jul 18, 2012, 4:48:49 PM7/18/12
to simile-...@googlegroups.com
Hi,

It sounds like you're using Exhibit 2? In which case I think you can
actually just add your code to the collection's listener queue.

exhibit.getDefaultCollection().addListener({
"onItemsChanged": function() {
setTimelineCenterDate()
}
});

You'll probably want to check if Timeline is currently the view on
display before running code that refers to it.

The tricky part with Exhibit 2 is running that at the right time, after
the default collection has been created, though if you've figured out a
way to listen to facet clicks, perhaps you'll already have an idea of
where to insert that into your flow.
Reply all
Reply to author
Forward
0 new messages