Drag & Drop Web Part Y-offset Problem

January 18 2011 11 comments

I’ve come across a bug in SharePoint 2010 with my custom master page that is based on minimal.master. In the edit mode, if I try to drag and drop web parts around, the element that is used to mark the drag position has a strange offset. Upon more investigation it appears that the javascript function that positions the marker with the class ‘ms-SPZoneIBar’ ignores the scroll position of the #s4-workspace div.

Override the javascript function with your own, and everything is golden once again.

MSOLayout_GetRealOffset = function (StartingObject, OffsetType, EndParent) {
    var realValue = 0;
    if (!EndParent) EndParent = document.body;
    for (var currentObject = StartingObject;
        currentObject != EndParent &&
        currentObject != document.body &&
        currentObject != null;
        currentObject = currentObject.offsetParent) {
        realValue += eval('currentObject.offset' + OffsetType);
    return (OffsetType == 'Top') ? realValue - document.getElementById('s4-workspace').scrollTop : realValue;

Popularity: 1% [?]

11 comments to “Drag & Drop Web Part Y-offset Problem”

  1. Jukka says:

    Tuukka, you saved my day with this!

  2. Andy says:

    I have the same problem in SharePoint 2007…any idea how to get this to work in that? This line causes the problem for SP 2007:

    realValue – document.getElementById(‘s4-workspace’).scrollTop

    …due to s4-workspace.

  3. Andy says:

    Actually I realise it is not the position of the drag bar that is the problem, it is the position of the web part name that follows the mouse. It is aligned to the mouse when at the top of the page but scroll down a little and it looks like this is positioned from the top of the page rather than relative to the page scrolling position. Any ideas?

  4. Seeing as I saw you recommend Optimum 100% Whey, have you had any experience with their Brand of Weightgainer?Pro Complex Gainer

  5. Wow, that’s what I was exploring for, what a
    information! present here at this webpage, thanks admin of this site.

  6. Hi-ya, good web site you possess in here.|

  7. Incredibly informative….look frontward to visiting again.|

  8. MayaDWatling says:

    Hello to every , since I am really eager of reading this
    webpage’s post to be updated on a regular basis.

    It includes pleasant stuff.

    My web blog MayaDWatling

  9. This is an old post but the code still works. Thank you!

  10. I like your last statement. This deserves thumps up. Thank you for the observation and for giving us a tip!

  11. If you are looking for casual chat contacts in France you must to visit transsexuelle lyon

Leave a Reply