0

画像のホバー時にオーバーレイでフェードインする単純なjquery関数があります。

if($(".portfolioThumbs").length>0){
$(".magnify").css("opacity","0");
$(".magnify").hover(function(){$(this).stop().animate({opacity:1},"slow")},function()     {$(this).stop().animate({opacity:0},"slow")}
)};

これと同じ効果をモバイルで動作させるにはどうすればよいですか? 「touchstart」と「touchend」を使用できる場所を読みました-それが正しい場合、どうすればそれをこの関数に組み合わせることができますか?

ありがとう!

4

1 に答える 1

0

多分そのようなものがうまくいくかもしれません。

var hoverStart = function(evt){
    $(this).stop().animate({
        opacity:1
    },"slow")
};
var hoverEnd = function(evt)     {
    $(this).stop().animate({
        opacity:0
    },"slow")
}
if($(".portfolioThumbs").length>0){
    $(".magnify").css("opacity","0");
    $(".magnify").bind('touchstart',hoverStart);
    $(".magnify").bind('touchend',hoverEnd);
    $(".magnify").hover(hoverStart, hoverEnd);
}
于 2013-01-25T04:59:54.200 に答える