Last active
August 23, 2020 09:22
-
-
Save wpmudev-sls/f9254b1ae9b49a0eadc41f918b7949b0 to your computer and use it in GitHub Desktop.
[Smush Pro] - Fix conflict lazyload with animation of Divi theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: [Smush Pro] - Fix conflict lazyload with animation of Divi theme | |
* Description: [Smush Pro] - Fix conflict lazyload with animation of Divi theme - 1154129948397436 | |
* Author: Thobk @ WPMUDEV | |
* Author URI: https://premium.wpmudev.org | |
* License: GPLv2 or later | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
add_action( 'wp_footer', function () { | |
if( defined('WP_SMUSH_VERSION') && class_exists( 'Smush\WP_Smush' ) ){ | |
// return if disabled lazyload | |
if( ! Smush\Core\Settings::get_instance()->get('lazy_load') ) return; | |
?> | |
<script> | |
// jQuery Appear Plugin | |
!function(p){var n=[],o=!1,f=!1,u={interval:250,force_process:!1},s=p(window),c=[];function d(){f=!1;for(var e=0,r=n.length;e<r;e++){var t=(i=n[e],p(i).filter(function(){return p(this).is(":appeared")}));if(t.trigger("appear",[t]),c[e]){var a=c[e].not(t);a.trigger("disappear",[a])}c[e]=t}var i}p.expr.pseudos.appeared=p.expr.createPseudo(function(e){return function(e){var r=p(e);if(!r.is(":visible"))return!1;var t=s.scrollLeft(),a=s.scrollTop(),i=r.offset(),n=i.left,o=i.top;return o+r.height()>=a&&o-(r.data("appear-top-offset")||0)<=a+s.height()&&n+r.width()>=t&&n-(r.data("appear-left-offset")||0)<=t+s.width()}}),p.fn.extend({appear:function(e,r){return p.appear(this,r),this}}),p.extend({appear:function(e,r){var t,a=p.extend({},u,r||{});if(!o){var i=function(){f||(f=!0,setTimeout(d,a.interval))};p(window).scroll(i).resize(i),o=!0}a.force_process&&setTimeout(d,a.interval),t=e,n.push(t),c.push()},force_appear:function(){return!!o&&(d(),!0)}})}("undefined"!=typeof module?require("jquery"):jQuery); | |
// Custom js | |
(function($){ | |
$(function(){ | |
if( window.et_animation_data && window.Waypoint ){ | |
$.each( window.et_animation_data, function(i, _element){ | |
var _section = $("." + _element.class); | |
$.appear(_section); | |
_section.on('appear', function(){ | |
Waypoint.refreshAll(); | |
}); | |
return false; | |
}); | |
} | |
}); | |
})(window.jQuery); | |
</script> | |
<?php | |
} | |
}, 21 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment