简体   繁体   English

向上和向下滑动以获得革命滑块

[英]Swipe up and down for Revolution Slider

I am using Revolution Slider for a WordPress site - I need be able to vertically swipe through the slides in the slider.我正在为 WordPress 网站使用 Revolution Slider - 我需要能够垂直滑动滑块中的幻灯片。 Currently, only horizontal swiping works.目前,只有水平滑动有效。 I was able to get the slider to respond to vertical mouse scrolls with the provided API but vertical swiping is not working.我能够使用提供的 API 使滑块响应垂直鼠标滚动,但垂直滑动不起作用。

I'm using this for the mouse scrolls and it's working fine:我将它用于鼠标滚动,并且工作正常:

(function() {

    // change "revapi1" here to whatever API name your slider uses (see notes below)
    var slider = revapi2;

    slider.parent().on('mousewheel DOMMouseScroll', function(event) {

        if(event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) {

            slider.revprev();

        }
        else {

            slider.revnext();

        }

    });

RE Vertica Swiping I found some code here : How to swipe top down JQuery mobile RE Vertica Swiping 我在这里找到了一些代码How to swipe top down JQuery mobile

but I'm not sure where to go from there or if it's even what I'm looking for.但我不确定从那里去哪里,或者它是否是我正在寻找的。
so far i have:到目前为止,我有:

swipe down for next slide:向下滑动查看下一张幻灯片:

(function() {
    var slider = revapi2;

slider.parent().on('swipedown', function(event) {
slider.revnext();
});

})()

swipe up for previous slide:向上滑动上一张幻灯片:

(function() {
    var slider = revapi2;

slider.parent().on('swipeup', function(event) {
slider.revprev();
});

})()

nothing is working - I'm pretty new to this stuff, so if you can point out where I'm going wrong too, that would be much appreciated.没有任何效果 - 我对这个东西很陌生,所以如果你也能指出我哪里出错了,那将不胜感激。

Thanks谢谢

I figured it out.我想到了。

Very simple, actually.其实很简单。 I just edited the plugins Js files found here:我刚刚编辑了在这里找到的插件 Js 文件:

revslider\\rs-plugin\\js revslider\\rs-plugin\\js

jquery.themepunch.revolution.min jquery.themepunch.revolution.min

and

jquery.themepunch.revolution jquery.themepunch.revolution

I found the "swipe functions" and replaced "left" with "up" and "right" with "down"我找到了“滑动功能”并将“左”替换为“上”,将“右”替换为“下”

////////////////////////////
        // SET THE SWIPE FUNCTION //
        ////////////////////////////
        var swipeAction = function(container,opt) {
            // TOUCH ENABLED SCROLL
                var aps = "vertical";

                if (opt.touchenabled=="on") {
                            if (opt.drag_block_vertical == true) 
                                aps = "none";

                            container.swipe({

                                fingers:opt.swipe_min_touches,                              
                                treshold:opt.swipe_treshold,                                
                                swipe:function(event,direction,distance,duration,fingerCount,fingerData) {
                                    switch (direction) {
                                        case "up":
                                             if (opt.transition==0) {
                                                                opt.next = opt.next+1;
                                                                if (opt.next == opt.slideamount) opt.next=0;
                                                                callingNewSlide(opt,container);
                                                        }
                                        break;
                                        case "down":
                                            if (opt.transition==0) {
                                                                opt.next = opt.next-1;
                                                                opt.downarrowpressed=1;
                                                                if (opt.next < 0) opt.next=opt.slideamount-1;
                                                                callingNewSlide(opt,container);

Works like a dream!像梦一样工作!

perfect solution!完美解决! I would recommend to contact us also via http://themepunch.com/support-center and ask for an "out of box" solution, so you can keep your version always up to date with the latest version, and have the option available without the needs to add this change in the script directly every time you update.我建议您也通过http://themepunch.com/support-center与我们联系并寻求“开箱即用”的解决方案,这样您就可以使您的版本始终保持最新版本,并提供可用选项无需每次更新时直接在脚本中添加此更改。

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

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