Browse Source

Add vertical scroll when zoom is inactive

codeClimate
Yotam Berkowitz 8 years ago
parent
commit
31096e04f6
1 changed files with 30 additions and 1 deletions
  1. +30
    -1
      lib/timeline/Core.js

+ 30
- 1
lib/timeline/Core.js View File

@ -161,6 +161,35 @@ Core.prototype._create = function (container) {
this.dom.root.addEventListener('mousewheel', onMouseWheel); this.dom.root.addEventListener('mousewheel', onMouseWheel);
this.dom.root.addEventListener('DOMMouseScroll', onMouseWheel); this.dom.root.addEventListener('DOMMouseScroll', onMouseWheel);
function onMouseWheelCenter(event) {
// prevent scrolling when zoomKey defined or activated
if (!me.options.zoomKey || event[me.options.zoomKey]) return
var delta = 0;
if (event.wheelDelta) { /* IE/Opera. */
delta = event.wheelDelta / 120;
} else if (event.detail) { /* Mozilla case. */
// In Mozilla, sign of delta is different than in IE.
// Also, delta is multiple of 3.
delta = -event.detail / 3;
}
var current = me.props.scrollTop;
var adjusted = current + delta * 120;
if (me.isActive()) {
me._setScrollTop(adjusted);
me._redraw();
me.emit('scroll', event);
}
// Prevent default actions caused by mouse wheel
// (else the page and timeline both scroll)
event.preventDefault();
}
this.dom.center.addEventListener('mousewheel', onMouseWheelCenter);
this.dom.center.addEventListener('DOMMouseScroll', onMouseWheelCenter);
// size properties of each of the panels // size properties of each of the panels
this.props = { this.props = {
root: {}, root: {},
@ -222,7 +251,7 @@ Core.prototype.setOptions = function (options) {
var fields = [ var fields = [
'width', 'height', 'minHeight', 'maxHeight', 'autoResize', 'width', 'height', 'minHeight', 'maxHeight', 'autoResize',
'start', 'end', 'clickToUse', 'dataAttributes', 'hiddenDates', 'start', 'end', 'clickToUse', 'dataAttributes', 'hiddenDates',
'locale', 'locales', 'moment', 'rtl'
'locale', 'locales', 'moment', 'rtl', 'zoomKey'
]; ];
util.selectiveExtend(fields, this.options, options); util.selectiveExtend(fields, this.options, options);

Loading…
Cancel
Save