We would like to have an anchor DOM element with position:fixed in our facebook canvas app with a fluid canvas size. Because the app runs in the canvas iframe a simple usage of css position:fixed does not work: The iframe content does not see any scroll events from the surrounding facebook page.
First approach to solve this was to ping facebook api and get the scroll position. So we put this into $(document).ready():
# refresh position of feedback button to simulate position:fixed in iframe
refresh_timer = 1000
move_button = () ->
# get scroll position from facebook
FB.Canvas.getPageInfo (info)->
# animate button to new position with an offset of 250px
$('#fdbk_tab').animate({top: info.scrollTop+250}, 100)
# start interval to do the refresh
setInterval(move_button, refresh_timer)
In general this does work. However it results in a bad user experience as the browser reload button and mouse cursor blink when the call to facebook api is triggered.
Any suggestions on how to improve this or other ways to implement/mimic position:fixed within the iframe are highly appreciated!