html5+jQuery图片和文字内容同时左右切换特效【原创

来源:https://www.sucaihuo.com/js/3629.html 2018-04-18 16:41浏览(2150) 收藏

html5+jQuery图片和文字内容同时左右切换特效,点击图片或者点击左右按钮进行切换,图片转动以及文字内容动画效果切换。
html5+jQuery图片和文字内容同时左右切换特效
分类:图片代码 > 按钮控制 难易:高级
查看演示 下载资源 下载积分: 20 积分

js代码

<script type="text/javascript">

            (function(){
                var bannerIndex = 0;
                var $bannerBgs = $('.js_banner-bg');
                var $bannerNotifications = $('.js_banner-notification');
                function changeTopBanner(index) {
                    $bannerBgs.removeClass('mui-enter-active');
                    $($bannerBgs[index]).addClass('mui-enter-active');

                    $bannerNotifications.removeClass('mui-enter-active');
                    $($bannerNotifications[index]).addClass('mui-enter-active');
                }

                setInterval(function(){
                    if (bannerIndex < 2) {
                        bannerIndex++;
                        changeTopBanner(bannerIndex);
                    } else {
                        bannerIndex = 0;
                        changeTopBanner(bannerIndex);
                    }
                }, 6000);

                // Function
                var functionIndex = 1;
                function presentScreen(index) {
                    $('.carousel').removeClass(
                        'present-screen-1 present-screen-2 present-screen-3'
                    ).addClass(`present-screen-${functionIndex}`);
                }

                var $titles = $('.js_function-text .title');
                var $descs = $('.js_function-text .desc');
                function presentText(index) {
                    index = index - 1;
                    $titles.removeClass('mui-enter-active');
                    $($titles[index]).addClass('mui-enter-active');
                    $descs.removeClass('mui-enter-active');
                    $($descs[index]).addClass('mui-enter-active');
                }

                var $functionScreens = $('.carousel .function-screen');
                for (var i = 0; i < $functionScreens.length; i++) {
                    (function (i) {
                        $($functionScreens[i]).click(function(){
                            functionIndex = i + 1;
                            presentScreen(functionIndex);
                            presentText(functionIndex);
                        })
                    })(i);
                }
                $('#js_function-orbit-prev').click(function(){
                    functionIndex > 1 ? functionIndex-- : functionIndex = 3;
                    presentScreen(functionIndex);
                    presentText(functionIndex);
                });
                $('#js_function-orbit-next').click(function(){
                    functionIndex < 3 ? functionIndex++ : functionIndex = 1;
                    presentScreen(functionIndex);
                    presentText(functionIndex);
                });

                var newsOrbit = new Foundation.Orbit($('#js_news-thumbnail'));


            })()
   
        </script>
声明:本文为原创文章,如需转载,请注明来源sucaihuo.com并保留原文链接:https://www.sucaihuo.com/js/3629.html
评论0
头像

系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791

1 2