Update context menu on scroll and resize

This commit is contained in:
Trevor Parscal 2011-12-01 22:50:55 +00:00
parent 1db55a8242
commit 00d62c5ebd
2 changed files with 7 additions and 12 deletions

View file

@ -63,12 +63,6 @@ es.ContextView = function( surfaceView, $overlay ) {
/* Methods */
es.ContextView.prototype.update = function() {
if ( this.$icon.is( ':visible' ) ) {
this.set();
}
};
es.ContextView.prototype.set = function() {
this.$.removeClass(

View file

@ -129,6 +129,11 @@ es.SurfaceView = function( $container, model ) {
} );
$window.scroll( function() {
_this.dimensions.scrollTop = $window.scrollTop();
if ( _this.currentSelection.from !== _this.currentSelection.to ) {
_this.contextView.set();
} else {
_this.contextView.clear();
}
} );
// Configuration
@ -187,11 +192,11 @@ es.SurfaceView.prototype.updateSelection = function( delay ) {
_this.clearInsertionAnnotations();
_this.hideCursor();
_this.documentView.drawSelection( _this.currentSelection );
// Update the context icon position
_this.contextView.update();
_this.contextView.set();
} else {
_this.showCursor();
_this.documentView.clearSelection( _this.currentSelection );
_this.contextView.clear();
}
_this.updateSelectionTimeout = undefined;
}
@ -270,8 +275,6 @@ es.SurfaceView.prototype.onMouseDown = function( e ) {
this.cursor.initialLeft = null;
// Apply new selection
this.model.select( selection );
// Hide the context
this.contextView.clear();
}
// If the inut isn't already focused, focus it and select it's contents
if ( !this.$input.is( ':focus' ) ) {
@ -332,8 +335,6 @@ es.SurfaceView.prototype.onMouseUp = function( e ) {
if ( e.button === 0 ) { // left mouse button
this.mouse.selectingMode = this.mouse.selectedRange = null;
this.model.select( this.currentSelection );
// Show the context
this.contextView.set();
}
};