From a12eee918c9e6e0b85af86585baba704640f4da0 Mon Sep 17 00:00:00 2001 From: Felix Niklas Date: Tue, 22 Mar 2016 07:57:35 +0100 Subject: [PATCH] online_notification: optimize height calculation --- .../controllers/widget/online_notification.coffee | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/app/controllers/widget/online_notification.coffee b/app/assets/javascripts/app/controllers/widget/online_notification.coffee index a60a73e7f..fc428513c 100644 --- a/app/assets/javascripts/app/controllers/widget/online_notification.coffee +++ b/app/assets/javascripts/app/controllers/widget/online_notification.coffee @@ -136,14 +136,17 @@ class App.OnlineNotificationWidget extends App.Controller heightPopoverSpacer = 22 heightPopoverHeader = @header.outerHeight(true) heightPopoverContent = 0 - @item.each -> heightPopoverContent += @clientHeight + isOverflowing = false + @item.each -> + # accumulate height of items + heightPopoverContent += @clientHeight - if (heightPopoverHeader + heightPopoverContent + heightPopoverSpacer) > heightApp - heightPopoverContent = heightApp - heightPopoverHeader - heightPopoverSpacer - @container.addClass('is-overflowing') - else - @container.removeClass('is-overflowing') + if (heightPopoverHeader + heightPopoverContent + heightPopoverSpacer) > heightApp + heightPopoverContent = heightApp - heightPopoverHeader - heightPopoverSpacer + isOverflowing = true + return false # exit .each loop + @container.toggleClass('is-overflowing', isOverflowing) @content.css('height', heightPopoverContent) fetch: =>