I have a draggable div that can be dropped in a droppable div. It works great. The draggable div contains the span element. I would like this span element to disappear as it approaches the dropdown div.
I have a draggable fadeout / in example based on another answer that applies to when you drag an item towards the window. I tried modifying this to fit my needs, but it is not sem, to work for some reason.
Drag the red square to the desired side. You will notice that it fades out when you drag it.
Demo script http://jsfiddle.net/EybmN/32/
$('#draggable').draggable({ drag: function(event, ui) { console.log(ui.helper.find('span')); ui.helper.find('span').css('opacity', 1 - ui.position.left / $(window).width()); } });
My attempt is to modify this so that the behavior is explained above.
Demo http://jsfiddle.net/EybmN/30/
$('#draggable').draggable({ drag: function(event, ui) { console.log(ui.helper.find('span')); $el = $('.droppable.blue'); var bottom = $el.position().top + $el.outerHeight(true); var $span = ui.helper.find('span'); $span.css('opacity', 1 - $span.top / bottom); } });
user5483305
source share