我正在使用jQuery UI卡下拉插件來創建一個非常簡單的匹配遊戲。我想讓卡片的卡入過渡更平滑一點,這樣當您將正確的卡片放在正確的插槽上時,它會穩定地移動到位。jQuery UI下降平滑過渡
她是一個的jsfiddle http://jsfiddle.net/AyN2a/
任何幫助將非常感激。謝謝。
// Create the slots
var words = [ '<img src="images/image1.png" width="200px" height="200px" alt="">', '<img src="images/image2.png" width="200px" height="200px" alt="">', '<img src="images/image3.png" width="200px" height="200px" alt="">', '<img src="images/image4.png" width="200px" height="200px" alt="">', '<img src="images/image5.png" width="200px" height="200px" alt="">', '<img src="images/image6.png" width="200px" height="200px" alt="">', '<img src="images/image7.png" width="200px" height="200px" alt="">'];
for (var i=1; i<=7; i++) {
$('<div>' + words[i-1] + '</div>').data('number', i).appendTo('#cardSlots').droppable({
accept: '#cardPile div',
hoverClass: 'hovered',
drop: handleCardDrop
});
}
function handleCardDrop(event, ui) {
var slotNumber = $(this).data('number');
var cardNumber = ui.draggable.data('number');
if (slotNumber == cardNumber) {
ui.draggable.addClass('correct');
ui.draggable.draggable('disable');
$(this).droppable('disable');
ui.draggable.position({ of: $(this), my: 'left top', at: 'left top' });
ui.draggable.draggable('option', 'revert', false);
correctCards++;
}
if (correctCards == 7) {
$('#successMessage').show();
$('#successMessage').animate({
left: '380px',
width: '150px',
height: '150px',
opacity: 1
});
}
}
你能提供的jsfiddle演示? –
@IvinvinDomininaka愛德華肯定,謝謝。 http://jsfiddle.net/AyN2a/ – user2879183