My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
MouseWheelScrollingAndZooming  
Mouse-wheel behavior with Timelines
Updated Feb 4, 2010 by larryklu...@gmail.com

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); });
}

Comment by testchro...@gmail.com, Oct 7, 2008

am i able to push it in

var theme = Timeline.ClassicTheme?.create();

theme.event.bubble.width = 420; theme.event.b....

??????

Comment by milena.f...@gmail.com, Jan 18, 2009

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?

Comment by bruno.ne...@gmail.com, Jan 28, 2009

I try to use this zoom function but it doesn´t work.

Comment by milena.f...@gmail.com, Feb 7, 2009

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.

Comment by staff...@sics.se, Feb 24, 2009

It would be very nice if you could zoom programatically instead. Is that possible?

Comment by gauthier...@gmail.com, Apr 6, 2009

in timeline-bundle.js --> look for this : this.theme.mouseWheel:"scroll"; --> replace with zoom instead of scroll

Comment by jamu...@gmail.com, Jan 18, 2010

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) {};
Comment by wazhe.wi...@gmail.com, Apr 8, 2010

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

Comment by f.schwar...@gmail.com, Apr 14, 2010

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?

Comment by blaisekal@gmail.com, May 25, 2010

How to zoom programmatically:

// Zoom in: 
Timeline.getBand(0).zoom(true); // true zooms in, false zooms out

// You might want to repaint after 
Timeline.getBand(0).paint();
Comment by wit.jing...@gmail.com, May 25, 2010

var theme1 = Timeline.ClassicTheme?.create(); Timeline.createBandInfo({

width: 200, // set to a minimum, autoWidth will then adjust intervalUnit: Timeline.DateTime?.CENTURY, intervalPixels: 50,
eventSource: eventSource1, date: d, theme: theme1,

Comment by wit.jing...@gmail.com, May 25, 2010

theme1.mouseWheel='zoom';

Comment by wit.jing...@gmail.com, May 27, 2010

// 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!!!!

Comment by blaisekal@gmail.com, Jun 1, 2010

You have to check if the zoom index actually exists, otherwise you're switching to an non-existent zoom level.

Comment by nbethm...@gmail.com, Jul 15, 2010

Zooming with the mouse wheel works fine except I'm losing events off the top which makes it unusable.

Comment by ideana...@gmail.com, Aug 10, 2010

Zoom using keyboard: use ctrl + up and down scroll. Hope this helps.

Comment by alanle...@gmail.com, Dec 14, 2011

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.

Comment by vishal17...@gmail.com, Jan 4, 2012

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


Sign in to add a comment
Powered by Google Project Hosting