From cd6eb9b3510c1bac58d1b6c3d5b98b3d94a69a44 Mon Sep 17 00:00:00 2001 From: alfred-c Date: Tue, 13 Mar 2018 17:48:14 -0700 Subject: [PATCH] label/arrow position when data towards bottom RE: Issue #9 Arrows and description not displaying in correct position If data is towards the bottom of the screen, label should be on top, but existing code would cause label and arrow to overlap. To fix, I removed the following offending lines and cleaned up unused variables: if (top_offset < label_shift_with_label_height && bottom_offset < label_shift_with_label_height) { label_y = data.center_y + label_margin; } Not sure why these lines were needed. Please review this section as it looks like the result of a bad merge. --- enjoyhint.js | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/enjoyhint.js b/enjoyhint.js index e9d0893..8742b13 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -1239,33 +1239,17 @@ var EnjoyHint = function (_options) { var label_width = label.outerWidth(); var label_height = label.outerHeight(); label.remove(); - var top_offset = data.center_y - half_h; - var bottom_offset = body_size.h - (data.center_y + half_h); - var left_offset = data.center_x - half_w; - var right_offset = body_size.w - (data.center_x + half_w); - var label_hor_side = (body_size.w - data.center_x) < data.center_x ? 'left' : 'right'; + //var label_hor_side = (body_size.w - data.center_x) < data.center_x ? 'left' : 'right'; var label_ver_side = (body_size.h - data.center_y) < data.center_y ? 'top' : 'bottom'; var label_shift = 150; - var label_margin = 40; - var label_shift_with_label_width = label_shift + label_width + label_margin; - var label_shift_with_label_height = label_shift + label_height + label_margin; - var label_hor_offset = half_w + label_shift; + //var label_hor_offset = half_w + label_shift; var label_ver_offset = half_h + label_shift; //original: var label_x = (label_hor_side == 'left') ? data.center_x - label_hor_offset - label_width : data.center_x + label_hor_offset; var label_y = (label_ver_side == 'top') ? data.center_y - label_ver_offset - label_height : data.center_y + label_ver_offset; var label_x = window.innerWidth / 2 - label_width / 2; - if (top_offset < label_shift_with_label_height && bottom_offset < label_shift_with_label_height) { - - label_y = data.center_y + label_margin; - } - - if (window.innerWidth <= 640) { - - } - var label_data = that.renderLabel({ x: label_x, y: label_y, @@ -1573,4 +1557,4 @@ a.children=[];for(var b=this.getChildren(),c=b.length,d=0;c>d;d++){var e=b[d];a. * @author Ariel Flesler * @version 2.1.2 */ -;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1=f[g]?0:Math.min(f[g],n));!a&&1=f[g]?0:Math.min(f[g],n));!a&&1