this.appendChild(this.dragBox_);
this.hideDragBox_();
+ this.initHintText_();
+
this.bindEventListener_(document, 'keypress', this.onKeypress_, this);
this.bindEventListener_(document, 'keydown', this.onKeydown_, this);
this.bindEventListener_(document, 'keyup', this.onKeyup_, this);
if (!model)
throw new Error('Model cannot be null');
- var modelInstanceChanged = this.model_ != model;
+ var modelInstanceChanged = this.model_ !== model;
this.model_ = model;
this.modelTrack_.model = model;
},
setInitialViewport_: function() {
+ // We need the canvas size to be up-to-date at this point. We maybe in
+ // here before the raf fires, so the size may have not been updated since
+ // the canvas was resized.
+ this.modelTrackContainer_.updateCanvasSizeIfNeeded_();
var w = this.modelTrackContainer_.canvas.width;
var min;
if (this.model_.bounds.isEmpty) {
min = 0;
range = 1000;
- } else if (this.model_.bounds.range == 0) {
+ } else if (this.model_.bounds.range === 0) {
min = this.model_.bounds.min;
range = 1000;
} else {
min = this.model_.bounds.min;
range = this.model_.bounds.range;
}
+
var boost = range * 0.15;
tempDisplayTransform.set(this.viewport_.currentDisplayTransform);
tempDisplayTransform.xSetWorldBounds(min - boost,
return;
var worldCenter = bounds.center;
+ var viewCenter = this.modelTrackContainer_.canvas.width / 2;
var adjustedWorldRange = bounds.range * 1.25;
var newScale = this.modelTrackContainer_.canvas.width /
adjustedWorldRange;
var zoomInRatio = newScale / this.viewport_.currentDisplayTransform.scaleX;
var animation = new tracing.TimelineDisplayTransformZoomToAnimation(
- worldCenter, 'center',
+ worldCenter, viewCenter,
this.viewport_.currentDisplayTransform.panY,
zoomInRatio);
this.viewport_.queueDisplayTransformAnimation(animation);
this.selection_ = new Selection();
tvcm.dispatchSimpleEvent(this, 'selectionChange');
+ this.showHintText_('Press \'m\' to mark current selection');
if (this.selectionOfInterest.length) {
var track = this.viewport_.trackForEvent(this.selectionOfInterest[0]);
loVX, hiVX, loY, hiY, selection);
// Activate the new selection.
- this.setSelectionAndClearHighlight(selection);
+ var selection_change_event = new tracing.RequestSelectionChangeEvent();
+ selection_change_event.selection = selection;
+ this.dispatchEvent(selection_change_event);
},
onBeginZoom_: function(e) {
tempDisplayTransform.panY -= yDelta;
vp.setDisplayTransformImmediately(tempDisplayTransform);
this.storeLastTouchPositions_(e);
+ },
+
+ initHintText_: function() {
+ this.hintTextBox_ = this.ownerDocument.createElement('div');
+ this.hintTextBox_.className = 'hint-text';
+ this.hintTextBox_.style.display = 'none';
+ this.appendChild(this.hintTextBox_);
+
+ this.pendingHintTextClearTimeout_ = undefined;
+ },
+
+ showHintText_: function(text) {
+ if (this.pendingHintTextClearTimeout_) {
+ window.clearTimeout(this.pendingHintTextClearTimeout_);
+ this.pendingHintTextClearTimeout_ = undefined;
+ }
+ this.pendingHintTextClearTimeout_ = setTimeout(
+ this.hideHintText_.bind(this), 1000);
+ this.hintTextBox_.textContent = text;
+ this.hintTextBox_.style.display = '';
+ },
+
+ hideHintText_: function() {
+ this.pendingHintTextClearTimeout_ = undefined;
+ this.hintTextBox_.style.display = 'none';
}
};