我正在使用Smooth Div Scroll jQuery Plugin在网站上移动幻灯片。加载到电影胶片中的图像是自定义发布类型,每个图像都有一个标题并包含单个图像。该插件在包含任意数量图像的长div上水平滚动。我的问题是,即使在图像消失之后,我仍然可以滚动显示无限的时间。如何在WordPress中加载帖子后运行jQuery方法?
这里是我的问题的故障:
- 我已经使用普通图像后循环,而不是试图 ,一切 预期一样(没有无限 滚动)。
- 我试过在document.ready和window.load之间设置脚本,使用document.ready它们根本不加载。
- 我试过调用一个公共函数“recalculateScrollableArea”,以便可以在图像加载无效后计算该区域,然后通过在脚本中调用jQuery中的警告框,我可以看到它仍然被调用在图像加载之前。
那应该怎么看平时: 如何看起来,当它过卷轴:
的平滑股利滚动代码和下面的初始化代码都被称为在页脚底部:
jQuery(window).load(function() {
jQuery("div#makeMeScrollable").smoothDivScroll({
autoScroll: "onstart" ,
autoScrollDirection: "backandforth",
autoScrollStep: 1,
autoScrollInterval: 15,
visibleHotSpots: "always"
});
这就是我所做的尝试和修正调整大小:
jQuery(document).ready(function() {
jQuery("#makeMeScrollable").smoothDivScroll("disable");
});
我还要提到,对于职位的图像由“P”标签包围,但我不明白为什么这将是问题。
感谢您的阅读!
编辑: 下面是一些更多的代码,其中大部分是股票,当只是普通IMGS的地方,而不是循环工作。
底座CSS和jQuery文件是相同的,在这个简单的演示的那些:http://www.smoothdivscroll.com/basicDemo.htm
jQuery和jQuery UI的进口(工作)
function jQuery_from_Google() {
if (!is_admin()) { // actually not necessary, because the Hook only get used in the Theme
wp_deregister_script('jquery'); // unregistered key jQuery
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js', false, '1.5.2'); // register key jQuery with URL of Google CDN
wp_enqueue_script('jquery'); // include jQuery
}
}
// nur for Themes since WordPress 3.0
add_action('after_setup_theme', 'jQuery_from_Google'); // Theme active, include function
function jQueryUI_from_Google() {
if (!is_admin()) { // actually not necessary, because the Hook only get used in the Theme
wp_register_script('jqueryui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js'); // register key jQueryUI with URL of Google CDN
wp_enqueue_script('jqueryui'); // include jQueryUI
}
}
// nur for Themes since WordPress 3.0
add_action('after_setup_theme', 'jQueryUI_from_Google'); // Theme active, include function
进口发生在页脚底部:
<?php // Smooth Div Scroll inport for filmstrip galleries ?>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/javascript/filmstrip.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/SmoothDivScroll-1.1/js/jquery.smoothDivScroll-1.1-min.js"></script>
</body>
</html>
这里是一个部分的代码片段,它使用的内容的循环:
<?php if(is_page('engagements')) { ?>
<div id="makeMeScrollable">
<div class="scrollingHotSpotLeft"></div>
<div class="scrollingHotSpotRight"></div>
<div class="scrollWrapper">
<div class="scrollableArea">
<?php
$args = array('post_type' => 'engagement_photos');
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
the_content();
endwhile;
?>
</div>
</div>
</div>
<?php } else if(is_page('weddings')) { ?>
这里是WordPress中添加图像的例子:
所有浏览器?链接到您的网页? – Sparky
我现在正在本地主机服务器上开发,所以它仍然不在线。所有浏览器都出现这个问题。 – mitchellbutler
如果您发布了所有相关的代码,那么可能会有所帮助......但是到目前为止发布的内容可以完成很多故障排除工作。 – Sparky