@@ -4,31 +4,6 @@ function scrollTopSupport() {
4
4
$ ( window ) . scrollTop ( 1 ) ;
5
5
return $ ( window ) . scrollTop ( ) === 1 ;
6
6
}
7
- function getScrollbarWidth ( ) {
8
- var div = $ ( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ) ,
9
- innerDiv = div . children ( ) [ 0 ] ,
10
- w1 , w2 ;
11
- $ ( "body" ) . append ( div ) ;
12
- w1 = innerDiv . offsetWidth ;
13
- div . css ( "overflow" , "scroll" ) ;
14
-
15
- w2 = innerDiv . offsetWidth ;
16
-
17
- if ( w1 === w2 ) {
18
- w2 = div [ 0 ] . clientWidth ;
19
- }
20
-
21
- div . remove ( ) ;
22
-
23
- return w1 - w2 ;
24
- }
25
- function getScrollInfo ( within ) {
26
- var that = within [ 0 ] ,
27
- scrollHeight = within . height ( ) < that . scrollHeight ,
28
- scrollWidth = within . width ( ) < that . scrollWidth ,
29
- scrollbarWidth = getScrollbarWidth ( ) ;
30
- return { height : scrollHeight ? scrollbarWidth : 0 , width : scrollWidth ? scrollbarWidth : 0 } ;
31
- } ;
32
7
33
8
module ( "position - within" , {
34
9
setup : function ( ) {
@@ -301,7 +276,7 @@ test( "collision: fit, no offset", function() {
301
276
302
277
collisionTest ( {
303
278
collision : "fit"
304
- } , { top : addTop + within . height ( ) - 10 - getScrollInfo ( within ) . height , left : addLeft + within . width ( ) - 10 - getScrollInfo ( within ) . width } , "right bottom" ) ;
279
+ } , { top : addTop + within . height ( ) - 10 - $ . position . getScrollInfo ( within ) . height , left : addLeft + within . width ( ) - 10 - $ . position . getScrollInfo ( within ) . width } , "right bottom" ) ;
305
280
306
281
collisionTest2 ( {
307
282
collision : "fit"
@@ -315,7 +290,7 @@ test( "collision: fit, with offset", function() {
315
290
collisionTest ( {
316
291
collision : "fit" ,
317
292
at : "right+2 bottom+3"
318
- } , { top : addTop + within . height ( ) - 10 - getScrollInfo ( within ) . height , left : addLeft + within . width ( ) - 10 - getScrollInfo ( within ) . width } , "right bottom" ) ;
293
+ } , { top : addTop + within . height ( ) - 10 - $ . position . getScrollInfo ( within ) . height , left : addLeft + within . width ( ) - 10 - $ . position . getScrollInfo ( within ) . width } , "right bottom" ) ;
319
294
320
295
collisionTest2 ( {
321
296
collision : "fit" ,
@@ -340,7 +315,7 @@ test( "collision: fit, within scrolled", function() {
340
315
collisionTest2 ( {
341
316
collision : "fit" ,
342
317
at : "right+100 bottom+100"
343
- } , { top : addTop + within . height ( ) - 10 - getScrollInfo ( within ) . height , left : addLeft + within . width ( ) - 10 - getScrollInfo ( within ) . width } , "right bottom" ) ;
318
+ } , { top : addTop + within . height ( ) - 10 - $ . position . getScrollInfo ( within ) . height , left : addLeft + within . width ( ) - 10 - $ . position . getScrollInfo ( within ) . width } , "right bottom" ) ;
344
319
within . scrollTop ( 0 ) . scrollLeft ( 0 ) ;
345
320
}
346
321
} ) ;
@@ -414,7 +389,7 @@ test( "collision: fit, with margin", function() {
414
389
415
390
collisionTest ( {
416
391
collision : "fit"
417
- } , { top : addTop + within . height ( ) - 20 - getScrollInfo ( within ) . height , left : addLeft + within . width ( ) - 20 - getScrollInfo ( within ) . width } , "right bottom" ) ;
392
+ } , { top : addTop + within . height ( ) - 20 - $ . position . getScrollInfo ( within ) . height , left : addLeft + within . width ( ) - 20 - $ . position . getScrollInfo ( within ) . width } , "right bottom" ) ;
418
393
419
394
collisionTest2 ( {
420
395
collision : "fit"
@@ -427,7 +402,7 @@ test( "collision: fit, with margin", function() {
427
402
428
403
collisionTest ( {
429
404
collision : "fit"
430
- } , { top : addTop + within . height ( ) - 20 - getScrollInfo ( within ) . height , left : addLeft + within . width ( ) - 20 - getScrollInfo ( within ) . width } , "right bottom" ) ;
405
+ } , { top : addTop + within . height ( ) - 20 - $ . position . getScrollInfo ( within ) . height , left : addLeft + within . width ( ) - 20 - $ . position . getScrollInfo ( within ) . width } , "right bottom" ) ;
431
406
432
407
collisionTest2 ( {
433
408
collision : "fit"
@@ -440,7 +415,7 @@ test( "collision: fit, with margin", function() {
440
415
441
416
collisionTest ( {
442
417
collision : "fit"
443
- } , { top : addTop + within . height ( ) - 25 - getScrollInfo ( within ) . height , left : addLeft + within . width ( ) - 25 - getScrollInfo ( within ) . width } , "right bottom" ) ;
418
+ } , { top : addTop + within . height ( ) - 25 - $ . position . getScrollInfo ( within ) . height , left : addLeft + within . width ( ) - 25 - $ . position . getScrollInfo ( within ) . width } , "right bottom" ) ;
444
419
445
420
collisionTest2 ( {
446
421
collision : "fit"
0 commit comments