Using Sugarcube 2 in Twine 1.
I'm back with my drag-and-drop nightmares... hope you're all ready for some FUN times. Basically, everything works fine when my draggables & droppables are both in the body, but I've moved my droppables to the UI-bar (StoryCaption, to be specific), and now they don't seem to register their draggable counterparts. Might this have something to do with using 'postdisplay' to set up the drag-and-drop?
Posting all of my code would take ages, so here's some hopefully helpful snippets.
I don't think any of my CSS is relevant, except that the UI-bar is set automatically to a z-index of 50. In order to have the draggables drag over it, I set their z-index arbitrarily to 100. Is this what's causing my problem?
/*these are my draggables*/
.song, .song3 {
padding: 5px;
background-color: rgba(41,0,0,.7);
display: inline-block;
font-size: .9rem;
padding-left: 10px;
padding-right: 10px;
color: rgba(255,255,255,.8);
margin-top: 5px;
z-index: 100;
}
/*and the droppables*/
#firstSlot, #secondSlot, #thirdSlot, #fourthSlot, #fifthSlot, #sixthSlot, .emptySlot {
width: 100%;
border: 3px ridge brown;
border-radius: 5px;
background-color: rgba(255,255,255,.1);
height: 45px;
color: red;
font-size: 1.1rem;
text-align: center;
}
StoryCaption: depending on the passage, display no past choices, offer a current choice ('"#firstSlot") or display a past choice.
<<if tags().includes("none")>>
<div class="emptySlot"></div>
<div class="emptySlot"></div>
<div class="emptySlot"></div>
<<elseif tags().includes("pickone")>>
<div id="firstSlot"></div>
<div class="emptySlot"></div>
<div class="emptySlot"></div>
<<elseif tags().includes("one")>>
<div class="Slot"><<display oneChoice>></div>
<div class="emptySlot"></div>
<div class="emptySlot"></div>
<</if>>
Truncated version of the JQuery. Basically set $need to however many choices are being made in a specific passage, and when the choices hit that amount, reveal the buttons to move forward. Record each dragged object's ID for future reference.
postdisplay["setUp"] = function () {
$('.btn1').hide();
$('.btn2').hide();
$( ".song" ).addClass("touch");
$( ".song" ).draggable({
revert: true,
containment: "document",
scope: "all"
});
$( "#firstSlot" ).droppable({
drop: handleFirstDrop,
scope: "all"
});
State.variables["songNum"] = 0;
};
function handleFirstDrop( event, ui ) {
$(this).html("");
ui.draggable.draggable( 'disable');
$(this).droppable( 'disable' );
ui.draggable.removeClass('touch');
ui.draggable.addClass('done');
ui.draggable.position( { of: $(this), my: 'left center', at: 'left+3 center' } );
ui.draggable.draggable('option', 'revert', false);
State.variables["songNum"]++;
State.variables["choice1"] = ui.draggable.attr('id');
if ( State.variables["songNum"] == State.variables["need"]) {
$('.btn1').show();
$('.btn2').show();
$('.ui-draggable').removeClass('touch');
$('.ui-draggable').draggable('disable');
}
}
$(document).on('click', '.btn2 button', function() {
State.variables["songNum"] = 0;
$('.btn1').hide();
$('.btn2').hide();
$('.ui-draggable')
.draggable('enable')
.addClass('touch')
.removeClass('done')
.draggable( 'option', 'revert', true);
$('.ui-droppable').droppable('enable');
$('.song').removeAttr('style');
});
Actual passage offering the drag-and-drop choice:
<<set $need to 1>><div id="talk">Passage text goes here...
<div id="songChoice"><div class="song" id="RBFI">Royal Blood - Figure It Out</div> <div class="song" id="CCPB"></div></div>
<span class="btn1"><hr><<button "Yep, that's right.">><<goto "0c">><</button>> <<button "No, wait a second...">><<goto "0b">><</button>></span>
</div>
Any and all help is appreciated, as always.