swipe 플러그인 touchSipe 로 변경

This commit is contained in:
chicpro
2013-10-21 14:48:11 +09:00
parent 1d9953a588
commit cb130df525
5 changed files with 94 additions and 133 deletions

1
js/jquery.touchSwipe.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,10 +0,0 @@
/**
* jQuery Plugin to obtain touch gestures from iPhone, iPod Touch and iPad, should also work with Android mobile phones (not tested yet!)
* Common usage: wipe images (left and right to show the previous or next image)
*
* @author Andreas Waltl, netCU Internetagentur (http://www.netcu.de)
* @version 1.1.1 (9th December 2010) - fix bug (older IE's had problems)
* @version 1.1 (1st September 2010) - support wipe up and wipe down
* @version 1.0 (15th July 2010)
*/
(function($){$.fn.touchwipe=function(settings){var config={min_move_x:20,min_move_y:20,wipeLeft:function(){},wipeRight:function(){},wipeUp:function(){},wipeDown:function(){},preventDefaultEvents:true};if(settings)$.extend(config,settings);this.each(function(){var startX;var startY;var isMoving=false;function cancelTouch(){this.removeEventListener('touchmove',onTouchMove);startX=null;isMoving=false}function onTouchMove(e){if(config.preventDefaultEvents){e.preventDefault()}if(isMoving){var x=e.touches[0].pageX;var y=e.touches[0].pageY;var dx=startX-x;var dy=startY-y;if(Math.abs(dx)>=config.min_move_x){cancelTouch();if(dx>0){config.wipeLeft()}else{config.wipeRight()}}else if(Math.abs(dy)>=config.min_move_y){cancelTouch();if(dy>0){config.wipeDown()}else{config.wipeUp()}}}}function onTouchStart(e){if(e.touches.length==1){startX=e.touches[0].pageX;startY=e.touches[0].pageY;isMoving=true;this.addEventListener('touchmove',onTouchMove,false)}}if('ontouchstart'in document.documentElement){this.addEventListener('touchstart',onTouchStart,false)}});return this}})(jQuery);

View File

@ -117,8 +117,6 @@
if(check_animated())
return;
$(window).on("touchmove", blockMove);
idx = $slides.index($slides.filter("."+cfg.active_class));
next = (idx + 1) % count;
@ -151,8 +149,6 @@
$tabs.eq((next + 1) % count).addClass("tab_listed").css("left", pos_right+"px");
}
$(window).off("touchmove", blockMove);
$wrap.height(next_height);
$tabs.eq(next).addClass(cfg.tab_active);
}
@ -170,8 +166,6 @@
if(check_animated())
return;
$(window).on("touchmove", blockMove);
idx = $slides.index($slides.filter("."+cfg.active_class));
next = idx - 1;
if(next < 0)
@ -206,8 +200,6 @@
$tabs.eq((next + 1) % count).addClass("tab_listed").css("left", pos_right+"px");
}
$(window).off("touchmove", blockMove);
$wrap.height(next_height);
$tabs.eq(next).addClass(cfg.tab_active);
}
@ -244,11 +236,6 @@
swipe_left();
}
function blockMove(event)
{
event.preventDefault();
}
$(window).on("load", function(e) {
swipe_init();
});
@ -259,12 +246,20 @@
// swipe event
$(window).touchwipe({
wipeLeft: function() { swipe_left(); },
wipeRight: function() { swipe_right(); },
min_move_x: 20,
min_move_y: 20,
preventDefaultEvents: false
this.swipe({
swipe: function(event, direction, duration, fingerCount) {
switch(direction) {
case "left":
swipe_left();
break;
case "right":
swipe_right();
break;
}
},
threshold: 50,
excludedElements:".noSwipe",
allowPageScroll:"vertical"
});
}
}(jQuery));

View File

@ -6,8 +6,8 @@ define("_INDEX_", TRUE);
include_once(G5_MSHOP_PATH.'/shop.head.php');
?>
<script src="<?php echo G5_JS_URL; ?>/jquery.touchwipe.min.js"></script>
<script src="<?php echo G5_JS_URL; ?>/jquery.slideview.js"></script>
<script src="<?php echo G5_JS_URL; ?>/jquery.touchSwipe.min.js"></script>
<script src="<?php echo G5_JS_URL; ?>/shop.mobile.main.js"></script>
<div id="sidx">

View File

