Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var a=new Draggable(newElement,{
- handle: 'drag-'+rand,
- starteffect: function() {
- $('contents-'+rand).hide();
- },
- endeffect : function () {
- $('contents-'+rand).show();
- },
- onEnd: function(element,event) {
- var $viewport=document.viewport;
- var rightpos=Math.floor((parseFloat($('container-'+rand).getStyle('left')) + parseFloat($('container-'+rand).getStyle('width')))+2); // plus 2 adds for the borders
- if( rightpos >=$viewport.getWidth() )
- {
- var newLeft=Math.floor(( $viewport.getWidth()-$('container-'+rand).getWidth() ));
- $('container-'+rand).setStyle({'left': newLeft+'px'});
- }
- if(parseFloat($('container-'+rand).getStyle('left')) < 0)
- {
- $('container-'+rand).setStyle({'left': '0px'});
- }
- if(parseFloat($('container-'+rand).getStyle('top')) < 0)
- {
- $('container-'+rand).setStyle({'top': '0px'});
- }
- // bottom
- var allowedContainment=Math.floor(($viewport.getHeight() - $('taskbar').getHeight() ));
- var bottomPos=$('container-'+rand).getHeight() + parseFloat($('container-'+rand).getStyle('top'));
- if(bottomPos >=allowedContainment) {
- var newTop=(allowedContainment-$('container-'+rand).getHeight());
- $('container-'+rand).setStyle({'top' : newTop+'px'});
- }
- },// end onEnd
- onDrag : function() {
- if($('suggestiveResults-'+rand)) {
- $('suggestiveResults-'+rand).remove();
- }
- }
- });
- Where container-+rand is the element you want it contained in....
- You can forget the onDrag: as its just to remove some suggestive search boxes i insert!
Add Comment
Please, Sign In to add comment