0

在我的主页上添加了一个滚动条/滑块。当我在它自己的页面上构建它时它正在工作,但是当复制到 Wordpress 时它不会动画/滚动。不确定是什么问题。

http://aerodynamicmusic.com/wordpress/

这是CSS:

/* js-disabled class - set image sizes so they all fit in the viewer */
.js-disabled img { width:100px; height:100px; display:block; float:left; margin:30px 0 0; }

#outerContainer { width:642px; height:202px; margin:auto; position:relative; }
#imageScroller { width:642px; height:202px; position:absolute; left: 10px; top: 567px;      background:#000000 url(../images/imageScrollerBG.png) no-repeat; }
#viewer { width:622px; height:182px; overflow:hidden; margin:auto; position:absolute; top:10px; }
#imageScroller a:active, #imageScroller a:visited { color:#000000; }
#imageScroller a img { border:0; }
#controls { width:634px; height:47px; background:url
(../images/controlsBG.png) no-repeat; position:absolute; top:4px;
left:4px; z-index:10;}
#controls a { width:37px; height:35px; position:absolute; top:3px; }
#controls a:active, #controls a:visited { color:#0d0d0d; }
#title { color:#ffffff; font-family:arial; font-size:100%;
font-weight:bold; width:100%;text-align:center; margin-top:10px; }
#rtl { background:url(../images/rtl.png) no-repeat; left:100px; }
#rtl:hover { background:url(../images/rtl_over.png) no-repeat; left:99px; }
#ltr { background:url(../images/ltr.png) no-repeat; right:100px; }
#ltr:hover { background:url(../images/ltr_over.png) no-repeat; }

和html:

<div id="outerContainer">
            <div id="imageScroller">
                <div id="viewer" class="js-disabled">
