Explore the community Forums Lectora Lectora Questions & Answers Drag and drop question: snap back if incorrect Reply To: Drag and drop question: snap back if incorrect

#377621 Score: 0
Profile photo of SB Chapman
SB Chapman
Member
beginner
intermediate
profile
picture perfect
wise owl
friend finder
contributor
curious george
Group Member
@schapman1885

After reading through the code and doing some testing with a collegeue, we dscovered that the

The following line: if(ansVarArray[dropId-1]!=(dropId + ‘-‘ + dropId)){

was problematic for us when we needed the first item to snap back.

So we made the following update: if(ansVarArray[dropId-1]!=(dropId +’-(na)’)){

This allowed the first item to properly snapback into place.

<script>var ansVar = VarQuestion_0002;
var restoreInitFunc = Update_qu53;
function dragItemDrop(dropId){
window.setTimeout(‘delayDragItemDrop(‘+dropId+’)’,100);
}
function delayDragItemDrop(dropId){
var ansVarArray = ansVar.getValue().split(‘,’);
if(ansVarArray[dropId-1]!=(dropId +’-(na)’)){
dragMgr.arrDragItems[dropId-1].restoreInit(restoreInitFunc);
}
}
</script>