2012-01-26 2 views
3

나는 웹 사이트에서 일하고있는 jquery 플러그인을 가지고 있으며 간단한 질문이 있습니다 ... "슬라이드를 잠금 해제하는"플러그인으로 iPhone처럼 보입니다 사전에슬라이드 잠금 해제 후 링크 활성화 ... jquery

$(function() { 

$("#slider").draggable({ 
    axis: 'x', 
    containment: 'parent', 
    drag: function(event, ui) { 
     if (ui.position.left > 550) { 
      $("#well").fadeOut(); 
     } else { 
      // Apparently Safari isn't allowing partial opacity on text with background clip? Not sure. 
      // $("h2 span").css("opacity", 100 - (ui.position.left/5)) 
     } 
    }, 
    stop: function(event, ui) { 
     if (ui.position.left < 551) { 
      $(this).animate({ 
       left: 0 
      }) 
     } 
    } 
}); 

$('#slider')[0].addEventListener('touchmove', function(event) { 
    event.preventDefault(); 
    var el = event.target; 
    var touch = event.touches[0]; 
    curX = touch.pageX - this.offsetLeft - 73; 
    if(curX <= 0) return; 
    if(curX > 550){ 
     $('#well').fadeOut(); 
    } 
    el.style.webkitTransform = 'translateX(' + curX + 'px)'; 
}, false); 

$('#slider')[0].addEventListener('touchend', function(event) { 
    this.style.webkitTransition = '-webkit-transform 0.3s ease-in'; 
    this.addEventListener('webkitTransitionEnd', function(event) { this.style.webkitTransition = 'none'; }, false); 
    this.style.webkitTransform = 'translateX(0px)'; 
}, false); 

}); 

덕분에 ... 나는 사람들이 슬라이드 완료시 링크로 전달 후 잠금 해제 버튼을 밀어 수 얼마나 궁금 해서요 ... 여기에 내가 함께 일하고 있어요 소스 코드의 도움, 나는 꽤 자바 스크립트 전문가가 아니에요하지만 난 그게 $("#well").fadeOut(); 후 일이 필요하다고 생각?

답변

1

당신은 당신이 링크가 말했다 - 당신이 가정 : 당신이 처럼 보였다 하이퍼 링크를 것

$("#well").fadeOut('fast',function(){ 
    window.location = 'http://www.foobar.com'; 
}); 
+1

그 예에서 :

$("#well").fadeOut('fast',function(){ window.location = $('#myLink').attr('href'); }); 

것은 그냥 URL로 재 지정하려면 . JQuery는 CSS 선택기를 사용하여 객체를 찾습니다. #의 경우, DOM 요소의 ID입니다. 그래서 $ ("# foo는")는 foo는의 ID로 DOM 요소를 찾아 낼 것입니다. – JSager