Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #11 from austinmoffa/master
Browse files Browse the repository at this point in the history
Fixing tooltip behavior for layer view
  • Loading branch information
ryanbharvey committed Mar 4, 2016
2 parents 455c10d + 350bab3 commit 96fdd23
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion assets/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,11 @@ function addPopupActionsToLayersControlLayerTitles(data_obj, map_params) {
var selector = 'div#' + slug + '-description-tooltip.layer-description-tooltip';
//var layerControlLabelSelector = 'label#' + slug + "-layer-control-label";
//console.log("Showing: " + selector);
$(selector).show();
$(selector).show(1, function() {
if (!$(selector).data('height-adjusted')) {
adjustLayerTooltipDisplay($(selector));
}
});
//console.log("Label: " + $(layerControlLabelSelector)[0].outerHTML + "\n"
// + " | CSS top: " + $(layerControlLabelSelector).css("top")
// + " | $().offset().top: " + $(layerControlLabelSelector).offset().top
Expand Down Expand Up @@ -803,6 +807,22 @@ function createDescriptionTooltip(dataset, p) {
return tooltip;
}

function adjustLayerTooltipDisplay(el) {
if (tooltipIsNearTheBottomEdge(el)) {
el.css('top', (-el.height() - parseInt(el.css('top'))) + 'px');
el.data('height-adjusted', true);
}
}

function tooltipIsNearTheBottomEdge(el) {
var w_height = $(window).height();
var el_offset = el.offset();
if (el_offset.top + el.height() > w_height) {
return true;
}
return false;
}

/********************************
* Layer management functions
*/
Expand Down

0 comments on commit 96fdd23

Please sign in to comment.