jquery自定义转换,如uncover-需要动态设置方向
快速jquery循环问题:jquery自定义转换,如uncover-需要动态设置方向,jquery,cycle,jquery-cycle,Jquery,Cycle,Jquery Cycle,快速jquery循环问题: $.fn.cycle.transitions.uncover = function($cont, $slides, opts) { var d = opts.direction || 'left'; var w = $cont.css('overflow','hidden').width(); var h = $cont.height(); opts.before.push(function(curr, next, opts) {
$.fn.cycle.transitions.uncover = function($cont, $slides, opts) {
var d = opts.direction || 'left';
var w = $cont.css('overflow','hidden').width();
var h = $cont.height();
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonReset(curr,next,opts,true,true,true);
if (d == 'right')
opts.animOut.left = w;
else if (d == 'up')
opts.animOut.top = -h;
else if (d == 'down')
opts.animOut.top = h;
else
opts.animOut.left = -w;
});
opts.animIn.left = 0;
opts.animIn.top = 0;
opts.cssBefore.top = 0;
opts.cssBefore.left = 0;
};
这是jquery周期的转换
我想即时决定效果方向是向上还是向下
如果当前幻灯片是5张中的第2张,我点击页面导航链接到幻灯片1,那么它应该是“向上”。
如果当前幻灯片是5张中的第2张,我单击链接到幻灯片5的页面导航,则方向应为“向下”
从逻辑部分来看,这似乎是通过一个简单的if语句来完成的,但我已经尝试过了,但无法真正完成这项工作
任何提示都将不胜感激
还有一件事:我知道有类似scrollVert的东西,但它不能满足我的需要。我需要以两种方式向上/向下揭示,就像scrollVert的作品一样,但不完全相同
另外,scrollVert是:
$.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) {
$cont.css('overflow','hidden');
opts.before.push(function(curr, next, opts, fwd) {
if (opts.rev)
fwd = !fwd;
$.fn.cycle.commonReset(curr,next,opts);
opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1);
opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH;
});
opts.cssFirst.top = 0;
opts.cssBefore.left = 0;
opts.animIn.top = 0;
opts.animOut.left = 0;
};
我正在尝试更改scrollvert函数,但是在uncover中有一个if d==。。。不知道如何将该条件从Unfold传输到scrollvert您可以确定当前正在显示的幻灯片以及下一个在Unfold转换中使用的幻灯片,如下所示
$.fn.cycle.transitions.uncover = function($cont, $slides, opts) {
var d = opts.direction || 'left';
var w = $cont.css('overflow','hidden').width();
var h = $cont.height();
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonReset(curr,next,opts,true,true,true);
// find index of Current slide
var curIndex = $slides.index(curr) + 1;// as it's 0 based
// find index of Next Slide
var nextIndex = $slides.index(next) + 1;
// now set d based on this two values
if(curIndex == 2 && nextIndex == 1)
d = 'up';
if(curIndex == 2 && nextIndex == 5)
d = 'down';
// add as many condition as you want
if (d == 'right')
opts.animOut.left = w;
else if (d == 'up')
opts.animOut.top = -h;
else if (d == 'down')
opts.animOut.top = h;
else
opts.animOut.left = -w;
});
opts.animIn.left = 0;
opts.animIn.top = 0;
opts.cssBefore.top = 0;
opts.cssBefore.left = 0;
};
我希望您现在可以从上面的代码中找出您想要的内容。如果你不想的话,请告诉我