Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeline autoPan implemented #897

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion Source/Widgets/Timeline/Timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ define([
this._timeBarSecondsSpan = undefined;
this._clock = clock;
this._scrubJulian = clock.currentTime;
this._lastJulian = clock.currentTime;
this._autoPan = 0;
this._mainTicSpan = -1;
this._mouseMode = timelineMouseMode.none;
this._touchMode = timelineTouchMode.none;
Expand Down Expand Up @@ -484,8 +486,41 @@ define([
this._scrubJulian = this._clock.currentTime;
var scrubElement = this._scrubElement;
if (typeof this._scrubElement !== 'undefined') {
var width = this._topDiv.clientWidth;
var seconds = this._startJulian.getSecondsDifference(this._scrubJulian);
var xPos = Math.round(seconds * this._topDiv.clientWidth / this._timeBarSecondsSpan);
var xPos = Math.round(seconds * width / this._timeBarSecondsSpan);
var drift = 2 * this._lastJulian.getSecondsDifference(this._scrubJulian);
var leftMargin = width / 6;
var rightMargin = 5 * width / 6;

if (this._lastXPos < 0 || this._lastXPos > width) {
seconds = this._startJulian.getSecondsDifference(this._scrubJulian);
this.zoomTo(this._startJulian.addSeconds(seconds), this._endJulian.addSeconds(seconds));
}

if ((this._lastXPos < leftMargin && this._autoPan === 1) || (this._lastXPos > rightMargin && this._autoPan === -1)) {
this._autoPan = 0;
} else if ((this._autoPan === -1 && this._clock.multiplier > 0) || (this._autoPan === 1 && this._clock.multiplier < 0)) {
this._autoPan = 0;
} else if (this._clock.shouldAnimate === true) {
if (xPos < leftMargin && this._clock.multiplier < 0) {
this._autoPan = -1;
} else if (xPos > rightMargin && this._clock.multiplier > 0) {
this._autoPan = 1;
}
} else {
this._autoPan = 0;
}

if (this._autoPan !== 0) {
if ((this._lastXPos > 3 * width / 8) && (this._lastXPos < 5 * width / 8 )) {
drift /= 2;
}
this.zoomTo(this._startJulian.addSeconds(drift), this._endJulian.addSeconds(drift));
seconds = this._startJulian.getSecondsDifference(this._scrubJulian);
xPos = Math.round(seconds * width / this._timeBarSecondsSpan);
}
this._lastJulian = this._clock.currentTime;

if (this._lastXPos !== xPos) {
this._lastXPos = xPos;
Expand Down