online_notification: optimize height calculation
This commit is contained in:
parent
8685bdb42a
commit
a12eee918c
1 changed files with 9 additions and 6 deletions
|
@ -136,14 +136,17 @@ class App.OnlineNotificationWidget extends App.Controller
|
||||||
heightPopoverSpacer = 22
|
heightPopoverSpacer = 22
|
||||||
heightPopoverHeader = @header.outerHeight(true)
|
heightPopoverHeader = @header.outerHeight(true)
|
||||||
heightPopoverContent = 0
|
heightPopoverContent = 0
|
||||||
@item.each -> heightPopoverContent += @clientHeight
|
isOverflowing = false
|
||||||
|
@item.each ->
|
||||||
|
# accumulate height of items
|
||||||
|
heightPopoverContent += @clientHeight
|
||||||
|
|
||||||
if (heightPopoverHeader + heightPopoverContent + heightPopoverSpacer) > heightApp
|
if (heightPopoverHeader + heightPopoverContent + heightPopoverSpacer) > heightApp
|
||||||
heightPopoverContent = heightApp - heightPopoverHeader - heightPopoverSpacer
|
heightPopoverContent = heightApp - heightPopoverHeader - heightPopoverSpacer
|
||||||
@container.addClass('is-overflowing')
|
isOverflowing = true
|
||||||
else
|
return false # exit .each loop
|
||||||
@container.removeClass('is-overflowing')
|
|
||||||
|
|
||||||
|
@container.toggleClass('is-overflowing', isOverflowing)
|
||||||
@content.css('height', heightPopoverContent)
|
@content.css('height', heightPopoverContent)
|
||||||
|
|
||||||
fetch: =>
|
fetch: =>
|
||||||
|
|
Loading…
Reference in a new issue