Lines 10-37
Link Here
|
10 |
|
10 |
|
11 |
<script type="text/javascript"> |
11 |
<script type="text/javascript"> |
12 |
//<![CDATA[ |
12 |
//<![CDATA[ |
13 |
var originalOffset; |
13 |
$(document).ready(function() { |
14 |
$(window).scroll(function () { |
14 |
function positionMap() { |
15 |
var tbh = $("#mapid"); |
15 |
var tbh = $("#mapid"); |
16 |
var offsetTop = tbh.offset().top; |
16 |
var mapContainer = tbh.parent(); |
17 |
var s = parseInt($(window).scrollTop(), 10); |
17 |
mapContainer.css('position', 'relative'); |
18 |
var fixMe = (s > offsetTop); |
18 |
tbh.css('position', 'absolute'); |
19 |
if ( !originalOffset ) originalOffset = tbh.position().top; |
19 |
tbh.css('right', 0); |
20 |
var repositionMe = (s < originalOffset); |
20 |
|
21 |
if (fixMe) { |
21 |
var offsetTop = mapContainer.offset().top; |
22 |
tbh.css({ |
22 |
var s = parseInt($(window).scrollTop(), 10); |
23 |
'position': 'fixed', |
23 |
tbh.css('top', '').css('bottom', ''); |
24 |
'top': '0', |
24 |
if (s > offsetTop) { |
25 |
'margin-left': '40%' |
25 |
var mapContainerOffsetBottom = offsetTop + mapContainer.innerHeight(); |
26 |
}); |
26 |
if (s + tbh.outerHeight(true) > mapContainerOffsetBottom) { |
27 |
} |
27 |
tbh.css('bottom', 0); |
28 |
if (repositionMe) { |
28 |
} else { |
29 |
tbh.css({ |
29 |
tbh.css('top', s - offsetTop); |
30 |
'position': 'absolute', |
30 |
} |
31 |
'top': originalOffset, |
31 |
} else { |
32 |
'margin-left': '40%' |
32 |
tbh.css('top', 0); |
33 |
}); |
33 |
} |
34 |
} |
34 |
} |
|
|
35 |
|
36 |
$(window).scroll(positionMap); |
37 |
positionMap(); |
35 |
}); |
38 |
}); |
36 |
//]]> |
39 |
//]]> |
37 |
</script> |
40 |
</script> |
38 |
- |
|
|