Browse Source

Fixed #541: `setWindow` not working when applying an interval larger than the configured `zoomMax`.

v3_develop
jos 9 years ago
parent
commit
89cacf51dc
6 changed files with 23 additions and 15 deletions
  1. +2
    -2
      HISTORY.md
  2. +9
    -5
      dist/vis.js
  3. +1
    -1
      dist/vis.map
  4. +2
    -2
      dist/vis.min.js
  5. +4
    -1
      lib/timeline/Core.js
  6. +5
    -4
      lib/timeline/Range.js

+ 2
- 2
HISTORY.md View File

@ -20,7 +20,6 @@ http://visjs.org
- Added opacity option to edges. Opacity is only used for the unselected state. - Added opacity option to edges. Opacity is only used for the unselected state.
- Fixed bug where selections from removed data elements persisted. - Fixed bug where selections from removed data elements persisted.
### DataSet/DataView ### DataSet/DataView
- Added property `length` holding the total number of items to the `DataSet` - Added property `length` holding the total number of items to the `DataSet`
@ -39,7 +38,8 @@ http://visjs.org
- Fixed width of range items not always being maintained when moving due to - Fixed width of range items not always being maintained when moving due to
snapping to nice dates. snapping to nice dates.
- Fixed not being able to drag items to an other group on mobile devices. - Fixed not being able to drag items to an other group on mobile devices.
- Fixed `setWindow` not working when applying an interval larger than the
configured `zoomMax`.
## 2015-01-16, version 3.9.1 ## 2015-01-16, version 3.9.1

+ 9
- 5
dist/vis.js View File

