【问题标题】:How work the waypoints of the divi theme on wordpress?如何在 wordpress 上使用 divi 主题的航点?
【发布时间】:2017-11-25 04:48:30
【问题描述】:

Divi theme 实现了waypoints,有人知道它是如何工作的以及如何使用它们吗?例如这个类允许动画在某个时候et-waypoint,但我需要知道如何操作事件。

【问题讨论】:

    标签: jquery html css wordpress wordpress-theming


    【解决方案1】:

    它是这样工作的,当你将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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-04
      • 2023-04-05
      • 2016-04-12
      • 1970-01-01
      相关资源
      最近更新 更多