简体   繁体   English

在Vegas滑块中为上一张和下一张幻灯片添加按钮

[英]Adding buttons for previous and next slide in Vegas slider

I have very simple slider created with Vegas Slideshow. 我有使用Vegas Slideshow创建的非常简单的滑块。 Now I'm trying to add simple Prev/Next buttons. 现在,我尝试添加简单的上一个/下一个按钮。 This is the slider 这是滑块

    <div class="slide-caption"></div>


    <script src="/assets/js/jquery-3.4.0.min.js"></script>
    <script src="/assets/js/vegas.min.js"></script>
    <script>
        $(".slider-wrapper").vegas({
            slides: [
                { src: "/assets/images/slide-1.jpg", text: "Deployment" },
                { src: "/assets/images/slide-1.jpg", text: "Deployment" },
            ],
            walk: function (index, slideSettings) {
                $('.slide-caption').html(slideSettings.text);
            }
        });
    </script>

This works perfectly. 这很完美。 It is showing the image and the caption bellow. 它显示图像和标题如下。

Now I've tried to add this for the buttons but nothing is appeared on page. 现在,我尝试为按钮添加此内容,但页面上没有任何内容。 There is no errors in console. 控制台中没有错误。 I'm not sure also if I need to add the HTML for the buttons or it is pull them from the JS and CSS of the Vegas 我也不确定是否需要为按钮添加HTML,或者是否从Vegas的JS和CSS中提取按钮

    <script>
        $(".slider-wrapper").vegas({
            slides: [
                { src: "/assets/images/slide-1.jpg", text: "Deployment" },
                { src: "/assets/images/slide-1.jpg", text: "Deployment" },
            ],
            walk: function (index, slideSettings) {
                $('.slide-caption').html(slideSettings.text);
            }
        });

         // buttons
        $('a#previous').on('click', function () {
        $elmt.vegas('options', 'transition', 'slideRight2').vegas('previous');
        });

        $('a#next').on('click', function () {
            $elmt.vegas('options', 'transition', 'slideLeft2').vegas('next');
        });
    </script>

Anyone know how exactly I can add the buttons? 有人知道我该如何添加按钮吗?

I haven't tested this, but it may get you heading in the right direction... 我尚未对此进行测试,但它可能使您朝着正确的方向前进...

HTML...
<div id="previous" class="button"></div>
<div id="next" class="button"></div>


JQUERY...
    <script>
    $("#previous").click( function() {
$elmt.vegas('options', 'transition', 'slideRight2').vegas('previous');
});

$("#next").click( function() {
$elmt.vegas('options', 'transition', 'slideRight2').vegas('next');
});

</script>       
CSS...
.button {
display: block;
height: 100px;
width: 100px;
background-color: purple;
 }

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

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