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
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;
}
TypeError: $(...).resizable is not a function ;)
–
Marketplace 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 put a break point on the ...draggable(...); you'll see that it is added position:fixed to the element.style.
just undo that with .style.position ="";
my code clears the style so it would fall back on the css declaration. with older jquery ui version, you may need to do the drag stop handler. which i doubt. but definitely not true for the latest.
© 2022 - 2024 — McMap. All rights reserved.