File tree Expand file tree Collapse file tree 4 files changed +69
-7
lines changed Expand file tree Collapse file tree 4 files changed +69
-7
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ <h2 id="qunit-userAgent"></h2>
43
43
< div id ="parent " style ="position: absolute; width: 6px; height: 6px; top: 4px; left: 4px; line-height: 6px; "> </ div >
44
44
< div id ="within " style ="position: absolute; width: 12px; height: 12px; top: 2px; left: 0px; "> </ div >
45
45
46
- < div style ="position: absolute; top: 0px; left: 0px ">
46
+ < div id =" scrollx " style ="position: absolute; top: 0px; left: 0px ">
47
47
< div id ="elx " style ="position: absolute; width: 10px; height: 10px; line-height: 10px; "> </ div >
48
48
< div id ="parentx " style ="position: absolute; width: 20px; height: 20px; top: 40px; left: 40px; "> </ div >
49
49
</ div >
Original file line number Diff line number Diff line change @@ -591,6 +591,67 @@ test( "within", function() {
591
591
} , "flipfit - left top" ) ;
592
592
} ) ;
593
593
594
+ test ( "with scrollbars" , function ( ) {
595
+ expect ( 4 ) ;
596
+
597
+ $ ( "#scrollx" ) . css ( {
598
+ width : 100 ,
599
+ height : 100 ,
600
+ left : 0 ,
601
+ top : 0
602
+ } ) ;
603
+
604
+ collisionTest ( {
605
+ of : "#scrollx" ,
606
+ collision : "fit" ,
607
+ within : "#scrollx"
608
+ } , {
609
+ top : 90 ,
610
+ left : 90
611
+ } , "visible" ) ;
612
+
613
+ $ ( "#scrollx" ) . css ( {
614
+ overflow : "scroll"
615
+ } ) ;
616
+
617
+ var scrollbarInfo = $ . position . getScrollInfo ( $ . position . getWithinInfo ( $ ( "#scrollx" ) ) ) ;
618
+
619
+ collisionTest ( {
620
+ of : "#scrollx" ,
621
+ collision : "fit" ,
622
+ within : "#scrollx"
623
+ } , {
624
+ top : 90 - scrollbarInfo . height ,
625
+ left : 90 - scrollbarInfo . width
626
+ } , "scroll" ) ;
627
+
628
+ $ ( "#scrollx" ) . css ( {
629
+ overflow : "auto"
630
+ } ) ;
631
+
632
+ collisionTest ( {
633
+ of : "#scrollx" ,
634
+ collision : "fit" ,
635
+ within : "#scrollx"
636
+ } , {
637
+ top : 90 ,
638
+ left : 90
639
+ } , "auto, no scroll" ) ;
640
+
641
+ $ ( "#scrollx" ) . css ( {
642
+ overflow : "auto"
643
+ } ) . append ( $ ( "<div>" ) . height ( 300 ) . width ( 300 ) ) ;
644
+
645
+ collisionTest ( {
646
+ of : "#scrollx" ,
647
+ collision : "fit" ,
648
+ within : "#scrollx"
649
+ } , {
650
+ top : 90 - scrollbarInfo . height ,
651
+ left : 90 - scrollbarInfo . width
652
+ } , "auto, with scroll" ) ;
653
+ } ) ;
654
+
594
655
test ( "fractions" , function ( ) {
595
656
expect ( 1 ) ;
596
657
Original file line number Diff line number Diff line change 97
97
collision : $ ( "#collision_horizontal" ) . val ( ) + " " + $ ( "#collision_vertical" ) . val ( )
98
98
} ) ;
99
99
}
100
- $ ( ".demo" ) . append ( "<div style='width:5000px;height:5000px;' />" ) . css ( "overflow" , "auto " ) ;
100
+ $ ( ".demo" ) . css ( "overflow" , "scroll " ) ;
101
101
102
102
$ ( ".positionable" ) . css ( "opacity" , 0.5 ) ;
103
103
Original file line number Diff line number Diff line change @@ -58,12 +58,13 @@ $.position = {
58
58
getScrollInfo : function ( within ) {
59
59
var overflowX = within . isWindow ? "" : within . element . css ( "overflow-x" ) ,
60
60
overflowY = within . isWindow ? "" : within . element . css ( "overflow-y" ) ,
61
- scrollbarWidth = overflowX === "auto" || overflowX === "scroll" ? $ . position . scrollbarWidth ( ) : 0 ,
62
- scrollbarHeight = overflowY === "auto" || overflowY === "scroll" ? $ . position . scrollbarWidth ( ) : 0 ;
63
-
61
+ hasOverflowX = overflowX === "scroll" ||
62
+ ( overflowX === "auto" && within . width < within . element [ 0 ] . scrollWidth ) ,
63
+ hasOverflowY = overflowY === "scroll" ||
64
+ ( overflowY === "auto" && within . height < within . element [ 0 ] . scrollHeight ) ;
64
65
return {
65
- height : within . height < within . element [ 0 ] . scrollHeight ? scrollbarHeight : 0 ,
66
- width : within . width < within . element [ 0 ] . scrollWidth ? scrollbarWidth : 0
66
+ width : hasOverflowX ? $ . position . scrollbarWidth ( ) : 0 ,
67
+ height : hasOverflowY ? $ . position . scrollbarWidth ( ) : 0
67
68
} ;
68
69
} ,
69
70
getWithinInfo : function ( element ) {
You can’t perform that action at this time.
0 commit comments