最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jquery cycle slideshow - adding slide prevnext progression (a la scrollHorz) along with custom animation - Stack Ov

programmeradmin1浏览0评论

I am using the jquery cycle plugin with a custom animation. It is working great!

However, I would like the slides to advance to the right or left depending upon the index#, i.e. if the user clicks on link 1 while slide #3 is the active slide the animation will transition out to the right, while if link 4 was clicked on the slide would transition to the left.

The functionality I'm looking for is the same as the scrollHorz/scrollVert transitions.

I understand that what I need is some logic to relate the current frame and the next frame: if (frameclicked on is a higher index than the current slide) {animate to the left} else {animate to the right}

I just don't know where to put it in the code. I hope that makes sense. Any help would be greatly appreciated! Thanks!

Not that it probably helps, but my custom code is below.

$('#s4').before('<div id="nav" class="nav">').cycle({
    fx:     'custom',

    cssBefore:{
            left:1000,
            opacity:0,
            display:'block'
        },
    animIn:{
            left:0,
            opacity:100
        },
    animOut:{
            left:-1000,
            opacity:0
        },
    cssAfter:{
            display:'none'
        },
    speed:  'slow',
    easeIn: 'easeInExpo',
    easeOut: 'easeInExpo',
    next: '.nextnav',
    prev: '.previous',
    timeout: 0,
    containerResize: 1,
    fit: 0,
    height: 600,
    pager: '#slideshow-nav',
    pagerAnchorBuilder: function(idx, slide) {
            return '#slideshow-nav li:eq(' + (idx) + ')';
        }

});

I am using the jquery cycle plugin with a custom animation. It is working great!

However, I would like the slides to advance to the right or left depending upon the index#, i.e. if the user clicks on link 1 while slide #3 is the active slide the animation will transition out to the right, while if link 4 was clicked on the slide would transition to the left.

The functionality I'm looking for is the same as the scrollHorz/scrollVert transitions.

I understand that what I need is some logic to relate the current frame and the next frame: if (frameclicked on is a higher index than the current slide) {animate to the left} else {animate to the right}

I just don't know where to put it in the code. I hope that makes sense. Any help would be greatly appreciated! Thanks!

Not that it probably helps, but my custom code is below.

$('#s4').before('<div id="nav" class="nav">').cycle({
    fx:     'custom',

    cssBefore:{
            left:1000,
            opacity:0,
            display:'block'
        },
    animIn:{
            left:0,
            opacity:100
        },
    animOut:{
            left:-1000,
            opacity:0
        },
    cssAfter:{
            display:'none'
        },
    speed:  'slow',
    easeIn: 'easeInExpo',
    easeOut: 'easeInExpo',
    next: '.nextnav',
    prev: '.previous',
    timeout: 0,
    containerResize: 1,
    fit: 0,
    height: 600,
    pager: '#slideshow-nav',
    pagerAnchorBuilder: function(idx, slide) {
            return '#slideshow-nav li:eq(' + (idx) + ')';
        }

});
Share Improve this question edited Sep 26, 2012 at 2:33 Eli 14.8k5 gold badges61 silver badges77 bronze badges asked Apr 17, 2011 at 20:13 JackrabbitrocksJackrabbitrocks 631 silver badge7 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

You need to hook into to onPrevNextEvent. They have something called isnext wich gets passed wich basically tells you which direction you are going in.

Example I updated a fiddle I whipped up yesterday for cycle.

http://jsfiddle/gx3YE/12/

$(function() {

$('#megaWrapper').cycle({
    next : "#next",
    prev : "#prev",
    timeout : 0,
    onPrevNextEvent: function(is,i,el) {
        if (is === true) {
            alert('slide right');
        }
        else {
            alert('slide left'); 
        }
    }

}); 

});

Isn't what you're describing part of Cycle's core functionality?

Here's how I do it:

$('.slideshow').cycle({
    fx: 'scrollHorz',
    timeout: 0,
    next:   '#next', 
    prev:   '#prev'     
}); 

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论