【发布时间】:2011-06-20 18:48:48
【问题描述】:
我正在使用Smooth Div Scroll jQuery Plugin 在网站上制作动态幻灯片。加载到胶卷中的图像属于自定义帖子类型,每个都有一个标题并包含一个图像。该插件在包含任意数量图像的长 div 上水平滚动。我的问题是即使在图像消失后我也可以滚动看似无限的时间。
这是我对问题的分析:
- 我尝试使用普通图像代替 后循环,以及一切 按预期工作(没有无限 滚动)。
- 我尝试在 document.ready 和 window.load 之间设置脚本,但使用 document.ready 时它们根本不会加载。
- 我尝试调用公共函数“recalculateScrollableArea”,以便在加载图像后计算面积无济于事,然后通过在脚本中调用 jQuery 中的警报框,我可以看到它仍在被调用在图片加载之前。
通常应该是什么样子: 过度滚动时的样子:
Smooth Div Scroll 代码和以下初始化代码均在页脚底部调用:
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”标签包围,但我不明白为什么会出现问题。
感谢阅读!
编辑: 这里还有一些代码,其中大部分是库存并且在放置普通 IMG 而不是循环时正常工作。
基本的 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 中添加图片的示例:
【问题讨论】:
-
所有浏览器?链接到您的页面?
-
我现在正在本地主机服务器上开发,所以它仍然不在线。所有浏览器都出现此问题。
-
如果您随后发布所有相关代码可能会有所帮助......到目前为止发布的内容无法解决太多问题。
-
好的,我在编辑中添加了一堆信息,如果需要其他任何信息,请告诉我。谢谢。
标签: javascript jquery wordpress jquery-ui jquery-plugins