File tree 3 files changed +13
-49
lines changed
3 files changed +13
-49
lines changed Original file line number Diff line number Diff line change 17
17
* until we are at the direct child of parentEl
18
18
* use-case: find scroll offset of any element within a scroll container
19
19
*/
20
- getPositionInParent : function ( el , parentEl ) {
21
- var left = 0 , top = 0 ;
22
- while ( el && el !== parentEl ) {
23
- left += el . offsetLeft ;
24
- top += el . offsetTop ;
25
- el = el . parentNode ;
26
- }
20
+ getPositionInParent : function ( el ) {
27
21
return {
28
- left : left ,
29
- top : top
22
+ left : el . offsetLeft ,
23
+ top : el . offsetTop
30
24
} ;
31
25
} ,
32
26
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+
2
+ describe ( 'js/utils/dom' , function ( ) {
3
+
4
+ describe ( 'getPositionInParent' , function ( ) {
5
+ it ( 'should return el.{offsetLeft,offsetTop}' , function ( ) {
6
+ var el = { offsetLeft : 3 , offsetTop : 4 } ;
7
+ expect ( ionic . DomUtil . getPositionInParent ( el ) ) . toEqual ( { left : 3 , top : 4 } ) ;
8
+ } ) ;
9
+ } ) ;
10
+ } ) ;
You can’t perform that action at this time.
0 commit comments