@@ -66,6 +66,7 @@ describe('draggable directive', () => {
66
66
#draggableElement
67
67
mwlDraggable
68
68
[dragAxis]="{x: true, y: true}"
69
+ [validateDrag]="validateDrag"
69
70
(dragPointerDown)="dragPointerDown($event)"
70
71
(dragStart)="dragStart($event)"
71
72
(ghostElementCreated)="ghostElementCreated($event)"
@@ -961,4 +962,30 @@ describe('draggable directive', () => {
961
962
changedTouches : [ { clientX : 10 , clientY : 18 } ]
962
963
} ) ;
963
964
} ) ;
965
+
966
+ it ( 'should expose the css transform on the validate drag function' , ( ) => {
967
+ const scrollFixture = TestBed . createComponent ( ScrollTestComponent ) ;
968
+ scrollFixture . componentInstance . validateDrag = sinon . stub ( ) . returns ( true ) ;
969
+ scrollFixture . detectChanges ( ) ;
970
+ document . body . appendChild ( scrollFixture . nativeElement ) ;
971
+ const draggableElement =
972
+ scrollFixture . componentInstance . draggableElement . nativeElement ;
973
+ triggerDomEvent ( 'mousedown' , draggableElement , { clientX : 5 , clientY : 10 } ) ;
974
+ triggerDomEvent ( 'mousemove' , draggableElement , { clientX : 5 , clientY : 12 } ) ;
975
+ scrollFixture . componentInstance . scrollContainer . elementRef . nativeElement . scrollTop = 5 ;
976
+ scrollFixture . debugElement
977
+ . query ( By . directive ( DraggableScrollContainerDirective ) )
978
+ . triggerEventHandler ( 'scroll' , { } ) ;
979
+ triggerDomEvent ( 'mousemove' , draggableElement , { clientX : 5 , clientY : 14 } ) ;
980
+ expect (
981
+ scrollFixture . componentInstance . validateDrag
982
+ ) . to . have . been . calledWith ( {
983
+ x : 0 ,
984
+ y : 9 ,
985
+ transform : {
986
+ x : 0 ,
987
+ y : 4
988
+ }
989
+ } ) ;
990
+ } ) ;
964
991
} ) ;
0 commit comments