From 907b490747b489bdd4a570c13a51444f6eda4a5a Mon Sep 17 00:00:00 2001 From: hide_d Date: Wed, 31 Jan 2018 11:49:36 +0900 Subject: [PATCH] =?UTF-8?q?=EC=83=88=20=EC=A7=80=EB=8F=84=20=ED=84=B0?= =?UTF-8?q?=EC=B9=98=EC=8A=A4=ED=81=AC=EB=A6=B0=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tmp_map/map.js | 64 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/tmp_map/map.js b/tmp_map/map.js index b2a67b0c..c54759cc 100644 --- a/tmp_map/map.js +++ b/tmp_map/map.js @@ -267,7 +267,10 @@ function reloadWorldMap(isDetailMap, clickableAll, selectCallback, hrefTemplate) var $map_body = $('.world_map .map_body'); + //터치스크린 탭 + $objs.bind('touchstart', function(e){ + console.log('touchstart'); var $this = $(this); var touchMode = $this.data('touchMode'); @@ -280,26 +283,21 @@ function reloadWorldMap(isDetailMap, clickableAll, selectCallback, hrefTemplate) else{ $this.data('touchMode', touchMode + 1); } + $map_body.data('touchMode', 1); - $tooltip_city.data('target', $this.data('id')) + $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.bind('mouseenter touchend', function(e){ + + $objs.bind('touchend', function(e){ + console.log('touchend'); var $this = $(this); - + var position = $this.parent().position(); + console.log(position); $tooltip_city.html($this.data('text')); $tooltip_nation.html($this.data('nation')); - $tooltip_city.data('target', $this.data('id')); - $tooltip.show(); + $tooltip.css({'top': position.top + 25, 'left': position.left + 35}).show(); return false; }); @@ -308,10 +306,6 @@ function reloadWorldMap(isDetailMap, clickableAll, selectCallback, hrefTemplate) $tooltip.hide(); }); - $objs.bind('mouseleave', function(event){ - $tooltip.hide(); - }); - $objs.bind('click', function(){ //touch의 경우 첫 터치는 tooltip을 보여주고, 두번째는 클릭 var $this = $(this); @@ -328,6 +322,40 @@ function reloadWorldMap(isDetailMap, clickableAll, selectCallback, hrefTemplate) return true; }); + //Mouse over 모드 작동 + + $map_body.bind('mousemove', function(e){ + if($(this).data('touchMode')){ + return true; + } + + 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.bind('mouseenter', function(e){ + console.log('mouseenter'); + var $this = $(this); + //mouseenter는 터치에서는 없는 마우스 고유 기능임. + $this.removeData('touchMode'); + $map_body.removeData('touchMode'); + + $tooltip_city.data('target', $this.data('id')); + $tooltip_city.html($this.data('text')); + $tooltip_nation.html($this.data('nation')); + + $tooltip.show(); + }); + + $objs.bind('mouseleave', function(event){ + $tooltip.hide(); + }); + + + return obj; }