zoukankan      html  css  js  c++  java
  • 摩天轮旋转轮播

            var item = $('.p02-1-s1 .tab > li');
            item.click(function() {
                $(this)
                    .addClass('current')
                    .siblings()
                    .removeClass('current');
                item.find('li').removeClass('active');
            });
            item.find('li').click(function(event) {
                event.stopPropagation();
                item.find('li').removeClass('active');
                $(this).addClass('active');
                item.removeClass('current');
                $(this).parents('li').addClass('current');
            });
            var item2 = $('.p02-1-s2 .tab > li');

            item2.click(function() {
                item2.removeClass('current');
                var clickIndex = $(this)
                    .addClass('current')
                    .index();
                $('.p02-1-s2 .text-slider > li')
                    .removeClass('active')
                    .eq(clickIndex)
                    .addClass('active');
            });
            var getDirection = (function() {
                var mark = 'back';
                return function(activeIndex, prevIndex) {
                    var direction = activeIndex > prevIndex ? 'forward' : 'back';
                    // 修正运动方向
                    if ((prevIndex === 0 && activeIndex === 3) || (prevIndex === 3 && activeIndex === 0)) {
                        direction = mark === 'back' ? 'back' : 'forward';
                    }
                    return (mark = direction);
                };
            })();
            var initStyles = (function() {
                var count = 0;
                var translates = ['translate(50%, -50%)','translate(-50%, -50%)','translate(-50%, -50%)','translate(-50%, 50%)'];
                return function(activeIndex, prevIndex) {
                    var direction = getDirection(activeIndex, prevIndex);
                    var deviation = $(window).width() > 1366 ? 0 : 1;
                    var deg, cssRotate, transition;
                    count += direction === 'forward' && activeIndex === 0 ? 1 : direction === 'back' && activeIndex === 3 ? -1 : 0;
                    deg = (activeIndex + deviation) * 90 + count * 360;
                    cssRotate = ' rotate(' + -deg + 'deg) ';
                    transition = 'all .5s ease-in-out 0s';
                    $('.p02-1-s4 .box').css({
                            transform: 'rotate(' + deg + 'deg)',
                            transition: transition
                        }).children('img').css({
                            transform: cssRotate,
                            transition: transition
                        }).parent().find('li').each(function(index) {
                            this.style = 'transform:' + translates[index] + cssRotate + ';transition:' + transition;
                            this.className = index === activeIndex ? 'current' : '';
                        });
                };
            })();
            initStyles(0, 3);
            $(window).resize(function () {
                initStyles(0, 3);
            });
            var s4 = new Swiper('#s4', {
                watchOverflow: true,
                navigation: {
                    prevEl: '.p02-1-s4 .prev',
                    nextEl: '.p02-1-s4 .next'
                },
                on: {
                    slideChange: function() {
                        if ($(window).width() > 768) {
                            initStyles(this.activeIndex, this.previousIndex);
                        }
                        $('.p02-1-s4 .mobile-icon li').eq(this.activeIndex).addClass('current').siblings().removeClass('current');
                    }
                }
            });

            $('.p02-1-s4 .tab li').click(function() {
                s4.slideTo($(this).index(), 200, false);
                $(this)
                    .addClass('current')
                    .siblings()
                    .removeClass('current');
            });
            $('.p02-1-s4 .mobile-icon li').click(function() {
                s4.slideTo($(this).index(), 200, false);
                $(this)
                    .addClass('current')
                    .siblings()
                    .removeClass('current');
            });
  • 相关阅读:
    lms框架服务注册中心
    lms框架应用服务接口和服务条目详解
    lms框架模块详解
    lms微服务框架主机介绍
    lms框架分布式事务使用简介
    MySQL锁总结
    VSCode 输出 java SSL 请求过程
    PowerShell自动化发布SpringBoot项目到Tomcat
    AWS EC2 使用---安装Docker和Nginx
    使用PowerShell连接到Linux
  • 原文地址:https://www.cnblogs.com/gduf/p/12092651.html
Copyright © 2011-2022 走看看