overleaf/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee

43 lines
1.2 KiB
CoffeeScript
Raw Normal View History

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()