All pastes #2092320 Raw Edit

Unnamed

public javascript v1 · immutable
#2092320 ·published 2011-10-21 19:57 UTC
rendered paste body
es.SurfaceView.prototype.moveCursor = function( direction ) {	if ( direction === 'left' ) {		this.showCursor( this.cursor.offset - 1 );	} else if ( direction === 'right' ) {		this.showCursor( this.cursor.offset + 1 );	} else if ( direction === 'up' || direction === 'down' ) {		var currentPosition = this.documentView.getRenderedPosition( this.cursor.offset );		if ( this.cursor.initialLeft === null ) {			this.cursor.initialLeft = currentPosition.left;		}		var	fakePosition = new es.Position( this.cursor.initialLeft, currentPosition.top ),			edgeCondition = ( direction == 'up' ) ? 0 : this.documentView.getLength(),			offset,			i = 1;		do {			if ( direction == 'up' ) {				fakePosition.top -= i++ * 10;			} else {				fakePosition.top += i++ * 10;			}			offset = this.documentView.getOffsetFromPosition( fakePosition );			fakePosition = this.documentView.getRenderedPosition( offset );		} while ( currentPosition.top === fakePosition.top && offset !== edgeCondition )		fakePosition.left = this.cursor.initialLeft;		this.showCursor( this.documentView.getOffsetFromPosition( fakePosition ) );	}	return;};