This is a message.

Easy dragable overlay using jquery.event.drag.js Created Jul 1, 2009

This thread is solved

Views: 4791     Replies: 4     Last reply Jan 16, 2012  
You must login first before you can use this feature

Levin
To be personal best.

Posts: 4

Registered:
Jun 30, 2009

Easy dragable overlay using jquery.event.drag.js

Posted: Jul 1, 2009

Today i implemented the drag feature on jquery.tools.overlay using jquery.event.drag.js,it's quite easy.Here is the whole demo,hope that can help u.

<html>
<head>
<title>dragable layout</title>
<link href="css/overlay-minimal.css" type="text/css" rel="stylesheet"></link>
</head>
<body>
<div id="drager" style="background:blue;width:200;height:50px;margin:0 auto;" rel="#overlay">Click me to open a overlay...</div>
<!-- overlayed element, which is styled with external stylesheet --> 
<div class="overlay" id="overlay"> 
 
    <!-- here is the content for overlay, can be anything --> 
    <h2 style="margin:10px 0" class="drag">Here is my overlay</h2> 
 
    <p style="float: left; margin:0px 20px 0 0;"> 
        <img src="http://static.flowplayer.org/img/title/eye192.png" /> 
    </p> 
 
    <p> 
         Class aptent taciti sociosqu ad litora torquent per conubia nostra, 
         per inceptos himenaeos. Donec lorem ligula, elementum vitae, 
         imperdiet a, posuere nec, ante. Quisque mattis massa id metus. 
    </p> 
 
</div>

<script src="http://cdn.jquerytools.org/1.0.2/jquery.tools.min.js"></script>

<script src="../jquery_event_drag/1.5/jquery.event.drag-1.5.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div[rel]").overlay({expose:true,closeOnClick:false,onLoad:function(){
	var img=this.getBackgroundImage();//OMG,if no bg-img,overlay will render a empty image...
	var ol=this.getContent();
	ol.bind("drag",function(event){
	var pos={top: event.offsetY,left: event.offsetX};
	$(this).css(pos);
	img.css(pos);	
	})
}});
});

</script>
</body>
</html>

I found that jquery.tools.overlay will always render a img tag in the dom even if i didn't use any background-image in the css of the overlay,which is very evil~It will render an empty image...Sometimes i don't want any background image on my overlay.

Levin
To be personal best.

Posts: 4

Registered:
Jun 30, 2009

and the jquery.event.drag.js

Posted: Jul 1, 2009

Reply to: Easy dragable overlay using jquery.event.drag.js, from mamboer
http://plugins.jquery.com/project/drag

saxony

Posts: 3

Registered:
Jun 25, 2009

scrollable content not scrollable

Posted: Jul 1, 2009

Reply to: and the jquery.event.drag.js, from mamboer
Thanks for the post. I implemented something similar, but ran into the problem with scrollable content in the overlay. Clicking and dragging on the scroll bar causes the whole overlay to drag (intended), but does not allow for scrolling the content.

My solution was to add a separate icon for dragging the overlay next to the close icon. All dragging is managed by the "handle" which allows content to be scrollable inside the overlay.

Hope this helps.

Levin
To be personal best.

Posts: 4

Registered:
Jun 30, 2009

» scrollable content not scrollable

Posted: Jul 1, 2009

Reply to: scrollable content not scrollable, from saxony
Yep,you are in the right way,we should use a 'handle' to handle the drag operation in the actual use.