Skip to content

Instantly share code, notes, and snippets.

View PaulGwamanda's full-sized avatar
💭
Leave the world a little better than you found it

Paul Gwamanda PaulGwamanda

💭
Leave the world a little better than you found it
View GitHub Profile
@PaulGwamanda
PaulGwamanda / SVG-scroll.js
Last active April 5, 2021 22:52
Draws an SVG Path on scroll event
// codepen below
// https://codepen.io/paulgwamanda/pen/EvbJzw
// Initiate animations
// @Todo: optimise
var initAnimations = function() {
var $animatable = $('.revealOnScroll');
$animatable.each( function() {
var pathLength = this.getTotalLength();
@PaulGwamanda
PaulGwamanda / gist:e71c5ee7bb1af4996dbeb1f4699cc011
Created September 6, 2017 15:18
Activate Bootstrap dropdown menu on hover
$('ul.nav li.dropdown').hover(function() {
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn(500);
}, function() {
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut(500);
});
@PaulGwamanda
PaulGwamanda / scroll-progress-bar
Created October 6, 2017 11:05
Scroll progress bar on top of page
//Scroll progress bar
$(document).ready(function() {
$(window).on('scroll', function() {
var docHeight = $(document).height(),
winHeight = $(window).height();
var viewport = docHeight - winHeight,
positionY = $(window).scrollTop();
var indicator = ( positionY / (viewport)) * 100;
$('.scroll-bar').css('width', indicator + '%');
});
@PaulGwamanda
PaulGwamanda / Smooth-scroll-down-arrow-animation.js
Created November 1, 2017 08:03
Smooth scroll animation to page - for anchor tags and scroll down arrow
//Add smooth scroll animation to page
$(document).ready(function(){
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
@PaulGwamanda
PaulGwamanda / wowjs-repeat-animation.js
Created November 2, 2017 09:49
Wow.js repeat animation on scroll up or down
WOW.prototype.addBox = function(element) {
this.boxes.push(element);
};
// Init WOW.js and get instance
var wow = new WOW();
wow.init();
// Attach scrollSpy to .wow elements for detect view exit events,
// then reset elements and add again for animation
@PaulGwamanda
PaulGwamanda / wordpress-active-menu-class.php
Created November 16, 2017 12:15
Add active menu class - wordpress
function special_nav_class ($classes, $item) {
if (in_array('current-menu-item', $classes) ){
$classes[] = 'active';
}
return $classes;
}
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
@PaulGwamanda
PaulGwamanda / wp_bootstrap_navwalker.php
Created November 16, 2017 12:17
Wordpress Bootstrap Navwalker
<?php
/**
* Class Name: wp_bootstrap_navwalker
* GitHub URI: https://github.com/twittem/wp-bootstrap-navwalker
* Description: A custom WordPress nav walker class to implement the Bootstrap 3 navigation style in a custom theme using the WordPress built in menu manager.
* Version: 2.0.4
* Author: Edward McIntyre - @twittem
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
@PaulGwamanda
PaulGwamanda / Dynamic wordpress social media theme options
Last active November 16, 2017 12:28
Dynamic Wordpress Social Media options
/** The list of Social Media options for the site
* This is used to build Theme options to insert each Social Media link and to output it in the theme
* @return array
*/
function ssa_social_media_options()
{
return array(
'facebook' => 'Facebook',
'twitter' => 'Twitter',
'instagram' => 'Instagram',
@PaulGwamanda
PaulGwamanda / Check for any wordpress theme dependencies
Created November 16, 2017 12:26
Check for any wordpress theme dependencies
/**
* Check for any theme dependencies
*
* @return array
*/
function M247_check_theme_dependencies() {
$missing = array();
$plugins = array(
'contact-form-7/wp-contact-form-7.php' => 'Contact Form 7',
'advanced-custom-fields/acf.php' => 'Advanced Custom Fields',
@PaulGwamanda
PaulGwamanda / Display wordpress template for post meta information.
Created November 16, 2017 12:28
Display wordpress template for post meta information.
/**
* Display template for post meta information.
*
*/
function THEME_posted_on()
{
printf(__('Posted on <a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="byline"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>','M247'),
esc_url(get_permalink()),
esc_attr(get_the_time()),
esc_attr(get_the_date('c')),