How to Detect When Draggable Hits Top or Bottom of Containment in jQuery UI

How to Detect When Draggable Hits Top or Bottom of Containment in jQuery UI

Can you please take a look at this demo and let me know how to detect when .draggable hits top and bottom of it's containment?

   
  1. $(function(){
  2. var draggableRight;
  3. var draggableWidth = $('.draggable').height();
  4. var parentWidth = $('#parent').height();
  5. $('.draggable').draggable({
  6. containment: 'parent',
  7. axis: "y",
  8. drag: function(e, ui){
  9. // ==> if .draggable hits top of parent change it's background red
  10. // $(document).trigger("mouseup");
  11. // $('.draggable').css({ background: 'red' });
  12. // ==> if .draggable hits bottom of parent change it's background blue
  13. // $(document).trigger("mouseup");
  14. // $('.draggable').css({ background: 'blue' });
  15. }
  16. });
  17. });