@ -3,7 +3,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
?>
<link rel="stylesheet" href="<?php echo G5_MSHOP_SKIN_URL; ?>/style.css">
<script src="<?php echo G5_JS_URL; ?>/jquery.touchwipe.min.js"></script>
<script src="<?php echo G5_JS_URL; ?>/jquery.touchSwipe.min.js"></script>
<form name="fitem" action="<?php echo $action_url; ?>" method="post" onsubmit="return fitem_submit(this);">
<input type="hidden" name="it_id[]" value="<?php echo $it['it_id']; ?>">
@ -384,111 +384,86 @@ $(function(){
});
// 이전 다음상품 swipe
$(window).touchwipe({
wipeLeft: function() {
<?php if($next_href) { ?>
if($("#loading_message").length > 0)
return;
var content = $("#container").clone()
.find("#form_btn_layer").remove()
.end().find(".sit_pvi_btn").remove()
.end().html();
var pos = $("#container").position();
var width = $("#container").width();
var height = $("#container").height();
var pad_top = $("#container").css("padding-top");
var duration = 500;
// 로딩 레이어
load_message();
$("#container")
.css({
width: width+"px",
height: height+"px"
})
.before("<div id=\"container_clone\">"+content+"</div>")
.find("*:visible").hide();
$("#container_clone")
.css({
display: "block",
width: width+"px",
height: height+"px",
position: "absolute",
top: pos.top+"px",
left: pos.left+"px",
paddingTop: pad_top
})
.animate(
{ left: "-="+width+"px" }, duration,
function() {
$("#container_clone").remove();
var str = '<?php echo $next_href; ?>';
var href = str.match(/https?:\/{2}[^\"]+/gi);
document.location.href = href[0];
}
);
<?php } else { ?>
alert("다음 상품이 없습니다.");
<?php } ?>
$("#container").swipe({
swipe: function(event, direction) {
switch(direction) {
case "left":
<?php if($next_href) { ?>
content_move(direction);
<?php } else { ?>
alert("다음 상품이 없습니다.");
<?php } ?>
break;
case "right":
<?php if($prev_href) { ?>
content_move(direction);
<?php } else { ?>
alert("이전 상품이 없습니다.");
<?php } ?>
break;
}
},
wipeRight: function() {
<?php if($prev_href) { ?>
if($("#loading_message").length > 0)
return;
var content = $("#container").clone()
.find("#form_btn_layer").remove()
.end().find(".sit_pvi_btn").remove()
.end().html();
var pos = $("#container").position();
var width = $("#container").width();
var height = $("#container").height();
var pad_top = $("#container").css("padding-top");
var duration = 500;
// 로딩 레이어
load_message();
$("#container")
.css({
width: width+"px",
height: height+"px"
})
.before("<div id=\"container_clone\">"+content+"</div>")
.find("*:visible").hide();
$("#container_clone")
.css({
display: "block",
width: width+"px",
height: height+"px",
position: "absolute",
top: pos.top+"px",
left: pos.left+"px",
zIndex: "1000",
paddingTop: pad_top
})
.animate(
{ left: "+="+width+"px" }, duration,
function() {
$("#container_clone").remove();
var str = '<?php echo $prev_href; ?>';
var href = str.match(/https?:\/{2}[^\"]+/gi);
document.location.href = href[0];
}
);
<?php } else { ?>
alert("이전 상품이 없습니다.");
<?php } ?>
},
min_move_x: 50,
preventDefaultEvents: false
threshold: 50,
excludedElements:".noSwipe",
allowPageScroll:"vertical"
});
});
function content_move(direction)
{
var content = $("#container").clone()
.find("#form_btn_layer").remove()
.end().find(".sit_pvi_btn").remove()
.end().html();
var pos = $("#container").position();
var width = $("#container").width();
var height = $("#container").height();
var pad_top = $("#container").css("padding-top");
var next_href = '<?php echo $next_href; ?>';
var prev_href = '<?php echo $prev_href; ?>';
var str, left_value;
var duration = 500;
if(direction == "left") {
str = next_href;
left_value = "-="+width+"px";
} else {
str = prev_href;
left_value = "+="+width+"px";
}
// 로딩 레이어
load_message();
$("#container")
.css({
width: width+"px",
height: height+"px"
})
.before("<div id=\"container_clone\">"+content+"</div>")
.find("*:visible").hide();
$("#container_clone")
.css({
display: "block",
width: width+"px",
height: height+"px",
position: "absolute",
top: pos.top+"px",
left: pos.left+"px",
zIndex: "1000",
paddingTop: pad_top
})
.animate(
{ left: left_value }, duration,
function() {
$("#container_clone").remove();
var href = str.match(/https?:\/{2}[^\"]+/gi);
document.location.href = href[0];
}
);
}
function load_message()
{
var w = $(window).width();