Merge pull request #1756 from overleaf/pr-resize-ace-when-toggling-pdf

Resize Ace when toggling PDF view

GitOrigin-RevId: 77e6fe662eb67f2ec39a00f42a35026f6a696eb9
This commit is contained in:
Alasdair Smith 2019-05-10 09:46:39 +01:00 committed by sharelatex
parent 51a4c33e91
commit dc09095ae7
3 changed files with 16 additions and 12 deletions

View file

@ -56,7 +56,7 @@ div.full-size(
last-updated="editor.last_updated",
cursor-position="editor.cursorPosition",
goto-line="editor.gotoLine",
resize-on="layout:main:resize,layout:pdf:resize,layout:review:resize,review-panel:toggle",
resize-on="layout:main:resize,layout:pdf:resize,layout:review:resize,review-panel:toggle,layout:flat-screen:toggle",
annotations="pdf.logEntryAnnotations[editor.open_doc_id]",
read-only="!permissions.write",
file-name="editor.open_doc_name",

View file

@ -158,8 +158,10 @@ define([
return ($scope.ui.pdfWidth = layoutState.east.size)
})
// Tracking code.
$scope.$watch('ui.view', function(newView, oldView) {
if (newView !== oldView) {
$scope.$broadcast('layout:flat-screen:toggle')
}
if (newView != null && newView !== 'editor' && newView !== 'pdf') {
return event_tracking.sendMBOnce(`ide-open-view-${newView}-once`)
}

View file

@ -390,16 +390,18 @@ define([
if (attrs.resizeOn != null) {
for (let event of Array.from(attrs.resizeOn.split(','))) {
scope.$on(event, function() {
const previousScreenPosition = getCursorScreenPosition()
editor.resize()
// Put cursor back to same vertical position on screen
const newScreenPosition = getCursorScreenPosition()
const session = editor.getSession()
return session.setScrollTop(
session.getScrollTop() +
newScreenPosition -
previousScreenPosition
)
scope.$applyAsync(() => {
const previousScreenPosition = getCursorScreenPosition()
editor.resize()
// Put cursor back to same vertical position on screen
const newScreenPosition = getCursorScreenPosition()
const session = editor.getSession()
return session.setScrollTop(
session.getScrollTop() +
newScreenPosition -
previousScreenPosition
)
})
})
}
}