Don't let widgets in review panel overlap

This commit is contained in:
James Allen 2016-10-20 15:04:10 +01:00
parent 2b94c69795
commit 8f9a4882c8
3 changed files with 29 additions and 2 deletions

View file

@ -44,8 +44,8 @@ div.full-size(
)
#review-panel
.review-panel-scroller
.review-entry-list
.review-entry(ng-repeat="(entry_id, entry) in reviewPanel.entries", ng-style="{'top': entry.screenPos.y}")
.review-entry-list(review-panel-sorted)
.review-entry(ng-repeat="(entry_id, entry) in reviewPanel.entries", ng-style="{'top': top}")
{{ entry.content }}
.ui-layout-east

View file

@ -1,3 +1,4 @@
define [
"ide/review-panel/controllers/ReviewPanelController"
"ide/review-panel/directives/reviewPanelSorted"
], () ->

View file

@ -0,0 +1,26 @@
define [
"base"
], (App) ->
console.log "Defingint", "reviePanelSorted"
App.directive "reviewPanelSorted", () ->
return {
link: (scope, element, attrs) ->
scope.$watch "reviewPanel.entries", (value) ->
return if !value?
console.log "reviewPanel.entries updates", entries
entries = []
for el in element.find(".review-entry")
entries.push {
el: el
scope: angular.element(el).scope()
}
entries.sort (a,b) -> a.scope.entry.offset - b.scope.entry.offset
previousBottom = 0
for entry in entries
height = $(entry.el).height()
top = entry.scope.entry.screenPos.y
top = Math.max(top, previousBottom + 12)
previousBottom = top + height
entry.scope.top = top
}