Skip to content

Instantly share code, notes, and snippets.

@adamcbrewer
Created October 25, 2012 15:58
Show Gist options
  • Select an option

  • Save adamcbrewer/3953638 to your computer and use it in GitHub Desktop.

Select an option

Save adamcbrewer/3953638 to your computer and use it in GitHub Desktop.

Revisions

  1. adamcbrewer revised this gist Dec 3, 2012. No changes.
  2. adamcbrewer revised this gist Nov 7, 2012. No changes.
  3. adamcbrewer revised this gist Nov 7, 2012. No changes.
  4. adamcbrewer revised this gist Oct 25, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion facebook.scrollTop.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    // Function for returning the user to any 'y' position in a Facebook app/tab. Uses jQuery animate, otherwise gracefully falls-back without it.
    // Source: http://stackoverflow.com/questions/7193425/how-do-you-animate-fb-canvas-scrollto & https://developers.facebook.com/docs/reference/javascript/FB.Canvas.scrollTo/
    // Source[1]: http://stackoverflow.com/questions/7193425/how-do-you-animate-fb-canvas-scrollto
    // Source[2]: https://developers.facebook.com/docs/reference/javascript/FB.Canvas.scrollTo/

    var scrollY = function (y) {
    if (window.jQuery) {
  5. adamcbrewer revised this gist Oct 25, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion facebook.scrollTop.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    // Function for returning the user to any 'y' position in a Facebook app/tab
    // Function for returning the user to any 'y' position in a Facebook app/tab. Uses jQuery animate, otherwise gracefully falls-back without it.
    // Source: http://stackoverflow.com/questions/7193425/how-do-you-animate-fb-canvas-scrollto & https://developers.facebook.com/docs/reference/javascript/FB.Canvas.scrollTo/

    var scrollY = function (y) {
    if (window.jQuery) {
  6. adamcbrewer created this gist Oct 25, 2012.
    20 changes: 20 additions & 0 deletions facebook.scrollTop.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    // Function for returning the user to any 'y' position in a Facebook app/tab

    var scrollY = function (y) {
    if (window.jQuery) {
    FB.Canvas.getPageInfo (function (pageInfo) {
    $({ y: pageInfo.scrollTop })
    .animate({
    y: y
    },
    {
    duration: 1000,
    step: function (offset) {
    FB.Canvas.scrollTo(0, offset);
    }
    });
    });
    } else {
    FB.Canvas.scrollTo(0, y);
    }
    };