<a class="wrapper" href="hhttp://aerodynamicmusic.com/wordpress/portfolio/sxsw-march-12/" title="SXSW March 12, 2012"><img class="logo" id="sxsw12" src="http://aerodynamicmusic.com/wordpress/wp-content/uploads/2012/05/sxsw12_slider.jpg" alt="SXSW March 12, 2012"></a><a class="wrapper" href="http://aerodynamicmusic.com/wordpress/portfolio/sxsw-march-14/" title="SXSW March 14, 2012"><img class="logo" id="sxsw14" src="http://aerodynamicmusic.com/wordpress/wp-content/uploads/2012/05/sxsw14_slider.jpg" alt="SXSW March 14, 2012"></a><a class="wrapper" href="http://aerodynamicmusic.com/wordpress/portfolio/sxsw-march-16/" title="SXSW March 16, 2012"><img class="logo" id="sxsw16" src="http://aerodynamicmusic.com/wordpress/wp-content/uploads/2012/05/sxsw16_slider.jpg" alt="SXSW March 16, 2012"></a><a class="wrapper" href="http://aerodynamicmusic.com/wordpress/portfolio/sxsw-march-17/" title="SXSW March 17, 2012"><img class="logo" id="sxsw17" src="http://aerodynamicmusic.com/wordpress/wp-content/uploads/2012/05/sxsw17_slider.jpg" alt="SXSW March 17, 2012"></a><a class="wrapper" href="http://aerodynamicmusic.com/wordpress/portfolio/sxsw-march-18/" title="SXSW March 18, 2012"><img class="logo" id="sxsw18" src="http://aerodynamicmusic.com/wordpress/wp-content/uploads/2012/05/sxsw18_slider.jpg" alt="SXSW March 18, 2012"></a><a class="wrapper" href="http://aerodynamicmusic.com/wordpress/portfolio/releases1/" title="Men at Work"><img class="logo" id="menatwork" src="http://aerodynamicmusic.com/wordpress/wp-content/uploads/2012/05/men_slider.jpg" alt="Men at Work"></a>
            </div>
                </div>
        </div>


        <script type="text/javascript">
            jQuery(function() {

              //remove js-disabled class
                jQuery("#viewer").removeClass("js-disabled");

              //create new container for images
                jQuery("<div>").attr("id", "container").css({ position:"absolute"}).width(jQuery(".wrapper").length * 170).height(170).appendTo("div#viewer");

                //add images to container
                jQuery(".wrapper").each(function() {
                    jQuery(this).appendTo("div#container");
                });

                //work out duration of anim based on number of images (1 second for each image)
                var duration = jQuery(".wrapper").length * 2000;

                //store speed for later (distance / time)
                var speed = (parseInt(jQuery("div#container").width()) + parseInt(jQuery("div#viewer").width())) / duration;

                //set direction
                var direction = "rtl";

                //set initial position and class based on direction
                (direction == "rtl") ? jQuery("div#container").css("left", jQuery("div#viewer").width()).addClass("rtl") : jQuery("div#container").css("left", 0 - jQuery("div#container").width()).addClass("ltr") ;

                //animator function
                var animator = function(el, time, dir) {

                    //which direction to scroll
                    if(dir == "rtl") {

                      //add direction class
                        el.removeClass("ltr").addClass("rtl");

                        //animate the el
                        el.animate({ left:"-" + el.width() + "px" }, time, "linear", function() {

                            //reset container position
                            jQuery(this).css({ left:jQuery("div#imageScroller").width(), right:"" });

                            //restart animation
                            animator(jQuery(this), duration, "rtl");

                            //hide controls if visible
                            (jQuery("div#controls").length > 0) ? jQuery("div#controls").slideUp("slow").remove() : null ;          

                        });
                    } else {

                      //add direction class
                        el.removeClass("rtl").addClass("ltr");

                        //animate the el
                        el.animate({ left:jQuery("div#viewer").width() + "px" }, time, "linear", function() {

                            //reset container position
                            jQuery(this).css({ left:0 - jQuery("div#container").width() });

                            //restart animation
                            animator(jQuery(this), duration, "ltr");

                            //hide controls if visible
                            (jQuery("div#controls").length > 0) ? jQuery("div#controls").slideUp("slow").remove() : null ;          
                        });
                    }
                }

                //start anim
                animator(jQuery("div#container"), duration, direction);

                //pause on mouseover
                jQuery("a.wrapper").live("mouseover", function() {

                    //stop anim
                    jQuery("div#container").stop(true);

                    //show controls
                    (jQuery("div#controls").length == 0) ? jQuery("<div>").attr("id", "controls").appendTo("div#outerContainer").css({ opacity:0.7 }).slideDown("slow") : null ;
                    (jQuery("a#rtl").length == 0) ? jQuery("<a>").attr({ id:"rtl", href:"#", title:"rtl" }).appendTo("#controls") : null ;
                    (jQuery("a#ltr").length == 0) ? jQuery("<a>").attr({ id:"ltr", href:"#", title:"ltr" }).appendTo("#controls") : null ;

                    //variable to hold trigger element
                    var title = jQuery(this).attr("title");

                    //add p if doesn't exist, update it if it does
                    (jQuery("p#title").length == 0) ? jQuery("<p>").attr("id", "title").text(title).appendTo("div#controls") : jQuery("p#title").text(title) ;
                });

                //restart on mouseout
                jQuery("a.wrapper").live("mouseout", function(e) {

                    //hide controls if not hovering on them
                    (e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? jQuery("div#controls").slideUp("slow").remove() : null ;

                    //work out total travel distance
                    var totalDistance = parseInt(jQuery("div#container").width()) + parseInt(jQuery("div#viewer").width());

                    //work out distance left to travel
                    var distanceLeft = (jQuery("div#container").hasClass("ltr")) ? totalDistance - (parseInt(jQuery("div#container").css("left")) + parseInt(jQuery("div#container").width())) : totalDistance - (parseInt(jQuery("div#viewer").width()) - (parseInt(jQuery("div#container").css("left")))) ;

                    //new duration is distance left / speed)
                    var newDuration = distanceLeft / speed;

                    //restart anim
                    animator(jQuery("div#container"), newDuration, jQuery("div#container").attr("class"));

                });

                //handler for ltr button
                jQuery("#ltr").live("click", function() {

                    //stop anim
                    jQuery("div#container").stop(true);

                    //swap class names
                    jQuery("div#container").removeClass("rtl").addClass("ltr");

                    //work out total travel distance
                    var totalDistance = parseInt(jQuery("div#container").width()) + parseInt(jQuery("div#viewer").width());

                    //work out remaining distance
                    var distanceLeft = totalDistance - (parseInt(jQuery("div#container").css("left")) + parseInt(jQuery("div#container").width()));

                    //new duration is distance left / speed)
                    var newDuration = distanceLeft / speed;

                //restart anim
                animator(jQuery("div#container"), newDuration, "ltr");
            });

            //handler for rtl button
            jQuery("#rtl").live("click", function() {

                //stop anim
                jQuery("div#container").stop(true);

                //swap class names
                jQuery("div#container").removeClass("ltr").addClass("rtl");

                //work out total travel distance
                var totalDistance = parseInt(jQuery("div#container").width()) + parseInt(jQuery("div#viewer").width());

                //work out remaining distance
                var distanceLeft = totalDistance - (parseInt(jQuery("div#viewer").width()) - (parseInt(jQuery("div#container").css("left"))));

                //new duration is distance left / speed)
                var newDuration = distanceLeft / speed;

                //restart anim
                animator(jQuery("div#container"), newDuration, "rtl");
            });
        });
    </script>

任何帮助,将不胜感激。

4

2 回答 2

0

首先,修复你的 JS 错误。将Firebug与 Firefox 一起使用,或者在 Chrome 或 Safari 或 IE8 中使用开发人员工具来查看您的站点上加载了哪些 JS,并使用错误控制台来查找/修复错误。

也修复你的 html 错误:[Invalid] Markup Validation of aerodynamicmusic.com wordpress - W3C Markup Validator。在验证报告中向下滚动以查看行号和源代码。

于 2012-05-17T20:10:44.243 回答
0

在上面的提示旁边,检查您到 video-js/skins - 文件夹的路径。您当前有两个返回 404 的请求,因此您的皮肤(可能是视频滑块的样式表)似乎没有正确加载。当前路径是“http://aerodynamicmusic.com/wp-content/plugins/videojs-pro/video-js/skins/none”,这不是文件的有效路径。

于 2012-08-22T10:13:22.977 回答