r100672 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100671‎ | r100672 | r100673 >
Date:01:02, 25 October 2011
Author:inez
Status:deferred
Tags:
Comment:
Proof of concept code (to be refactore) for auto-scrolling when selecting with mouse and it is below the window
Modified paths:
  • /trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js
@@ -185,14 +185,24 @@
186186 this.cursor.initialLeft = null;
187187 return false;
188188 };
189 -
 189+var lastEventPosition = new es.Position();
190190 es.SurfaceView.prototype.onMouseMove = function( e ) {
191191 if ( e.button === 0 /* left mouse button */ && this.mouse.selecting ) {
 192+
 193+ if ( e.pageY - $(window).scrollTop() <= window.innerHeight ) {
 194+ stopScrolling();
 195+ } else {
 196+ lastEventPosition = es.Position.newFromEventPagePosition( e );
 197+ stopScrolling();
 198+ startScrolling();
 199+ }
 200+
192201 this.hideCursor();
193202 this.selection.to = this.documentView.getOffsetFromEvent( e );
194203 if ( !this.drawSelection() ) {
195204 this.showCursor();
196205 }
 206+
197207 }
198208 };
199209
@@ -343,4 +353,28 @@
344354 } else {
345355 return false;
346356 }
347 -};
\ No newline at end of file
 357+};
 358+
 359+
 360+
 361+
 362+
 363+var scrollStep = function() {
 364+ lastEventPosition.top += 20;
 365+ lastEventPosition.bottom += 20;
 366+
 367+ fakelastEventPosition = new es.Position(lastEventPosition.left, lastEventPosition.top, lastEventPosition.bottom);
 368+
 369+ surfaceView.selection.to = surfaceView.documentView.getOffsetFromPosition( fakelastEventPosition );
 370+ surfaceView.drawSelection();
 371+
 372+ $(window).scrollTop( $(window).scrollTop() + 20 );
 373+};
 374+var scrollInterval = null;
 375+var startScrolling = function( interval ) {
 376+ scrollStep();
 377+ scrollInterval = setInterval(scrollStep, interval || 50);
 378+};
 379+var stopScrolling = function() {
 380+ clearInterval( scrollInterval );
 381+};

Status & tagging log