mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
43 lines
1.2 KiB
CoffeeScript
43 lines
1.2 KiB
CoffeeScript
|
define [
|
||
|
"base",
|
||
|
"utils/EventEmitter"
|
||
|
], (App, EventEmitter) ->
|
||
|
App.controller "ReviewPanelController", ($scope, $element) ->
|
||
|
$scope.reviewPanel =
|
||
|
entries: {}
|
||
|
|
||
|
scroller = $element.find(".review-panel-scroller")
|
||
|
list = $element.find(".review-entry-list")
|
||
|
|
||
|
ignoreNextPanelEvent = false
|
||
|
ignoreNextAceEvent = false
|
||
|
|
||
|
$scope.onScroll = (scrollTop, height) ->
|
||
|
if ignoreNextAceEvent
|
||
|
# console.log "Ignoring ace event"
|
||
|
ignoreNextAceEvent = false
|
||
|
else
|
||
|
ignoreNextPanelEvent = true
|
||
|
list.height(height)
|
||
|
scroller.scrollTop(scrollTop)
|
||
|
|
||
|
$scope.scrollEvents = new EventEmitter()
|
||
|
|
||
|
scrollAce = (e) ->
|
||
|
now = new Date()
|
||
|
if ignoreNextPanelEvent
|
||
|
# console.log "Ignoring review panel event"
|
||
|
ignoreNextPanelEvent = false
|
||
|
else
|
||
|
# console.log "review panel scrolled", e
|
||
|
ignoreNextAceEvent = true
|
||
|
$scope.scrollEvents.emit "scroll", e.target.scrollTop
|
||
|
lastScroll = now
|
||
|
|
||
|
previousScroll = new Date()
|
||
|
scroller.on "scroll", scrollAce
|
||
|
ace.require("ace/lib/event").addMouseWheelListener scroller[0], (e) ->
|
||
|
deltaY = e.wheelY
|
||
|
# console.log "mousewheel", deltaY
|
||
|
scroller.scrollTop(scroller.scrollTop() + deltaY * 4)
|
||
|
e.preventDefault()
|