我在創建的遊戲中有一個拖放事件。我不想將元素拖放到拖放區域,而是希望能夠單擊拖動區域,然後拖放區域併爲其移動進行動畫處理。是否可以這樣做,以便用戶不必實際拖動它?點擊拖放區域
如果是這樣,在那裏我會從這裏去...
$('.drag').draggable({
helper: 'clone',
snap: '.drop',
grid: [60, 60],
revert: 'invalid',
snapMode: 'corner'
});
$('.drop').droppable({
drop: function(event, ui) {
word = $(this).data('word');
guesses[word].push($(ui.draggable).attr('data-letter'));
console.log($(event));
console.log($(ui.draggable).text());
console.log('CHECKING : ' + $(this).text() + ' against ' + $(ui.draggable).text().trim());
if ($(this).text() == $(ui.draggable).text().trim()) {
$(this).addClass('wordglow3');
} else {
$(this).addClass('wordglow');
}
console.log('CHECKING : ' + $(this).text() + ' against ' + $(ui.draggable).text().trim());
console.log(guesses);
if (guesses[word].length == 3) {
if (guesses[word].join('') == word) {
$('td[data-word=' + word + ']').addClass('wordglow2');
} else {
$('td[data-word=' + word + ']').addClass("wordglow4");
guesses[word].splice(0, guesses[word].length);
}
}
},
這一個方式,我不認爲@Shouvik – sMilbz 2012-08-01 09:28:09
肯定的,試試吧。如果您遇到問題,請發佈您的嘗試,我們會很樂意解決您的問題! :) 最好... – Shouvik 2012-08-01 11:05:06