Is it possible to set a minimum and maximum time on the timeline pan?

91 views
Skip to first unread message

Ben Welsh

unread,
Apr 13, 2009, 6:17:07 PM4/13/09
to Timemap.js Development
I'd like to be able to limit the pan so users can't scroll off into
the abyss. Is there a bandInfo setting that can do that?

I'm looking at the docs here ...

http://code.google.com/p/simile-widgets/wiki/Timeline_BandClass

...and having trouble getting getMinDate() to work in bandInfo.

Thanks again,

Ben.

Nick Rabinowitz

unread,
Apr 13, 2009, 7:59:50 PM4/13/09
to ben....@gmail.com, Timemap.js Development
I'm not sure Timeline can do this out of the box - there doesn't seem to be a setMinDate() function. It's possible you could get what you want with some combination of band.setViewLength() or band.SCROLL_MULTIPLES - not sure I entirely understand these, though. See http://static.simile.mit.edu/timeline/api-2.2.0/scripts/timeline.js for the later-version code. You can access the top band directly at tm.timeline.getBand(0).

Another approach would be to add a listener to the top band, and if the user scrolls beyond the desired date, reset to the min date - something like:

var band = tm.timeline.getBand(0);
band.minDateLimit = someDate;
band.addOnScrollListener(function() {
  if (band.getMinVisibleDate() < band.minDateLimit) {
    band.setMinVisibleDate(band.minDateLimit);
  }
  // repeat for maximum
});

Though it might cause the band to flip out - not sure. Hope that helps -

-Nick

Ben Welsh

unread,
Apr 13, 2009, 8:01:54 PM4/13/09
to Timemap.js Development
Thanks again, Nick. I'll definitely give that try. Though I'm also
thinking about painting some bright lines at the beginning and end of
the data range so people will get a visual cue.

And now I'll pepper the list with one final annoying question for the
day. Stand by!

On Apr 13, 4:59 pm, Nick Rabinowitz <nick.rabinow...@gmail.com> wrote:
> I'm not sure Timeline can do this out of the box - there doesn't seem to be
> a setMinDate() function. It's possible you could get what you want with some
> combination of band.setViewLength() or band.SCROLL_MULTIPLES - not sure I
> entirely understand these, though. Seehttp://static.simile.mit.edu/timeline/api-2.2.0/scripts/timeline.jsfor the
> later-version code. You can access the top band directly at
> tm.timeline.getBand(0).
>
> Another approach would be to add a listener to the top band, and if the user
> scrolls beyond the desired date, reset to the min date - something like:
>
> var band = tm.timeline.getBand(0);
> band.minDateLimit = someDate;
> band.addOnScrollListener(function() {
>   if (band.getMinVisibleDate() < band.minDateLimit) {
>     band.setMinVisibleDate(band.minDateLimit);
>   }
>   // repeat for maximum
>
> });
>
> Though it might cause the band to flip out - not sure. Hope that helps -
>
> -Nick
>

bancarel valentin

unread,
Feb 24, 2015, 11:42:15 AM2/24/15
to timemap-d...@googlegroups.com, ben....@gmail.com
Sorry for the very late post but I found this post which was very helpful for me but what Nick said was not totally correct I think because the method "setMinVisibleDate" check if the user is scrolling and if he is it's doing nothing so if you call it in the onScroll event it's completely silly cause it will never do anything. Or maybe I'm completely wrong, if that's the case, please correct me.

Anyway to get around this, I redefine the method "setMinVisibleDate" which is define in timemap-1.2.js or other following your version and I delete the if statement. And I do the same for the "setMaxVisibleDate" method.

Hope that's helpful.

bancarel valentin

unread,
Feb 24, 2015, 11:55:57 AM2/24/15
to timemap-d...@googlegroups.com
Read that before apply changes I tell in the previous post, yes the function is doing nothing when called from the on Scroll but if you take out the if(!isChanging), then your browser will throw an "Uncaught RangeError: Maximum call stack size exceeded" when you go out of the dates range and without releasing the mouse click on the timeline. So I'm looking for a way to do that another, if you guys have any clue, you're welcome.
Reply all
Reply to author
Forward
0 new messages