Index: trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js |
— | — | @@ -185,14 +185,24 @@ |
186 | 186 | this.cursor.initialLeft = null; |
187 | 187 | return false; |
188 | 188 | }; |
189 | | - |
| 189 | +var lastEventPosition = new es.Position(); |
190 | 190 | es.SurfaceView.prototype.onMouseMove = function( e ) { |
191 | 191 | 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 | + |
192 | 201 | this.hideCursor(); |
193 | 202 | this.selection.to = this.documentView.getOffsetFromEvent( e ); |
194 | 203 | if ( !this.drawSelection() ) { |
195 | 204 | this.showCursor(); |
196 | 205 | } |
| 206 | + |
197 | 207 | } |
198 | 208 | }; |
199 | 209 | |
— | — | @@ -343,4 +353,28 @@ |
344 | 354 | } else { |
345 | 355 | return false; |
346 | 356 | } |
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 | +}; |