如何在wordpress上运用divi主题的路点?

时间:2017-06-22 04:48:33

标签: jquery html css wordpress wordpress-theming

waypoints实施et-waypoint,任何人都知道它是如何工作的以及如何使用它们?例如,这个类允许动画在某个时刻String str = new String(bytesDecode , "UTF-8"); ,但我需要知道如何操纵事件。

1 个答案:

答案 0 :(得分:2)

它的工作方式如下,当你将et-waypoint类分配给任何divi模块时,它将由divi JS编写的jQuery自动获取,

<script>
(function($) {
    var $animation_elements = $('.et-waypoint'),
        $window = $(window);

    function check_if_in_view() {
        var window_height = $window.height(),
            window_top_position = $window.scrollTop(),
            window_bottom_position = (window_top_position + window_height);

        $animation_elements.each(function() {
            var $element = $(this),
                element_height = $element.outerHeight(),
                element_top_position = $element.offset().top,
                element_bottom_position = (element_top_position + element_height);

            //check to see if this element is within viewport
            if ((element_bottom_position >= window_top_position) && (element_top_position <= window_bottom_position)) {
                $element.addClass('et-animated');
            } else {
                $element.removeClass('et-animated');
            }
        });
    }

    $window.on('scroll resize', check_if_in_view);
})(jQuery);
</script>

在这种情况下,$animation_elements抓取et-waypoint并在窗口滚动时调用check_if_in_view