@ -7921,7 +7921,7 @@ return /******/ (function(modules) { // webpackBootstrap
me.animateTimer = setTimeout(next, 20); me.animateTimer = setTimeout(next, 20);
} }
} }
}
};
return next(); return next();
} }
@ -8015,7 +8015,7 @@ return /******/ (function(modules) { // webpackBootstrap
zoomMin = 0; zoomMin = 0;
} }
if ((newEnd - newStart) < zoomMin) { if ((newEnd - newStart) < zoomMin) {
if ((this.end - this.start) === zoomMin) {
if ((this.end - this.start) === zoomMin && newStart > this.start && newEnd < this.end) {
// ignore this action, we are already zoomed to the minimum // ignore this action, we are already zoomed to the minimum
newStart = this.start; newStart = this.start;
newEnd = this.end; newEnd = this.end;
@ -8035,8 +8035,9 @@ return /******/ (function(modules) { // webpackBootstrap
if (zoomMax < 0) { if (zoomMax < 0) {
zoomMax = 0; zoomMax = 0;
} }
if ((newEnd - newStart) > zoomMax) { if ((newEnd - newStart) > zoomMax) {
if ((this.end - this.start) === zoomMax) {
if ((this.end - this.start) === zoomMax && newStart < this.start && newEnd > this.end) {
// ignore this action, we are already zoomed to the maximum // ignore this action, we are already zoomed to the maximum
newStart = this.start; newStart = this.start;
newEnd = this.end; newEnd = this.end;
@ -8052,7 +8053,7 @@ return /******/ (function(modules) { // webpackBootstrap
var changed = (this.start != newStart || this.end != newEnd); var changed = (this.start != newStart || this.end != newEnd);
// if the new range does NOT overlap with the old range, emit checkRangedItems to avoid not showing ranged items (ranged meaning has end time, not neccesarily of type Range)
// if the new range does NOT overlap with the old range, emit checkRangedItems to avoid not showing ranged items (ranged meaning has end time, not necessarily of type Range)
if (!((newStart >= this.start && newStart <= this.end) || (newEnd >= this.start && newEnd <= this.end)) && if (!((newStart >= this.start && newStart <= this.end) || (newEnd >= this.start && newEnd <= this.end)) &&
!((this.start >= newStart && this.start <= newEnd) || (this.end >= newStart && this.end <= newEnd) )) { !((this.start >= newStart && this.start <= newEnd) || (this.end >= newStart && this.end <= newEnd) )) {
this.body.emitter.emit('checkRangedItems'); this.body.emitter.emit('checkRangedItems');
@ -22629,6 +22630,7 @@ return /******/ (function(modules) { // webpackBootstrap
* start or only end. Syntax: * start or only end. Syntax:
* *
* TimeLine.setWindow(start, end) * TimeLine.setWindow(start, end)
* TimeLine.setWindow(start, end, options)
* TimeLine.setWindow(range) * TimeLine.setWindow(range)
* *
* Where start and end can be a Date, number, or string, and range is an * Where start and end can be a Date, number, or string, and range is an
@ -22644,12 +22646,14 @@ return /******/ (function(modules) { // webpackBootstrap
* for the animation. Default duration is 500 ms. * for the animation. Default duration is 500 ms.
*/ */
Core.prototype.setWindow = function(start, end, options) { Core.prototype.setWindow = function(start, end, options) {
var animate = (options && options.animate !== undefined) ? options.animate : true;
var animate;
if (arguments.length == 1) { if (arguments.length == 1) {
var range = arguments[0]; var range = arguments[0];
animate = (range.animate !== undefined) ? range.animate : true;
this.range.setRange(range.start, range.end, animate); this.range.setRange(range.start, range.end, animate);
} }
else { else {
animate = (options && options.animate !== undefined) ? options.animate : true;
this.range.setRange(start, end, animate); this.range.setRange(start, end, animate);
} }
}; };

+ 1
- 1
dist/vis.map
File diff suppressed because it is too large
View File


+ 2
- 2
dist/vis.min.js
File diff suppressed because it is too large
View File


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

@ -398,6 +398,7 @@ Core.prototype._getDataRange = function() {
* start or only end. Syntax: * start or only end. Syntax:
* *
* TimeLine.setWindow(start, end) * TimeLine.setWindow(start, end)
* TimeLine.setWindow(start, end, options)
* TimeLine.setWindow(range) * TimeLine.setWindow(range)
* *
* Where start and end can be a Date, number, or string, and range is an * Where start and end can be a Date, number, or string, and range is an
@ -413,12 +414,14 @@ Core.prototype._getDataRange = function() {
* for the animation. Default duration is 500 ms. * for the animation. Default duration is 500 ms.
*/ */
Core.prototype.setWindow = function(start, end, options) { Core.prototype.setWindow = function(start, end, options) {
var animate = (options && options.animate !== undefined) ? options.animate : true;
var animate;
if (arguments.length == 1) { if (arguments.length == 1) {
var range = arguments[0]; var range = arguments[0];
animate = (range.animate !== undefined) ? range.animate : true;
this.range.setRange(range.start, range.end, animate); this.range.setRange(range.start, range.end, animate);
} }
else { else {
animate = (options && options.animate !== undefined) ? options.animate : true;
this.range.setRange(start, end, animate); this.range.setRange(start, end, animate);
} }
}; };

+ 5
- 4
lib/timeline/Range.js View File

@ -157,7 +157,7 @@ Range.prototype.setRange = function(start, end, animate, byUser) {
me.animateTimer = setTimeout(next, 20); me.animateTimer = setTimeout(next, 20);
} }
} }
}
};
return next(); return next();
} }
@ -251,7 +251,7 @@ Range.prototype._applyRange = function(start, end) {
zoomMin = 0; zoomMin = 0;
} }
if ((newEnd - newStart) < zoomMin) { if ((newEnd - newStart) < zoomMin) {
if ((this.end - this.start) === zoomMin) {
if ((this.end - this.start) === zoomMin && newStart > this.start && newEnd < this.end) {
// ignore this action, we are already zoomed to the minimum // ignore this action, we are already zoomed to the minimum
newStart = this.start; newStart = this.start;
newEnd = this.end; newEnd = this.end;
@ -271,8 +271,9 @@ Range.prototype._applyRange = function(start, end) {
if (zoomMax < 0) { if (zoomMax < 0) {
zoomMax = 0; zoomMax = 0;
} }
if ((newEnd - newStart) > zoomMax) { if ((newEnd - newStart) > zoomMax) {
if ((this.end - this.start) === zoomMax) {
if ((this.end - this.start) === zoomMax && newStart < this.start && newEnd > this.end) {
// ignore this action, we are already zoomed to the maximum // ignore this action, we are already zoomed to the maximum
newStart = this.start; newStart = this.start;
newEnd = this.end; newEnd = this.end;
@ -288,7 +289,7 @@ Range.prototype._applyRange = function(start, end) {
var changed = (this.start != newStart || this.end != newEnd); var changed = (this.start != newStart || this.end != newEnd);
// if the new range does NOT overlap with the old range, emit checkRangedItems to avoid not showing ranged items (ranged meaning has end time, not neccesarily of type Range)
// if the new range does NOT overlap with the old range, emit checkRangedItems to avoid not showing ranged items (ranged meaning has end time, not necessarily of type Range)
if (!((newStart >= this.start && newStart <= this.end) || (newEnd >= this.start && newEnd <= this.end)) && if (!((newStart >= this.start && newStart <= this.end) || (newEnd >= this.start && newEnd <= this.end)) &&
!((this.start >= newStart && this.start <= newEnd) || (this.end >= newStart && this.end <= newEnd) )) { !((this.start >= newStart && this.start <= newEnd) || (this.end >= newStart && this.end <= newEnd) )) {
this.body.emitter.emit('checkRangedItems'); this.body.emitter.emit('checkRangedItems');

Loading…
Cancel
Save