【发布时间】:2014-02-19 14:15:35
【问题描述】:
您好,我正在尝试将 Smooth Div Scroll 连接到我的网站:http://Izzy.me
Smooth Div Scroll 是这样的:http://smoothdivscroll.com/
在 Izzy.Me 的首页我有 3 张鸟的照片,我用它们作为示例来查看是否连接了 Smooth Div Scroll。
这是这些图片的 CSS:
<div id="makeMeScrollable">
<img src="http://www.birds.com/wp-content/uploads/home/bird4.jpg" alt="Field" id="field" />
<img src="http://www.birds.com/wp-content/uploads/home/bird.jpg" alt="Gnome" id="gnome" />
<img src="http://3.bp.blogspot.com/-KFaKPd9ytxM/TxdKjRZulaI/AAAAAAAAD6A/w0kduvREq2w/s1600/bird-1-wallpaper-1024x768-853745.jpeg" alt="Pencils" id="pencils" />
</div>
在我的子函数 php 中有这个:
<?php
function theme_javascript()
{
wp_enqueue_script( 'kinetic', get_template_directory_uri() . '/js/jquery.kinetic.min.js', array('jquery'), '20140109', true );
wp_enqueue_script( 'mousewheel', get_template_directory_uri() . '/js/jquery.mousewheel.min.js', array('jquery'), '20140109', true );
wp_enqueue_script( 'smoothdivscroll', get_template_directory_uri() . '/js/jquery.smoothdivscroll-1.3-min.js', array('jquery'), '20140109', true );
wp_enqueue_script( 'jquery-ui-1.8.23.custom', get_template_directory_uri() . '/js/jquery-ui-1.8.23.custom.min.js', array('jquery'), '20140109', true );
wp_enqueue_script( 'jquery-ui-1.10.3.custom', get_template_directory_uri() . '/js/jquery-ui-1.10.3.custom.min.js', array('jquery'), '20140109', true );
}
add_action( 'wp_enqueue_scripts', 'theme_javascript' );
?>
我从 Smoothscroll 下载的插件文件,包括 .min 文件和完整的 js 文件。我只是将 .min 文件拖放到我的父主题 JS 文件夹中,而忽略了文件夹中更完整的 .js 文件。
我不确定我的函数代码是否写得正确,因为 .min 文件的名称让我对如何正确包含它们感到有些困惑。所以也许这就是为什么它没有连接? .min 文件的五个名称是:
- jquery.kinetic.min
- jquery.mousewheel.min
- jquery.smoothdivscroll-1.3-min
- jquery-ui-1.8.23.custom.min
- jquery-ui-1.10.3.custom.min
所以现在回头看看我包含的函数 php 看起来对吗? (感谢您的帮助)
【问题讨论】:
-
也许你应该解释一下它的作用以及它应该为你做什么
-
为什么不只包含指向 div-scroll cdn 的链接 (//cdnjs.cloudflare.com/ajax/libs/jquery-smooth-scroll/1.4.13/jquery.smooth-scroll.min .js) 在你的 html 中?
-
另外,.min 文件只是编译的 javascript,它们的包含方式与完整源文件的包含方式相同。
-
Chanckjh ,它应该做的一个例子在这里显示为一个例子:smoothdivscroll.com。您还可以在 blacksabbath.com 上查看示例。还有 rogue_js,我应该尝试包含完整的 js 文件并删除 .min 文件吗?当我将它们包含在我的函数 php 代码中时,文件名看起来正确吗? (您可以使用五个文件名的列表作为参考。
标签: javascript jquery smooth-scrolling