Introduction
When displaying a Timeline, the mouse-wheel can act in any of three ways while the mouse is over a Timeline band:
- Scroll -- the mouse-wheel will scroll the Timeline forward and backward in time. This is similar to pressing the arrow keys. Difference is that holding down an arrow key will accelerate the scrolling speed. This action is set by the default theme.
- Zoom -- the mouse-wheel will change the timescale of the Timeline. Zooming is an alternative to using Hotzones to change the timescale.
- Default -- the mouse-wheel will scroll the container or window depending on where the vertical scrollbars are (if any). The Timeline will be neither scrolled or zoomed.
Change the mouse-wheel behavior in your theme file.
User Interface Tips
It can be confusing to your users to have the mouse-wheel scroll the page when the mouse in some places on the browser screen and either scroll or zoom a Timeline when the mouse in other places.
You may wish to design your pages to eliminate the vertical scroll bar. This can be done by resizing the height of the items on your page when the viewport size is changed.
Known issue: Apple Multi-Touch scrolling
Mac computers can be configured to use "Multi-Touch" trackpad gestures. The scrolling multi-touch appears to send mouse-wheel events to both the Timeline (causing a scroll or zoom) and to the entire window, causing a scroll if the window has a scrollbar. Work-arounds: Plan your page to not have a vertical scrollbar or set the Timeline mouseWheel option to 'default'. Thank you Jon Crump for the report.
Zooming
To use the mouse-wheel for zooming:
- Change the mouseWheel setting in your theme.
- Decide on the intervalPixels and intervalUnit steps that you would like the user to be able to zoom to. The BandInfo object's intervalUnit and intervalPixels parameters must correspond with one of these steps, and the index of this default step must be passed along as the zoomIndex.
Zooming example in action: See the file webapp/docs/create-timelines.html (only available in the source files at this time)
Example
- See the zoomIndex and zoomSteps fields below
function onLoad() {
var eventSource = new Timeline.DefaultEventSource();
var bandInfos = [
Timeline.createBandInfo({
date: "Jun 28 2006 00:00:00 GMT",
width: "70%",
intervalUnit: Timeline.DateTime.MONTH,
intervalPixels: 100,
eventSource: eventSource,
zoomIndex: 10,
zoomSteps: new Array(
{pixelsPerInterval: 280, unit: Timeline.DateTime.HOUR},
{pixelsPerInterval: 140, unit: Timeline.DateTime.HOUR},
{pixelsPerInterval: 70, unit: Timeline.DateTime.HOUR},
{pixelsPerInterval: 35, unit: Timeline.DateTime.HOUR},
{pixelsPerInterval: 400, unit: Timeline.DateTime.DAY},
{pixelsPerInterval: 200, unit: Timeline.DateTime.DAY},
{pixelsPerInterval: 100, unit: Timeline.DateTime.DAY},
{pixelsPerInterval: 50, unit: Timeline.DateTime.DAY},
{pixelsPerInterval: 400, unit: Timeline.DateTime.MONTH},
{pixelsPerInterval: 200, unit: Timeline.DateTime.MONTH},
{pixelsPerInterval: 100, unit: Timeline.DateTime.MONTH} // DEFAULT zoomIndex
)
}),
Timeline.createBandInfo({
date: "Jun 28 2006 00:00:00 GMT",
width: "30%",
intervalUnit: Timeline.DateTime.YEAR,
intervalPixels: 200,
showEventText: false,
trackHeight: 0.5,
trackGap: 0.2,
eventSource: eventSource,
overview: true
})
];
bandInfos[1].syncWith = 0;
bandInfos[1].highlight = true;
tl = Timeline.create(document.getElementById("my-timeline"), bandInfos);
Timeline.loadXML("example2.xml", function(xml, url) { eventSource.loadXML(xml, url); });
}
am i able to push it in
var theme = Timeline.ClassicTheme?.create();
??????
Hi, I am very interested in implementing this function into my project, but it doesn't seem to be working.
The necessary documents that show zooming are in: http://code.google.com/p/simile-widgets/source/browse/timeline/trunk/src/webapp/docs/create-timelines.html?r=1418&spec=svn1418 and http://code.google.com/p/simile-widgets/source/browse/timeline/trunk/src/webapp/docs/create-timelines.js?r=1418&spec=svn1418
However, even when I run this code, the zooming option doesn't work.
Any info on this?
I try to use this zoom function but it doesn´t work.
I made it work when I downloaded the API to my local server, modifying this line of code: this.mouseWheel = 'zoom'; in file themes.js. I'm using Timeline v2.3.0.
It would be very nice if you could zoom programatically instead. Is that possible?
in timeline-bundle.js --> look for this : this.theme.mouseWheel:"scroll"; --> replace with zoom instead of scroll
If you don't like any of Timeline's scrolling options and would like to prevent the widget from hijacking these events altogether the following code should do the trick:
// Override all scroll wheel handling to let the browser work as normal Timeline._Band.prototype._onMouseScroll = function(innerFrame, evt, target) {};Hi!
May I know the link for the source code (timeline-bundle.js?) that I can change the mouseWheel to "zoom"? Thanks a lot.
Angelia
Hey there, works nicely, well as long as the user got a mousewheel. Is it possible to zoom with the keyboard, additionally to the mousewheel zoom?
How to zoom programmatically:
var theme1 = Timeline.ClassicTheme?.create(); Timeline.createBandInfo({
theme1.mouseWheel='zoom';
// Zoom in: Timeline.getBand(0).zoom(true); // true zooms in, false zooms out
// You might want to repaint after Timeline.getBand(0).paint();
have bug!!!! if you ring left scroll then Timeline.getBand(0).zoom(true); you well see the div is blank!!!!
You have to check if the zoom index actually exists, otherwise you're switching to an non-existent zoom level.
Zooming with the mouse wheel works fine except I'm losing events off the top which makes it unusable.
Zoom using keyboard: use ctrl + up and down scroll. Hope this helps.
I know it is off topic but I have added a zoom bar to the timeline. I have also added a helper function initZoomSteps. This currently only works for century/decades but I will be adapting it soon for day/month/year. The demo is at http://ec2-50-19-52-89.compute-1.amazonaws.com/AlsTimelines.html. The code is at my github repository - https://github.com/alan-leslie/Timeline-zoombar.
Hi,
The source code for the above mentioned files can be found at :
http://code.google.com/p/simile-widgets/wiki/Timeline_Releases_and_Access
Incase you need to implement zoom, you have to modify your existing html file with the code given above. Sample implementation is here :
http://web.iiit.ac.in/~vishal.gargug08/timeline/example/monet/monet.html
-vishal garg