简体   繁体   English

EasySlider 1.7-当vertical = true和continuous = true时为空白面

[英]EasySlider 1.7 - blank side when vertical=true and continuous=true

www.natebarnes.com is my site. www.natebarnes.com是我的网站。 I have my slider set to scroll vertically, to come out from behind the horizon graphic at the bottom of the screen. 我将滑块设置为垂直滚动,以从屏幕底部的地平线图形后面出来。

When setting easyslider to scroll vertical and cycle contniuosly, it seems to be inserting a blank slide or something. 将easyslider设置为垂直滚动并连续循环时,似乎正在插入空白幻灯片或其他内容。 It seems to be a common complaint on the 1.7 comment thread, however I've not found an answer for it. 在1.7注释线程上,这似乎是一个普遍的抱怨,但是我还没有找到答案。 Any help would be a great relief. 任何帮助将是一个极大的缓解。 Thanks in advance! 提前致谢!

If you use transparent images(gif or png), instead of matt's block of code 如果您使用透明图像(gif或png),而不是matt的代码块

if(options.continuous && !options.vertical){
    $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px"));
    $("ul", obj).append($("ul li:nth-child(2)", obj).clone());
    $("ul", obj).css('width',(s+1)*w);
} else if(options.continuous && options.vertical) {
    $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-bottom","-"+ h +"px"));
    $("ul", obj).append($("ul li:nth-child(2)", obj).clone());
    $("ul", obj).css('height',(s+1)*h);
};

use this one 用这个

if(options.continuous && !options.vertical){
    $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px"));
    $("ul", obj).append($("ul li:nth-child(2)", obj).clone());
    $("ul", obj).css('width',(s+1)*w);
} else if(options.continuous && options.vertical) {                 
    $("ul", obj).prepend($("ul li:first-child", obj).clone().css("margin-bottom","-"+ h +"px"));
    $("ul", obj).append($("ul li:nth-child(2)", obj).clone());
    $("ul", obj).css('height',(s+1)*h);                
};

In this way last image won't be positioned below first one. 这样,最后一张图片将不会位于第一张图片的下方。

I ran into this same problem this morning and started Googling for answers... I didn't find any, so I dove into the code myself. 今天早上,我遇到了同样的问题,并开始使用Google搜索以寻找答案……我没有找到任何答案,所以我自己研究了代码。 I found an answer and I saw your question here so I thought I'd share. 我找到了答案,并且在这里看到了您的问题,所以我想与您分享。 Please keep in mind that I am not the best Javascript coder ever, so there might be a more elegant solution than this, but it worked for me, so it might work for you. 请记住,我不是有史以来最好的Javascript编码器,因此可能会有比这更好的解决方案,但是它对我有用,所以对您来说可能有用。 Here's what I changed - I've left out line numbers because, well, obviously, as you tweak the file, they will change. 这就是我更改的内容-我省略了行号,因为很明显,当您调整文件时,它们会更改。

First, you'll see this: 首先,您将看到以下内容:

$("ul", obj).css('width',s*w);

It sets the width but, when it's vertical, you need to set the height. 它设置宽度,但是在垂直时,您需要设置高度。 I changed it to this: 我将其更改为:

    if(!options.vertical) {
        $("ul", obj).css('width',s*w);
    } else {
        $("ul", obj).css('height',s*h);
    };

Now, if it's vertical you want, it sets a proper height. 现在,如果您想要的是垂直的,它会设置适当的高度。 Second, there is this: 其次,是这样的:

    if(options.continuous){
        $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px"));
        $("ul", obj).append($("ul li:nth-child(2)", obj).clone());
        $("ul", obj).css('width',(s+1)*w);
    }

I believe this is what causes the problem - It's appending the slide, but assuming you are moving horizontally. 我相信这就是导致问题的原因-它是在附加幻灯片,但假设您水平移动。 I believe the "blank slide" you and I saw is there... it's just one slide-width to the right, so we can't see it. 我相信您和我看到的“空白幻灯片”都在那儿……它只是右侧的一个幻灯片宽度,所以我们看不到它。 I added code in case both vertical and continuous are true to instead append it to the bottom: 我添加了代码,以防垂直和连续都适用,而是将其追加到底部:

    if(options.continuous && !options.vertical){
        $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px"));
        $("ul", obj).append($("ul li:nth-child(2)", obj).clone());
        $("ul", obj).css('width',(s+1)*w);
    } else if(options.continuous && options.vertical) {
        $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-bottom","-"+ h +"px"));
        $("ul", obj).append($("ul li:nth-child(2)", obj).clone());
        $("ul", obj).css('height',(s+1)*h);
    };

Essentially, it appends the slide to the bottom instead of the side. 本质上,它将幻灯片附加到底部而不是侧面。 Now, I was also getting a weird push to my slides - each time the next came up, it would move to the left a little, until the slides were off the screen. 现在,我也被怪异地推到了幻灯片上-每次下一张幻灯片出现时,它都会向左移动一点,直到幻灯片离开屏幕为止。 That problem came up here: 这个问题出现在这里:

    if(!options.vertical) {
            $("ul",obj).css("margin-left",(t*w*-1));
        } else {
            $("ul",obj).css("margin-left",(t*h*-1));
        }

Everything appears right, except the second margin-left should just be margin-top instead: 一切看起来都正确,除了左边第二个margin应当位于margin-top之外:

    if(!options.vertical) {
            $("ul",obj).css("margin-left",(t*w*-1));
        } else {
            $("ul",obj).css("margin-top",(t*h*-1));
        }

Once I made all those changes, the slider when vert=true && continuous=true worked fine. 完成所有这些更改后,当vert = true && Continuous = true时的滑块工作正常。 I also used the modified script on another page where I wanted vert=false and cont=true and it worked fine there, too, so it doesn't appear there were any side effects to these changes. 我还在另一页上使用了经过修改的脚本,在该页上我想要vert = false和cont = true,并且在那儿也能正常工作,因此这些更改没有出现任何副作用。

Hope it helps! 希望能帮助到你!

@vseMatt Also don't forget to add @vseMatt也不要忘记添加

if(options.vertical) {
    $("li", obj).css('float','none');
    $("li", obj).css('display','block');
}

This is needed when you use vertical slider in IE9. 在IE9中使用垂直滑块时,这是必需的。 Without this, It consumed a whole day :/. 没有这个,它消耗了整整一天的时间:/。 Finally figured it out. 终于想通了。

is because of the width / height of the slides. 是因为幻灯片的宽度/高度。 Make sure all are the same exactly size and also make the #slider to be the same width / height. 确保所有尺寸都完全相同,并且#slider的宽度/高度都相同。 Please let us know if this was the issue. 如果这是问题,请告诉我们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM