Guest User

Untitled

a guest
Jun 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. var a=new Draggable(newElement,{
  2. handle: 'drag-'+rand,
  3. starteffect: function() {
  4. $('contents-'+rand).hide();
  5. },
  6. endeffect : function () {
  7. $('contents-'+rand).show();
  8. },
  9. onEnd: function(element,event) {
  10.  
  11. var $viewport=document.viewport;
  12. var rightpos=Math.floor((parseFloat($('container-'+rand).getStyle('left')) + parseFloat($('container-'+rand).getStyle('width')))+2); // plus 2 adds for the borders
  13. if( rightpos >=$viewport.getWidth() )
  14. {
  15. var newLeft=Math.floor(( $viewport.getWidth()-$('container-'+rand).getWidth() ));
  16. $('container-'+rand).setStyle({'left': newLeft+'px'});
  17. }
  18. if(parseFloat($('container-'+rand).getStyle('left')) < 0)
  19. {
  20. $('container-'+rand).setStyle({'left': '0px'});
  21. }
  22. if(parseFloat($('container-'+rand).getStyle('top')) < 0)
  23. {
  24. $('container-'+rand).setStyle({'top': '0px'});
  25. }
  26. // bottom
  27. var allowedContainment=Math.floor(($viewport.getHeight() - $('taskbar').getHeight() ));
  28. var bottomPos=$('container-'+rand).getHeight() + parseFloat($('container-'+rand).getStyle('top'));
  29. if(bottomPos >=allowedContainment) {
  30. var newTop=(allowedContainment-$('container-'+rand).getHeight());
  31. $('container-'+rand).setStyle({'top' : newTop+'px'});
  32.  
  33. }
  34.  
  35.  
  36. },// end onEnd
  37. onDrag : function() {
  38.  
  39. if($('suggestiveResults-'+rand)) {
  40.  
  41. $('suggestiveResults-'+rand).remove();
  42. }
  43. }
  44.  
  45.  
  46. });
  47.  
  48. Where container-+rand is the element you want it contained in....
  49.  
  50. You can forget the onDrag: as its just to remove some suggestive search boxes i insert!
Add Comment
Please, Sign In to add comment