gpt4 book ai didi

javascript - 如何将 Scrollify.js 与 Wordpress 和 Elementor 一起使用?

转载 作者:行者123 更新时间:2023-11-29 23:05:07 25 4
gpt4 key购买 nike

我对网络开发和编程完全陌生,我想在我的 WP 网站上使用 Scrollify。

所以我只想在一个页面中加载 Scrollify,所以我将它添加到 functions.php

function load_js_assets() {
if( is_page( 26 ) ) {
wp_enqueue_script('scrollify', 'https://goodlifesoft.com/scrollify.js', array('jquery'), '', false);
}

我在控制台中添加了一条消息,以查看文件已加载。

我在 header.php

加载了最新版本的 jquery
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

我在footer.php中调用了Scrollify函数

<script>
$(function() {
$.scrollify({
section : ".elementor-element.elementor-element.elementor-section-height-full.elementor-section-content-middle.elementor-section-boxed.elementor-section-height-default.elementor-section-items-middle.elementor-section.elementor-top-section",
});
});
</script>

这是我在控制台中收到的消息。来自控制台的内容

enter image description here

这在 JSfiddle 中对我有用 https://jsfiddle.net/Balodis/w697stj5/60/

如果有人能指出我做错了什么,我将不胜感激。

谢谢!

最佳答案

尝试在我的网站上实现类似的东西并让它工作时发现了这个线程 - 这是我所做的:

  1. 我下载了 scrollify.js 脚本并将其上传到我的 wordpress 子主题文件。

  2. 我使用子函数调用脚本.php

add_action('wp_enqueue_scripts', 'scroll_script');

function scroll_script() {
wp_enqueue_script(
'custom-script',
get_stylesheet_directory_uri().
'/jquery.scrollify.js',
array('jquery')
);
}
  1. 最后,我将此代码添加到页脚
<script>
jQuery(function() {
jQuery.scrollify({
section : ".panel",
sectionName : "data-id",

interstitialSection : "",
easing: "easeOutExpo",
scrollSpeed: 1100,
offset : 0,
scrollbars: true,
standardScrollElements: "",
setHeights: true,
overflowScroll: true,
updateHash: true,
touchScroll:true,
before:function() {},
after:function() {},
afterResize:function() {},
afterRender:function() {}
});
});
</script>

当然,您必须将“Section”类编辑为您想要在自己的页面/布局中滚动的元素。

关于javascript - 如何将 Scrollify.js 与 Wordpress 和 Elementor 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54933229/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com