mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-28 01:01:39 +00:00
Scroll to selected history update when coming back from the labels view.
This commit is contained in:
parent
663ca275cb
commit
6b31268bfa
2 changed files with 20 additions and 0 deletions
|
@ -3,6 +3,22 @@ define [
|
||||||
], (App) ->
|
], (App) ->
|
||||||
historyEntriesListController = ($scope, $element, $attrs) ->
|
historyEntriesListController = ($scope, $element, $attrs) ->
|
||||||
ctrl = @
|
ctrl = @
|
||||||
|
ctrl.$entryListViewportEl = null
|
||||||
|
_isEntryElVisible = ($entryEl) ->
|
||||||
|
entryElTop = $entryEl.offset().top
|
||||||
|
entryElBottom = entryElTop + $entryEl.outerHeight()
|
||||||
|
entryListViewportElTop = ctrl.$entryListViewportEl.offset().top
|
||||||
|
entryListViewportElBottom = entryListViewportElTop + ctrl.$entryListViewportEl.height()
|
||||||
|
return entryElTop >= entryListViewportElTop and entryElBottom <= entryListViewportElBottom;
|
||||||
|
_getScrollTopPosForEntry = ($entryEl) ->
|
||||||
|
halfViewportElHeight = ctrl.$entryListViewportEl.height() / 2
|
||||||
|
return $entryEl.offset().top - halfViewportElHeight
|
||||||
|
ctrl.onEntryLinked = (entry, $entryEl) ->
|
||||||
|
if entry.selectedTo and entry.selectedFrom and !_isEntryElVisible $entryEl
|
||||||
|
$scope.$applyAsync () ->
|
||||||
|
ctrl.$entryListViewportEl.scrollTop _getScrollTopPosForEntry $entryEl
|
||||||
|
ctrl.$onInit = () ->
|
||||||
|
ctrl.$entryListViewportEl = $element.find "> .history-entries"
|
||||||
return
|
return
|
||||||
|
|
||||||
App.component "historyEntriesList", {
|
App.component "historyEntriesList", {
|
||||||
|
|
|
@ -26,6 +26,8 @@ define [
|
||||||
color : "#FFF"
|
color : "#FFF"
|
||||||
else
|
else
|
||||||
color: "hsl(#{ hue }, 70%, 50%)"
|
color: "hsl(#{ hue }, 70%, 50%)"
|
||||||
|
ctrl.$onInit = () ->
|
||||||
|
ctrl.historyEntriesList.onEntryLinked ctrl.entry, $element.find "> .history-entry"
|
||||||
return
|
return
|
||||||
|
|
||||||
App.component "historyEntry", {
|
App.component "historyEntry", {
|
||||||
|
@ -35,6 +37,8 @@ define [
|
||||||
users: "<"
|
users: "<"
|
||||||
onSelect: "&"
|
onSelect: "&"
|
||||||
onLabelDelete: "&"
|
onLabelDelete: "&"
|
||||||
|
require:
|
||||||
|
historyEntriesList: '^historyEntriesList'
|
||||||
controller: historyEntryController
|
controller: historyEntryController
|
||||||
templateUrl: "historyEntryTpl"
|
templateUrl: "historyEntryTpl"
|
||||||
}
|
}
|
Loading…
Reference in a new issue