0
問題がありますが、div要素をビューにスライドさせるコードをいくつか作成できましたが、閉じるボタンクリックされましたか?私はリンクを押し続けることができるので、アニメーションをもう一度再生するのではなく、最後の位置にdivを表示するだけです。divをアニメーション化してボタンをクリックしてスライドさせるにはどうすればいいですか?
HERESにjqueryのコード
$(document).ready(function() {
//select all the a tag with name equal to modal
$('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var id = $(this).attr('href');
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set height and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(600);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//Slide up Boxes Div transition effect
$(id).css({display:'block'}).animate({marginTop:'0px', opacity:'1', },400);
});
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask, .window').hide();
});
//if mask is clicked
$('#mask').click(function() {
$(this).hide();
$('.window').hide();
});
});
おかげ
あなたのHTMLを投稿したり、あなたのコードのjsfiddleを作成することはできますか? – Jasper
@ジャスパーはい、申し訳ありません、ここに行きます。それはモーダルウィンドウのポップアウトであることが意図されていますが、何らかの理由で(私にとってはとにかく)jsfiddleで正しく動作するように見えるhttp://jsfiddle.net/4hw8H/ – Farreal
jsfiddleにはjQueryを含める必要がありましたナビゲーションパネル)。私はあなたのjsfiddleへのアップデートを下の私の答えに掲示しました。 – Jasper