Skip to content

Commit fe31d2d

Browse files
author
Nathan Sobo
committed
Add scrolling benchmark to React editor
1 parent 71e8396 commit fe31d2d

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/editor-component.coffee

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ EditorComponent = React.createClass
262262
'editor:scroll-to-cursor': => editor.scrollToCursorPosition()
263263
'core:page-up': => editor.pageUp()
264264
'core:page-down': => editor.pageDown()
265+
'benchmark:scroll': @runScrollBenchmark
265266

266267
addCommandListeners: (listenersByCommandName) ->
267268
{parentView} = @props
@@ -476,3 +477,26 @@ EditorComponent = React.createClass
476477

477478
show: ->
478479
@setState(visible: true)
480+
481+
runScrollBenchmark: ->
482+
node = @getDOMNode()
483+
484+
scroll = (delta, done) ->
485+
dispatchMouseWheelEvent = ->
486+
node.dispatchEvent(new WheelEvent('mousewheel', wheelDeltaX: -0, wheelDeltaY: -delta))
487+
488+
stopScrolling = ->
489+
clearInterval(interval)
490+
done?()
491+
492+
interval = setInterval(dispatchMouseWheelEvent, 10)
493+
setTimeout(stopScrolling, 500)
494+
495+
console.timeline('scroll')
496+
scroll 50, ->
497+
scroll 100, ->
498+
scroll 200, ->
499+
scroll 400, ->
500+
scroll 800, ->
501+
scroll 1600, ->
502+
console.timelineEnd('scroll')

0 commit comments

Comments
 (0)