@@ -224,6 +224,7 @@ export class Draggable extends Base<HTMLElement> implements INotifyPropertyChang
224224 public isPreventSelect : boolean ;
225225 /**
226226 * Specifies the callback function for drag event.
227+
227228 * @event
228229 */
229230 @Event ( )
@@ -324,7 +325,7 @@ export class Draggable extends Base<HTMLElement> implements INotifyPropertyChang
324325 */
325326 @Property ( 750 )
326327 public tapHoldThreshold : number ;
327- /**
328+ /**
328329 * @private
329330 */
330331 @Property ( false )
@@ -352,6 +353,7 @@ export class Draggable extends Base<HTMLElement> implements INotifyPropertyChang
352353 private prevTop : number = 0 ;
353354 private dragProcessStarted : boolean = false ;
354355 /* tslint:disable no-any */
356+ private eleTop : number = 0 ;
355357 private tapHoldTimer : any = 0 ;
356358 private dragElePosition : any ;
357359 public currentStateTarget : any ;
@@ -572,6 +574,11 @@ export class Draggable extends Base<HTMLElement> implements INotifyPropertyChang
572574 if ( this . clone && marginTop !== 0 ) {
573575 pos . top += marginTop ;
574576 }
577+ this . eleTop = ! isNaN ( parseFloat ( styles . top ) ) ? parseFloat ( styles . top ) - this . offset . top : 0 ;
578+ /* istanbul ignore next */
579+ // if (this.eleTop > 0) {
580+ // pos.top += this.eleTop;
581+ // }
575582 if ( this . enableScrollHandler && ! this . clone ) {
576583 pos . top -= this . parentScrollY ;
577584 pos . left -= this . parentScrollX ;
@@ -688,7 +695,6 @@ export class Draggable extends Base<HTMLElement> implements INotifyPropertyChang
688695 let dLeft : number = this . position . left - this . diffX ;
689696 let dTop : number = this . position . top - this . diffY ;
690697 let styles : CSSStyleDeclaration = getComputedStyle ( helperElement ) ;
691- let marginTop : number = parseFloat ( styles . marginTop ) ;
692698 if ( this . dragArea ) {
693699 if ( this . pageX !== pagex || this . skipDistanceCheck ) {
694700 let helperWidth : number = helperElement . offsetWidth + ( parseFloat ( styles . marginLeft )
@@ -732,37 +738,42 @@ export class Draggable extends Base<HTMLElement> implements INotifyPropertyChang
732738 this . dragLimit . top = this . clone ? this . dragLimit . top : 0 ;
733739 draEleTop = ( top - iTop ) < 0 ? this . dragLimit . top : ( top - iTop ) ;
734740 draEleLeft = ( left - iLeft ) < 0 ? this . dragElePosition . left : ( left - iLeft ) ;
735- // when drag-element has margin-top
736- /* istanbul ignore next */
737- if ( marginTop > 0 ) {
738- if ( this . clone ) {
739- draEleTop += this . element . offsetTop ;
740- if ( dTop < 0 ) {
741- if ( ( this . element . offsetTop + dTop ) >= 0 ) {
742- draEleTop = this . element . offsetTop + dTop ;
743- } else {
744- draEleTop -= this . element . offsetTop ;
745- }
741+ } else {
742+ draEleTop = top - iTop ;
743+ draEleLeft = left - iLeft ;
744+ }
745+ let marginTop : number = parseFloat ( getComputedStyle ( this . element ) . marginTop ) ;
746+ // when drag-element has margin-top
747+ /* istanbul ignore next */
748+ if ( marginTop > 0 ) {
749+ if ( this . clone ) {
750+ draEleTop += marginTop ;
751+ if ( dTop < 0 ) {
752+ if ( ( marginTop + dTop ) >= 0 ) {
753+ draEleTop = marginTop + dTop ;
754+ } else {
755+ draEleTop -= marginTop ;
746756 }
747- draEleTop = ( this . dragLimit . bottom < draEleTop ) ? this . dragLimit . bottom : draEleTop ;
748757 }
749- if ( ( top - iTop ) < 0 ) {
750- if ( dTop + marginTop + ( helperElement . offsetHeight - iTop ) >= 0 ) {
751- let tempDraEleTop : number = this . dragLimit . top + dTop - iTop ;
752- if ( ( tempDraEleTop + marginTop + iTop ) < 0 ) {
753- draEleTop -= marginTop + iTop ;
754- } else {
755- draEleTop = tempDraEleTop ;
756- }
757- } else {
758+ draEleTop = ( this . dragLimit . bottom < draEleTop ) ? this . dragLimit . bottom : draEleTop ;
759+ }
760+ if ( ( top - iTop ) < 0 ) {
761+ if ( dTop + marginTop + ( helperElement . offsetHeight - iTop ) >= 0 ) {
762+ let tempDraEleTop : number = this . dragLimit . top + dTop - iTop ;
763+ if ( ( tempDraEleTop + marginTop + iTop ) < 0 ) {
758764 draEleTop -= marginTop + iTop ;
765+ } else {
766+ draEleTop = tempDraEleTop ;
759767 }
768+ } else {
769+ draEleTop -= marginTop + iTop ;
760770 }
761771 }
762- } else {
763- draEleTop = top - iTop ;
764- draEleLeft = left - iLeft ;
765772 }
773+ /* istanbul ignore next */
774+ // if(this.eleTop > 0) {
775+ // draEleTop += this.eleTop;
776+ // }
766777 if ( this . enableScrollHandler && ! this . clone ) {
767778 draEleTop -= this . parentScrollY ;
768779 draEleLeft -= this . parentScrollX ;
@@ -938,11 +949,6 @@ export class Draggable extends Base<HTMLElement> implements INotifyPropertyChang
938949 pageX = this . clone ? intCoord . pageX : ( intCoord . pageX + window . pageXOffset ) - this . relativeXPosition ;
939950 pageY = this . clone ? intCoord . pageY : ( intCoord . pageY + window . pageYOffset ) - this . relativeYPosition ;
940951 }
941- if ( ! this . clone && this . dragArea && ! isdragscroll ) {
942- this . getScrollableValues ( ) ;
943- pageY -= this . tempScrollHeight ? this . parentScrollY : 0 ;
944- pageX -= this . tempScrollWidth ? this . parentScrollX : 0 ;
945- }
946952 return {
947953 left : pageX - ( this . margin . left + this . cursorAt . left ) ,
948954 top : pageY - ( this . margin . top + this . cursorAt . top )
0 commit comments