From d5fecd0388be706d1b693232715c6db6bc5c3dc0 Mon Sep 17 00:00:00 2001 From: hide_d Date: Wed, 31 Jan 2018 10:59:11 +0900 Subject: [PATCH] =?UTF-8?q?=EC=83=88=20=EC=A7=80=EB=8F=84=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=ED=84=B0=EC=B9=98=EC=8A=A4=ED=81=AC=EB=A6=B0?= =?UTF-8?q?=EC=97=90=EC=84=9C=201=ED=84=B0=EC=B9=98=20->=20tooltip,=202?= =?UTF-8?q?=ED=84=B0=EC=B9=98=20->=20=ED=81=B4=EB=A6=AD=20=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=8F=99=EC=9E=91=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tmp_map/map.js | 59 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/tmp_map/map.js b/tmp_map/map.js index fb7cd447..b2a67b0c 100644 --- a/tmp_map/map.js +++ b/tmp_map/map.js @@ -159,7 +159,6 @@ function reloadWorldMap(isDetailMap, clickableAll, selectCallback, hrefTemplate) city.nation = nationObj.name; city.color = nationObj.color; city.isCapital = (nationObj.capital == city.id); - console.log(city.id, nationObj.capital, city.isCapital); return city; } @@ -268,24 +267,68 @@ function reloadWorldMap(isDetailMap, clickableAll, selectCallback, hrefTemplate) var $map_body = $('.world_map .map_body'); + $objs.bind('touchstart', function(e){ + var $this = $(this); + + var touchMode = $this.data('touchMode'); + if($tooltip_city.data('target') != $this.data('id')){ + $this.data('touchMode', 1); + } + else if(touchMode === undefined){ + $this.data('touchMode', 1); + } + else{ + $this.data('touchMode', touchMode + 1); + } - $map_body.mousemove(function(e){ + $tooltip_city.data('target', $this.data('id')) + + }); + + $map_body.bind('mousemove', function(e){ var parentOffset = $map_body.offset(); var relX = e.pageX - parentOffset.left; var relY = e.pageY - parentOffset.top; $tooltip.css({'top': relY + 10, 'left': relX + 10}); }); - $objs.hover(function(event){ - var $city = $(this); - $tooltip_city.html($city.data('text')); - $tooltip_nation.html($city.data('nation')); + $objs.bind('mouseenter touchend', function(e){ + var $this = $(this); + + $tooltip_city.html($this.data('text')); + $tooltip_nation.html($this.data('nation')); + $tooltip_city.data('target', $this.data('id')); $tooltip.show(); - },function(event){ + return false; + }); + + $map_body.bind('touchend',function(e){ + //위의 touchend bind에 해당하지 않는 경우 -> 빈 지도 터치 $tooltip.hide(); }); + $objs.bind('mouseleave', function(event){ + $tooltip.hide(); + }); + + $objs.bind('click', function(){ + //touch의 경우 첫 터치는 tooltip을 보여주고, 두번째는 클릭 + var $this = $(this); + var touchMode = $this.data('touchMode'); + + if(touchMode === undefined){ + return true; + } + + if(touchMode === 1){ + return false; + } + $this.data('touchMode', 1); + return true; + }); + + return obj; } @@ -337,7 +380,7 @@ $(function(){ function tmp(a){ console.log(a); - return false; + //return false; } reloadWorldMap(isDetailMap, clickableAll, tmp, 'goCity.php?id={0}');