隐藏投资组合部分后重新初始化MixItUp

时间:2016-12-01 06:20:46

标签: javascript jquery html css mixitup

<div class="col-sm-3">
    <div class="sidebar-nav">
        <div class="navbar navbar-default avbar-fixed-top" role="navigation">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <span class="visible-xs navbar-brand">Sidebar menu</span>
            </div>
            <div class="navbar-collapse collapse sidebar-navbar-collapse">
                <ul class="nav navbar-nav">
                    <img id="logo" src="assets/img/logo.jpg"/> 
                    <li class="active home"><a href="#">Home</a></li>
                    <li><a href="#">About</a></li>
                    <li class="filter" data-filter=".category-1"><a href="#">Animation</a></li>
                    <li class="filter" data-filter=".category-2"><a href="#">Commercial</a></li>
                    <li class="filter" data-filter=".category-3"><a href="#">Documentary</a></li>
                    <li class="filter" data-filter=".category-4"><a href="#">Film</a></li>
                    <li class="filter" data-filter=".category-5"><a href="#">Music</a></li>
                    <li class="filter" data-filter=".category-6"><a href="#">Video Games</a></li>
                    <li><a href="#">Services</a></li>
                </ul>
            </div><!--/.nav-collapse -->
        </div>
    </div>
</div>

<div class="col-sm-5 col-sm-offset-4 text-center">
    <ul id="descBars">
        <li>Something About Elliot</li>
        <li>Something About Elliot</li> 
        <li>Something About Elliot</li> 
        <li>Something About Elliot</li> 
    </ul>
</div>

<div class="col-sm-8 col-sm-push-1">
    <div id="portfolio">
        <div class="pContainer">
            <div class="col-md-3 col-xs-6 thumb mix category-1">
                <a class="thumbnail" href="#">
                    <img class="img-responsive" src="http://placehold.it/400x400" alt="">
                </a>
            </div>
            <div class="col-md-3 col-xs-6 thumb mix category-2">
                <a class="thumbnail" href="#">
                    <img class="img-responsive" src="http://placehold.it/400x400" alt="">
                </a>
            </div>
            <div class="col-md-3 col-xs-6 thumb mix category-3">
                <a class="thumbnail" href="#">
                    <img class="img-responsive" src="http://placehold.it/400x400" alt="">
                </a>
            </div>
            <div class="col-md-3 col-xs-6 thumb mix category-4">
                <a class="thumbnail" href="#">
                    <img class="img-responsive" src="http://placehold.it/400x400" alt="">
                </a>
            </div>
            <div class="col-md-3 col-xs-6 thumb mix category-5">
                <a class="thumbnail" href="#">
                    <img class="img-responsive" src="http://placehold.it/400x400" alt="">
                </a>
            </div>
            <div class="col-md-3 col-xs-6 thumb mix category-6">
                <a class="thumbnail" href="#">
                    <img class="img-responsive" src="http://placehold.it/400x400" alt="">
                </a>
            </div>
            <div class="col-md-3 col-xs-6 thumb mix category-1">
                <a class="thumbnail" href="#">
                    <img class="img-responsive" src="http://placehold.it/400x400" alt="">
                </a>
            </div>
            <div class="col-md-3 col-xs-6 thumb mix category-2">
                <a class="thumbnail" href="#">
                    <img class="img-responsive" src="http://placehold.it/400x400" alt="">
                </a>
            </div>
        </div>
    </div>
</div>

<video playsinline autoplay muted loop poster="polina.jpg" id="bgvid">
    <!--<source src="polina.webm" type="video/webm">-->
    <source src="assets/videos/video.mp4" type="video/mp4">
</video>

<footer class="navbar navbar-fixed-bottom"> 
    <div class="footer-container container-fluid">
        <div class="social-links">
            <a href="#"><i class="fa fa-facebook fa-lg"></i></a>
            <a href="#"><i class="fa fa-twitter fa-lg"></i></a>
            <a href="#"><i class="fa fa-google-plus fa-lg"></i></a>
            <a href="#"><i class="fa fa-pinterest fa-lg"></i></a>
        </div>
    </div>  
</footer>

<!-- /.container -->

<!-- jQuery Version 1.11.1 -->
<script src="js/jquery.js"></script>

<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<script src="http://cdn.jsdelivr.net/jquery.mixitup/latest/jquery.mixitup.min.js"></script>

<script>
    $(function(){
        category = "";
        homeVisible = true;

        $( ".filter" ).click(function() {
            category = $( ".filter" ).data( "filter");

            $('#descBars').fadeOut('slow').promise().done(function() {

                $('#portfolio').mixItUp({
                    load: {
                        filter: category
                    }
                });

                homeVisible = false;
            });
        });

        $( ".home" ).click(function() {
            if (homeVisible == false){

                homeVisible = true;

                $('#portfolio').fadeOut('slow').promise().done(function() {
                    $( "#descBars" ).fadeIn( "slow", function() {
                    });
                });
            }
        });
    });
</script>

我正在开发一个只能一次显示某些部分的单页网站。单击具有li类的filter时,并根据元素的加载类别初始化MixItUp。在此之前,ID为div的{​​{1}}已淡出。问题是,当用户点击回家时,我可以让descBars重新开始,但MixItUp在此之后停止工作,不确定如何重新初始化它,或者是否有更好的方法来实现我想要做的事情。

0 个答案:

没有答案