Skip to content

Instantly share code, notes, and snippets.

@lafikl
Created July 3, 2014 18:11
Show Gist options
  • Save lafikl/d8da6e217e5c5f1c0cc8 to your computer and use it in GitHub Desktop.
Save lafikl/d8da6e217e5c5f1c0cc8 to your computer and use it in GitHub Desktop.

Revisions

  1. lafikl created this gist Jul 3, 2014.
    22 changes: 22 additions & 0 deletions steady.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    var el = document.getElementById('head'); // caching it for better performance
    var steady = new Steady({
    throttle: 100,
    handler: function(el, done) {
    console.log('woo!');

    // this important to tell Steady that you finished processing so it can call you later
    done();
    }
    });

    steady.addTracker('is-visible-head', function(){
    var rect = el.getBoundingClientRect();

    return (
    rect.top >= 0
    && rect.left >= 0
    && rect.top <= (window.innerHeight || document.documentElement.clientHeight)
    );
    });

    steady.addCondition('is-visible-head', true);