简体   繁体   English

向此推荐滑块添加动画

[英]Adding animation to this testimonial slider

I have created a slider using CSS3 to display my testimonials.. Now I need to add some animation to this slider using Jquery. 我用CSS3创建了一个滑块来显示我的推荐。现在我需要使用Jquery为这个滑块添加一些动画。 But I dont have any idea how to use Jquery with this slider.. and what are the suitable plugin for this. 但我不知道如何使用这个滑块的Jquery ..什么是适合的插件。 So anybody can tell me How can I add an animation to this slider? 所以任何人都可以告诉我如何向这个滑块添加动画?

any ideas are greatly appreciated. 任何想法都非常感谢。

Thank you. 谢谢。

Here is a link to the slider code: jsfiddle.net/XJVYj/82 这是滑块代码的链接:jsfiddle.net/XJVYj/82

I think it will be very hard to find a Plugin that exactly matches your code. 我认为很难找到与您的代码完全匹配的插件。 But I could code you the jQuery stuff for it. 但我可以为你编写jQuery的东西。 But then I would have two Questions. 但后来我会有两个问题。

  1. How much of the CSS can I change? 我可以改变多少CSS? Or should it also still work without js activated? 或者它是否还可以在没有激活js的情况下工作?
  2. Are you staying with a number of 3 items in the future? 你将来会继续使用3件物品吗? Or do you want to change the number of slides dynamically? 或者您想动态更改幻灯片的数量?

// EDIT //编辑

OK it works now. 好的,现在有效。 I know its not very elegant, but I dont wanted to change too much of your code. 我知道它不是很优雅,但我不想改变你的代码太多。 So I just had to edit two of your css selectors (I commented the old one out). 所以我只需编辑你的两个css选择器(我评论了旧的选择器)。 You also wanna notice, that with this solution your old method still works when javascript is disabled. 您还需要注意,使用此解决方案,当禁用javascript时,旧方法仍然有效。 The jQuery Code follows... jQuery代码如下......

$("div.one").css({"left":0, "opacity":1});
$("div.two").css({"left":300, "opacity":1});
$("div.three").css({"left":600, "opacity":1});

$("input#first").click(function(){
    $("div.one").animate({left:0},600);
    $("div.two").animate({left:300},600);
    $("div.three").animate({left:600},600);
});

$("input#second").click(function(){
    $("div.one").animate({left:-300},600);
    $("div.two").animate({left:0},600);
    $("div.three").animate({left:300},600);
});

$("input#third").click(function(){
    $("div.one").animate({left:-600},600);
    $("div.two").animate({left:-300},600);
    $("div.three").animate({left:0},600);
});​

jsfiddle.net/mYhEV/2/ jsfiddle.net/mYhEV/2/

Hope it helps. 希望能帮助到你。

PS: For a cleaner solution you would have to rethink a bit. PS:为了更清洁的解决方案,你必须重新考虑一下。 One method would be to put all the sliders in a wrapper and just moving this wrapper instead of moving. 一种方法是将所有滑块放在一个包装器中,然后移动这个包装器而不是移动。

There is documentation literally right in the script file which has options you can use: 脚本文件中有文档,可以使用以下选项:

$.tiny.carousel = {
        options: {  
            start: 1, // where should the carousel start?
            display: 1, // how many blocks do you want to move at 1 time?
            axis: 'x', // vertical or horizontal scroller? ( x || y ).
            controls: true, // show left and right navigation buttons.
            pager: false, // is there a page number navigation present?
            interval: false, // move to another block on intervals.
            intervaltime: 3000, // interval time in milliseconds.
            rewind: false, // If interval is true and rewind is true it will play in reverse if the last slide is reached.
            animation: true, // false is instant, true is animate.
            duration: 1000, // how fast must the animation move in ms?
            callback: null // function that executes after every move.
        }
    };

Secifcally: animation: true, // false is instant, true is animate . Secifcally: animation: true, // false is instant, true is animate

Try setting the animation to true when you call the slider on your element (you provided no script code so I can't edit it for you.) 在元素上调用滑块时尝试将动画设置为true(您没有提供脚本代码,因此我无法为您编辑它。)

$('YOUR_SLIDERr').tinycarousel({ animation: true });​

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

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