It works perfect in firefox, but in ie, chrome and opera it doesn't work.
<div> has position:fixed, and is .draggable()
and it doesn't work except firefox
don't set fixed in CSS: it works in firefox, chromium, safari, iexplore
var div = $('#id');
div.resizable(
{
stop: function(event, ui)
{
var top = getTop(ui.helper);
ui.helper.css('position', 'fixed');
ui.helper.css('top', top+"px");
}
});
div.draggable(
{
stop: function(event, ui)
{
var top = getTop(ui.helper);
ui.helper.css('position', 'fixed');
ui.helper.css('top', top+"px");
}
});
function getTop(ele)
{
var eTop = ele.offset().top;
var wTop = $(window).scrollTop();
var top = eTop - wTop;
return top;
}
Just use in your CSS:
#draggable{
position:fixed !important;
}
If you are using both draggable and rezisable delete the "!important" from the CSS, and then set the stop option (the callback when the dragging and resizing stops) to this function:
function stop(event){
if(event.type === "resizestop"){
var topOff = $(this).offset().top - $(window).scrollTop()
$(this).css("top",topOff)
}
$(this).css("position","fixed")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With