mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Reset scroll margins when changing document
This commit is contained in:
@@ -187,20 +187,25 @@ define [
|
||||
scope.$on "#{scope.name}:set-scroll-size", (e, size) ->
|
||||
# Make sure that the editor has enough scroll margin above and below
|
||||
# to scroll the review panel with the given size
|
||||
marginChanged = false
|
||||
if editor.renderer.scrollMargin.top != size.overflowTop
|
||||
window.editors[0].renderer.scrollMargin.top = size.overflowTop
|
||||
marginChanged = true
|
||||
|
||||
marginTop = size.overflowTop
|
||||
maxHeight = editor.renderer.layerConfig.maxHeight
|
||||
marginBottom = Math.max(size.height - maxHeight, 0)
|
||||
setScrollMargins(marginTop, marginBottom)
|
||||
|
||||
setScrollMargins = (marginTop, marginBottom) ->
|
||||
marginChanged = false
|
||||
if editor.renderer.scrollMargin.top != marginTop
|
||||
editor.renderer.scrollMargin.top = marginTop
|
||||
marginChanged = true
|
||||
if editor.renderer.scrollMargin.bottom != marginBottom
|
||||
editor.renderer.scrollMargin.bottom = marginBottom
|
||||
marginChanged = true
|
||||
|
||||
if marginChanged
|
||||
editor.renderer.updateFull()
|
||||
|
||||
resetScrollMargins = () ->
|
||||
setScrollMargins(0,0)
|
||||
|
||||
scope.$watch "theme", (value) ->
|
||||
editor.setTheme("ace/theme/#{value}")
|
||||
|
||||
@@ -325,6 +330,8 @@ define [
|
||||
sharejs_doc.attachToAce(editor)
|
||||
editor.initing = false
|
||||
|
||||
resetScrollMargins()
|
||||
|
||||
# need to set annotations after attaching because attaching
|
||||
# deletes and then inserts document content
|
||||
session.setAnnotations scope.annotations
|
||||
|
||||
Reference in New Issue
Block a user