From b527f9c600629a12948098184c96081db47655a4 Mon Sep 17 00:00:00 2001 From: Josef Citrine Date: Sun, 17 Jul 2016 13:17:09 +0100 Subject: [PATCH] Compensating for dynamic player height --- .../assets/scripts/app/controllers/application.coffee | 3 +-- resources/assets/scripts/shared/layout.coffee | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/resources/assets/scripts/app/controllers/application.coffee b/resources/assets/scripts/app/controllers/application.coffee index 9011b572..b8cfb67f 100644 --- a/resources/assets/scripts/app/controllers/application.coffee +++ b/resources/assets/scripts/app/controllers/application.coffee @@ -52,8 +52,7 @@ module.exports = angular.module('ponyfm').controller "application", [ $rootScope.$on 'player-starting-track', () -> $scope.isPlaying = true - windowHeight = $(window).height() - $('.site-body').height windowHeight - ($('.top-bar').height() + $('.now-playing').height()) + window.isPlaying = true $rootScope.$on 'player-stopping', () -> $scope.isPlaying = false diff --git a/resources/assets/scripts/shared/layout.coffee b/resources/assets/scripts/shared/layout.coffee index b1460f6d..3f561f39 100644 --- a/resources/assets/scripts/shared/layout.coffee +++ b/resources/assets/scripts/shared/layout.coffee @@ -14,13 +14,18 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +window.isPlaying = false + window.handleResize = () -> windowHeight = $(window).height() windowWidth = $(window).width() isMobile = windowWidth <= 480 $siteBody = $ '.site-body' - $siteBody.height windowHeight - $('.top-bar').height() + if window.isPlaying + $siteBody.height windowHeight - ($('.top-bar').height() + $('.now-playing').height()) + else + $siteBody.height windowHeight - $('.top-bar').height() $('.dropdown-menu').each () -> $this = $ this @@ -32,6 +37,8 @@ window.handleResize = () -> if !isMobile $this = $ this newHeight = windowHeight - $this.offset().top + if window.isPlaying + newHeight = newHeight - $('.now-playing').height() if newHeight > 0 $this.height newHeight