Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions app/public/js/common/queueCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,38 @@ app.controller('QueueCtrl', function(
$anchorScroll();
}

/**
* Dynamically change position of menu not to overlap fixed footer and header
* @param {object} $event - Angular event
*/
$scope.menuPosition = function ($event) {
var $hover = $($event.target);
var $menu = $hover.find('.queueListView_list_item_options_list');
var $arrow = $hover.find('.queueListView_list_item_options_arrow');

var menuHeight = $menu.height();
var arrowHeight = $arrow.outerHeight();
var headerHeight = $('.topFrame').outerHeight();
var footerHeight = $('.player_inner').outerHeight();
var hoverHeight = $hover.outerHeight();

// Calculate top and bottom edge position and compare it with current
var borderTop = headerHeight;
var borderBottom = window.innerHeight - footerHeight;
var hoverTop = $hover.offset().top;

// Arrow in the middle by default
var newTop = -menuHeight / 2 + arrowHeight / 2;

// If overlapping top border - move list to the bottom
if (hoverTop - menuHeight / 2 < borderTop) {
newTop = -arrowHeight;
// If overlapping bottom border - move list to the top
} else if (hoverTop + hoverHeight + menuHeight / 2 > borderBottom) {
newTop = -menuHeight + arrowHeight;
}

$menu.css({ top: newTop });
};

});
28 changes: 23 additions & 5 deletions app/public/stylesheets/sass/_components/_queueList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

.queueListView_list {
width: 100%;
// Keep some offset from the bottom not to mix last queue item
// with player progress bar on mouse over
padding-bottom: 15px;

& .queueListView_list_itemTitle {
text-align: center;
Expand Down Expand Up @@ -78,16 +81,19 @@
text-align: center;
height: 17px;

&.active .queueListView_list_item_options_list {
display: block;
&.active {
.queueListView_list_item_options_list,
.queueListView_list_item_options_arrow {
display: block;
}
}
}

.queueListView_list_item_options_list {
display: none;
position: absolute;
right: 0;
top: 17px;
right: 19px;
top: -11px;
background: $separatorCleanColor;
z-index: 10;
border-radius: 2px;
Expand All @@ -105,4 +111,16 @@
&:hover {
background: $separatorDarkColor;
}
}
}

.queueListView_list_item_options_arrow {
display: none;
position: absolute;
top: -3px;
right: 8px;
width: 0;
height: 0;
border-top: 12px solid transparent;
border-bottom: 10px solid transparent;
border-left: 12px solid #3E3E40;
}
5 changes: 3 additions & 2 deletions app/views/common/queueList.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
<span class="queueListView_list_item_user" title="by: {{ item.songUser }}">by: {{ item.songUser }} </span>
<div class="queueListView_list_item_options"
ng-class="{ active: hover }"
ng-mouseover="hover = true"
ng-mouseover="menuPosition($event); hover = true"
ng-mouseleave="hover = false" >
<i class="fa fa-ellipsis-v"></i>
<ul class="queueListView_list_item_options_list" >
<div class="queueListView_list_item_options_arrow"></div>
<ul class="queueListView_list_item_options_list">
<li class="queueListView_list_item_options_list_button" ng-click="remove($event); $event.stopPropagation();">Remove</li>
<li class="queueListView_list_item_options_list_button" ng-click="like($event); $event.stopPropagation();">Like</li>
<li class="queueListView_list_item_options_list_button" ng-click="repost($event); $event.stopPropagation();">Repost</li>
Expand Down