I am using a fancybox with plugin jquery.easydrag.js. The reason for this is to be able to drag the fancybox around.
It seems to be working fine, but the problem comes when the fancybox has scrollbars. I.e. for example when clicking on submit and not entering any fields the valdidation on screen causes scrollbars. Which is fine normally but the scrollbars causes all sorts of issues with the draggable feature so that when I am trying to click the scrollbar up and down, it actually moves the entire windows. So it seems to be confused as to what content can be moved and what to do with a scrollbar.
claimLink.fancybox({
'width': 500,
'height': 590,
'autoDimensions': false,
'onCleanup': function (e) {
var modelClaimFormId = $j(e).attr("href").replace("body", "");
var modalClaimForm = $j(modelClaimFormId);
if (!($j(modalClaimForm).valid())) {
$j(claimForm).remove();
$j(e).parents("tr").remove();
}
}
});
$j("#fancybox-wrap").easydrag(true);
EDIT :
I managed to add something for input and textareas to ignore the scrolling see below…just wondering what I can do for scrollbars.
$j("#fancybox-wrap").easydrag(true);
$j("#fancybox-wrap input,textarea").click(function(){
$j("#fancybox-wrap").dragOff();
});
$j("#fancybox-wrap input,textarea").mouseover(function () {
$j("#fancybox-wrap").dragOff();
});
$j("#fancybox-wrap input,textarea").blur(function () {
$j("#fancybox-wrap").dragOn();
});
$j("#fancybox-wrap input,textarea").mouseout(function () {
$j("#fancybox-wrap").dragOn();
});
This is the link to JS for easydrag plugin
I posted the first example about how to make fancybox draggable back in 2009 for v1.2.1. Then I posted some notes to make it work with v1.3.1 as seen here but when fancybox v1.3.4 was introduced, the
easyDragplugin was not working as smooth as with the previous versions and started behaving buggy. I didn’t have the time to find a workaround … so I just drop it.The solution was simple though: the
easyDragplugin provides a way to set a “handler” as explained here so instead of holding and dragging the whole#fancybox-wrapcontainer, which blocks access to the scroll bars if any, you just drag the lightbox from a specific defined element. Such handler can be appended to#fancybox-wrapselector and set it within the EasyDrag plugin using theonCompletecallback API option like:Notice that you can use any element as handler, in my example I used a html button but you may use an image if preferred. The important thing is to assign the minimum important
cssproperties to the handler so it can be appended to the#fancybox-wrapcontainer without issue like:other properties can be cosmetic.
See it working here!!!
Once you complete and submit the form, the response will be a new fancybox with scroll bars that you can use independently from the easyDrag handler.
Please feel free to analyze the code and customize it to your own needs (and don’t forget to grant me the bounty 😉
UPDATE: Notice that since we are appending the handler to the
#fancybox-wrapcontainer every time we fire fancybox, then we need to remove it once we close fancybox using theonClosedcallback, otherwise we will duplicate the handler if we open fancybox again with unexpected results:I updated my DEMO too.
LAST NOTE: This solution is for fancybox v1.3.4.
I haven’t tested it with v2.x but I don’t see why it wouldn’t work. Just make sure that you bind
EasyDragand append the handler to the.fancybox-wrapselector insteadYou may use the
afterShowcallback to append the handler to it andafterCloseto remove it.