Skip to content

Instantly share code, notes, and snippets.

@incidunt
Forked from srikat/functions.php
Created April 29, 2019 03:24
Show Gist options
  • Select an option

  • Save incidunt/7de37a1ab3be89c106f8d9f2de626499 to your computer and use it in GitHub Desktop.

Select an option

Save incidunt/7de37a1ab3be89c106f8d9f2de626499 to your computer and use it in GitHub Desktop.

Revisions

  1. @srikat srikat revised this gist Feb 3, 2014. 3 changed files with 30 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    add_action( 'wp_enqueue_scripts', 'enqueue_sticky_last_widget' );
    function enqueue_sticky_last_widget() {

    wp_enqueue_style( 'animate', get_stylesheet_directory_uri() . '/css/animate.min.css' );

    wp_enqueue_script( 'waypoints', get_stylesheet_directory_uri() . '/js/waypoints.min.js', array( 'jquery' ), '1.0.0' );
    wp_enqueue_script( 'waypoints-init', get_stylesheet_directory_uri() .'/js/waypoints-init.js' , array( 'jquery', 'waypoints' ), '1.0.0' );

    wp_enqueue_script( 'jquery-sticky', get_stylesheet_directory_uri() .'/js/jquery.sticky.js' , array( 'jquery' ), '1.0.0' );
    wp_enqueue_script( 'jquery-sticky-init', get_stylesheet_directory_uri() .'/js/jquery.sticky.init.js' , array( 'jquery-sticky' ), '1.0.0' );
    }
    5 changes: 5 additions & 0 deletions jquery.sticky.init.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    jQuery(document).ready(function($) {

    $(".sidebar-primary .widget:last-child").sticky({getWidthFrom: ".sidebar-primary .sticky-wrapper", className: "stuck"});

    });
    14 changes: 14 additions & 0 deletions style.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    /*
    Fading in last sidebar widget as it is scrolled to and making it fixed
    -----------------------------------------------------------------------------*/

    .sidebar-primary .widget:last-child {
    filter: alpha(opacity=0);
    opacity: 0;
    /*animation-duration: 1.5s;*/
    }

    .admin-bar .stuck .widget {
    top: 28px !important;
    /*top: 68px !important;*/
    }
  2. @srikat srikat created this gist Feb 3, 2014.
    15 changes: 15 additions & 0 deletions waypoints-init.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    jQuery(function($) {

    $('.sidebar-primary .widget:last-child').waypoint(function(direction) {
    if (direction == 'up') {
    $(this).removeClass( 'fadeIn' ).addClass( 'fadeOut' );
    }
    else {
    $(this).removeClass('fadeOut').addClass( 'animated fadeIn' );
    }
    },
    {
    offset: '50%',
    });

    });