mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
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:
parent
51a4c33e91
commit
dc09095ae7
3 changed files with 16 additions and 12 deletions
|
@ -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",
|
||||
|
|
|
@ -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`)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue