Sortable: helper position bugged if sortable is in position:relative which is in overflow: scroll

Sortable: helper position bugged if sortable is in position:relative which is in overflow: scroll

Hi,
I found 2 issues with sortable if it is in relative container  which is in overflow: scroll.

Look at this jsfiddle  demo. Scroll down and drag one of the items there. You will see that after you click on the item, the helper jumps to the bottom by value of scroll position. It happens only at first drag.

After some code inspection I've found place where it happens and possible solution. 
_mouseStart method in sortable module calcaulates parent offset at the beginning (calling _getParrentOffset method). Interesting code fragment from this method:
 
  1. $.extend(this.offset, {
  2. click: { 
  3. left: event.pageX - this.offset.left,
  4. top: event.pageY - this.offset.top
  5. },
  6. parent: this._getParentOffset(), //HERE 
  7. relative: this._getRelativeOffset()
  8. });
  9. this.helper.css("position", "absolute");
  10. this.cssPosition = this.helper.css("position");
Look at the end of this snippet and look at _getParentOffset code below. this.cssPosition i set up after _getParentOffset call. Interesting thing is that _getParentOffset had code which resolves problem with nested scrolls and relatives but it relys on this.cssPosition property (which is not set at first time)

_getParentOffset snippet:


if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}

I've put this line of code before _getParentOffset call and it seems to work:

  1. this.cssPosition = "absolute";


The second thing is if you uncomment revert: true and drag one of the items (after scroll down of course) you will see that revert animation is bugged too.

I've found solution for it too.
_mouseStop method doesn't get scroll parent properly so I've changed it like this:

  1.         var scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent;//GET SCROLL PARENT HERE

  2. if(this.options.revert) {
  3. var that = this,
  4. cur = this.placeholder.offset(),
  5. axis = this.options.axis,
  6. animation = {};

  7. if ( !axis || axis === "x" ) {
  8. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : scroll[0].scrollLeft); //USE RECIVED SCROLL PARENT HERE
  9. }
  10. if ( !axis || axis === "y" ) {
  11. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : scroll[0].scrollTop); //AND HERE
  12. }
  13. this.reverting = true;
  14. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  15. that._clear(event);
  16. });
  17. } else {
  18. this._clear(event, noPropagation);
  19. }

I don't know if this changes doesn't break anything but maybe it will help dev team to resolve this issues :)