微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

多个滑块的背景检查

如何解决多个滑块的背景检查

我想对滑块中的图像进行背景检查,以便对控件的颜色进行自适应更改。

我使用一个简单的滑块脚本在一个页面上有多个滑块并尝试使用 https://github.com/kennethcachia/Background-Check

现在,该页面上的示例是针对单个滑块的,我认为该脚本不起作用,因为检查了所有图像。我想我只需要在这个 (.this) 滑块中检查类名或图像。如何仅在特定滑块中检查类?

jQuery(document).ready(function($) {
    $('.simple-slider-wrapper').each(function() {
        const this_slider = $(this);
       
        const slides = this_slider.find('ul li');
        const control_prev = this_slider.find('.control_prev');
        const control_next = this_slider.find('.control_next');

        function slider_init() {
            if (slides.length > 1) {
                control_prev.css('display','block');
                control_next.css("display","block");
            }
            
        }
        slider_init();

        
        function backgroundcheck_init() {
            BackgroundCheck.init({
              targets: '.control',//< this slider?
              images: 'images'      //< this images?
            });
        }
        //backgroundcheck_init();

        
        function moveRight() {
            // move last child to beginning of list and set list position to -100%
            this_slider.find('ul li:last-child').prependTo(this_slider.find('ul'));
            slides.css('left','-100%');
            // move all list elements to right
            slides.stop().animate({ left: 0 },500);
        };

        function moveLeft() {
            // move all list elements to left
            const arr = [ slides.stop().animate({ left: '-100%' },500).promise() ]
            // after animation end move first child to end of list and set list position to 0
            $.when.apply($,arr).then(function() {
                this_slider.find('ul li:first-child').appendTo(this_slider.find('ul'));
                slides.css('left',0);
            });
        };

        control_prev.on("click",function () {
            if (slides.length > 1) {
                moveRight();
                //< place for BackgroundCheckRefresh
            }
        });

        control_next.on("click",function () {
            if (slides.length > 1) {
                moveLeft();
                //< place for BackgroundCheckRefresh
            }
        });
    });

});

与此同时,我将使用 mix-blend-mode,但对叠加控件进行更多控制仍然很有趣。我什至可以使用一些额外的类来处理这个

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。