简体   繁体   English

如何实现SlitSlider jQuery插件

[英]How to implement SlitSlider jQuery plugin

I am trying to implement the SlitSlider carousel but there is a serious lack of documentation, and therefore I am having trouble. 我正在尝试实现SlitSlider轮播,但是严重缺乏文档,因此遇到了麻烦。

Has anyone succesfuly used this? 有没有人成功使用过这个? I keep getting TypeError: self._init is not a function 我不断收到TypeError: self._init is not a function

The code can be found on gitub 可以在gitub上找到该代码

My code so far: 到目前为止,我的代码:

function initiate() {
        var $slider = $('ul.slider');

        $slider.slitslider({
            autoplay: true,
            interval: 1000
        });
} 

initiate();

I've just implemented this slider on my website and struggled with getting it to work. 我刚刚在我的网站上实现了此滑块,并努力使其正常运行。 Without seeing your full code it's difficult to say why it's not working for you. 没有看到完整的代码,很难说为什么它对您不起作用。 But I do believe the script needs to be called on the page very specifically like so: 但我确实认为需要在页面上非常具体地调用脚本,如下所示:

S(document.ready(function(){
    var loaded = false;        
    $(window).on('load resize',function(){
        loaded = true;            
        var Page = (function() {
            slitslider = $('ul.slider').slitslider({
                autoplay: true,
                interval: 1000
                }
            }),
            init = function(){
                initEvents();
            },
            initEvents = function(){
                // add your custom navigation events here
            };
            return {init:init};
        }) ();
        Page.init();
    });
});

I included the $(window).on('load resize') function to prevent the slitslider CSS elements from FOUC. 我包含了$(window).on('load resize')函数,以防止slotslider CSS元素出现在FOUC中。 Hope this helps! 希望这可以帮助!

Here's my site with the fullscreen slitslider fully implemented: http://www.estherlee.co 这是我的网站,其中全屏切缝滑块已完全实现: http : //www.estherlee.co

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

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