gpt4 book ai didi

jquery - 滑动后激活链接以解锁... jquery

转载 作者:行者123 更新时间:2023-12-01 01:37:48 24 4
gpt4 key购买 nike

我正在为一个网站使用一个 jquery 插件,我有一个简单的问题...这是一个“滑动解锁”插件,看起来就像 iPhone...我想知道如何允许人们滑动解锁按钮,然后在滑动完成后转发到链接...这是我正在使用的源代码:

$(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);

});

提前感谢您的帮助,我不是一个 javascript 专家,但我认为它需要在 $("#well").fadeOut(); 之后?

最佳答案

您说过您有一个链接 - 假设您有:

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

如果您只想重定向到某个网址:

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

关于jquery - 滑动后激活链接以解锁... jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9013125/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com