Skip to content

Instantly share code, notes, and snippets.

@AdsonCicilioti
Last active December 28, 2015 17:42
Show Gist options
  • Select an option

  • Save AdsonCicilioti/1adf4f50b688ce2b8b19 to your computer and use it in GitHub Desktop.

Select an option

Save AdsonCicilioti/1adf4f50b688ce2b8b19 to your computer and use it in GitHub Desktop.

Revisions

  1. AdsonCicilioti revised this gist Dec 28, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion anchorSmooth.js
    Original file line number Diff line number Diff line change
    @@ -17,5 +17,4 @@ jQuery(document).ready(function($) {
    scrollTop: that_offset.top - 150 // Set a negative value to compensate for a fixed height of the top bar
    }, speed);
    }

    });
  2. AdsonCicilioti revised this gist Dec 28, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions anchorSmooth.js
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    jQuery(document).ready(function($) {
    ////// ANCHOR SMOOTH
    $('a[href^="#"]').click(function(e) {
    e.preventDefault();
    anchorScroll( $(this), $($(this).attr('href')), 800 );
    });

    function anchorScroll(this_obj, that_obj, base_speed) {
    var this_offset = this_obj.offset();
    var that_offset = that_obj.offset();
  3. AdsonCicilioti revised this gist Dec 28, 2015. No changes.
  4. AdsonCicilioti revised this gist Dec 28, 2015. 1 changed file with 14 additions and 14 deletions.
    28 changes: 14 additions & 14 deletions anchorSmooth.js
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,21 @@
    jQuery(document).ready(function($) {

    ////// ANCHOR SMOOTH
    $('a[href^="#"]').click(function(e) {
    e.preventDefault();
    anchorScroll( $(this), $($(this).attr('href')), 800 );
    });
    ////// ANCHOR SMOOTH
    $('a[href^="#"]').click(function(e) {
    e.preventDefault();
    anchorScroll( $(this), $($(this).attr('href')), 800 );
    });

    function anchorScroll(this_obj, that_obj, base_speed) {
    var this_offset = this_obj.offset();
    var that_offset = that_obj.offset();
    var offset_diff = Math.abs(that_offset.top - this_offset.top);

    var speed = (offset_diff * base_speed) / 1000;

    $('html,body').animate({
    scrollTop: that_offset.top - 150 // Set a negative value to compensate for a fixed height of the top bar
    }, speed);
    var this_offset = this_obj.offset();
    var that_offset = that_obj.offset();
    var offset_diff = Math.abs(that_offset.top - this_offset.top);
    var speed = (offset_diff * base_speed) / 1000;
    $('html,body').animate({
    scrollTop: that_offset.top - 150 // Set a negative value to compensate for a fixed height of the top bar
    }, speed);
    }

    });
  5. AdsonCicilioti created this gist Dec 28, 2015.
    21 changes: 21 additions & 0 deletions anchorSmooth.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    jQuery(document).ready(function($) {

    ////// ANCHOR SMOOTH
    $('a[href^="#"]').click(function(e) {
    e.preventDefault();
    anchorScroll( $(this), $($(this).attr('href')), 800 );
    });

    function anchorScroll(this_obj, that_obj, base_speed) {
    var this_offset = this_obj.offset();
    var that_offset = that_obj.offset();
    var offset_diff = Math.abs(that_offset.top - this_offset.top);

    var speed = (offset_diff * base_speed) / 1000;

    $('html,body').animate({
    scrollTop: that_offset.top - 150 // Set a negative value to compensate for a fixed height of the top bar
    }, speed);
    }

    });