Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在iPhone上的mobile safari中动画效果不佳_Jquery_Html_Css_Mobile Safari_Jquery Animate - Fatal编程技术网

Jquery 在iPhone上的mobile safari中动画效果不佳

Jquery 在iPhone上的mobile safari中动画效果不佳,jquery,html,css,mobile-safari,jquery-animate,Jquery,Html,Css,Mobile Safari,Jquery Animate,嘿,我正在创建带有垂直选项卡列表的选项卡式内容。 我是通过改变背景位置来实现的。 它在IE/CHROME中运行良好,但在移动设备上浏览safari时, 第一次动画效果很好,其他时候背景位置下降太多 我添加了很多代码,但我认为问题不在于HTML,因为它可以在其他浏览器中使用,我只是发布了代码供参考 这是我的动画代码: <!-- This part is responsible for tabbed content --> var $tabbed_area = jQuery('

嘿,我正在创建带有垂直选项卡列表的选项卡式内容。 我是通过改变背景位置来实现的。 它在IE/CHROME中运行良好,但在移动设备上浏览safari时, 第一次动画效果很好,其他时候背景位置下降太多

我添加了很多代码,但我认为问题不在于HTML,因为它可以在其他浏览器中使用,我只是发布了代码供参考

这是我的动画代码:

<!-- This part is responsible for tabbed content -->

    var $tabbed_area = jQuery('#side-tabs-tab ul'),
        $tab_content = jQuery('.tab-content-tab');





                    if ($tabbed_area.length) {

            var animating = false,
                divAnimated = false;
            jQuery('body.home #main-area-tab').css('backgroundImage','none');
            $tab_content.hide().filter(':first').show();
            $tabbed_area.css( {backgroundPosition: "0px 0px"} );
            var isFirstUse = true;
            $tabbed_area.find('li a').click(function(){
                this_element = jQuery(this);

                tab_order = this_element.parent('li').prevAll().length;
                previouslyActiveTab = jQuery('.tab-content-tab').filter(':visible').prevAll('.tab-content-tab').length;

                if ( (tab_order != previouslyActiveTab) && !animating ) {
                    $tabbed_area.find('li a.activeTab').removeClass('activeTab');
                    var marginDelimeter = 177;


                    if( parseInt(jQuery.browser.version, 10) == 7){
                        marginDelimeter = 177;
                    }

                    activeTop = this_element.position().top - marginDelimeter;
                        if( navigator.userAgent.match(/iPhone/i)){
                        //marginDelimeter = 213;

                        }
                    animating = true;
                    var $visibleDiv = $tab_content.filter(':visible'),
                        $divToAnimate = $tab_content.filter(':eq('+tab_order+')');


                    $visibleDiv.fadeOut(500,function(){
                       $visibleDiv.css({opacity:0});
                       $divToAnimate.css({opacity:1}).fadeIn(500,function(){if (jQuery.browser.msie) this.style.removeAttribute('filter');});
                       divAnimated = true;
                    });

                    $tabbed_area.stop().animate({backgroundPosition:"(0px "+activeTop+"px)"}, 500,function(){
                        this_element.addClass('activeTab');
                        if (divAnimated) { 
                            animating = false;
                            divAnimated = false;
                        } else {
                            var wait = setInterval(function() {
                                if (divAnimated) { 
                                    animating = false;
                                    divAnimated = false;
                                    clearInterval(wait);
                                };
                            }, 100);
                        };
                    });
                };

                return false;
            });
        };
<!-- End of tabbed content -->
有人能告诉我我做错了什么吗


如果你不明白我的意思,你可以现场查看,进入并点击开发服务。

你想使用的是CSS3转换和转换,而不是jQuery动画。通过这种方式,您可以在移动设备(如iOS和Android)上获得硬件加速性能。要移动图元,请使用transform3d(即使是2d变换),这样您将获得最佳性能


您想要使用的是CSS3转换和转换,而不是jQuery动画。通过这种方式,您可以在移动设备(如iOS和Android)上获得硬件加速性能。要移动图元,请使用transform3d(即使是2d变换),这样您将获得最佳性能


您已经硬编码了动画元素的位置。改为使用单击按钮的位置计算结束位置


示例:

您已经硬编码了动画元素的位置。改为使用单击按钮的位置计算结束位置


示例:

这不是答案,shuold是注释,我有理由想使用jQuery而不是CSS3,我不是在寻找最佳性能,我只是不明白代码中的问题。这不是答案,shuold是注释,我有理由想使用jQuery而不是CSS3,我并不是在寻找最佳性能,我只是不明白代码中的问题在哪里。
   <div id="side-tabs-tab">
    <ul style='padding:0px; padding-bottom: 20px;'>
        <?php for ($i = 1; $i <= $featured_num; $i++) { ?>
            <?php if ($arr[$i]["tabtitle"] == '') $arr[$i]["tabtitle"] = 'Tab Custom field'; ?>
            <li class="clearfix"><a href="#" <?php if ($i == 1) echo(' class="activeTab"'); ?>><?php if($arr[$i]["thumb"] <> '') echo('<img src="'.esc_url( $arr[$i]["thumb"] ).'" alt="" width="36" height="37" />'); ?><span><?php echo( esc_html( $arr[$i]["tabtitle"] ) ); ?></span></a></li>
        <?php }; ?>
    </ul>   
</div> <!-- end #side-tabs -->


<div id="main-area-tab">
    <?php for ($i = 1; $i <= $featured_num; $i++) { ?>
        <div class="tab-content-tab<?php if ($i == 1) echo(' active'); ?>">
            <h2 class="title-tab"><?php echo(esc_html($arr[$i]["title"])); ?></h2>
            <?php echo($arr[$i]["content"]); ?>
            <!--<a href="<?php echo esc_url($arr[$i]["permalink"]); ?>" class="readmore-tab"><span><?php esc_html_e('Read More','MyAppTheme'); ?></span></a> -->
        </div> <!-- end .tab-content -->
    <?php }; ?>
</div> <!-- end #main-area -->
   #side-tabs-tab {background:url(images/tabs-shadow-tab.png) no-repeat scroll 116px 0 transparent; float: left; width: 205px; height: 353px; margin-top: -3px; }
    #side-tabs-tab ul {list-style: none; margin-top: 43px; margin-left: 12px; font-size: 16px; background:url(images/arrow-tab.png) no-repeat; padding-bottom: 20px; }
                #side-tabs-tab ul li { margin-bottom: 10px; height: 40px; }
                    #side-tabs-tab ul li a {text-decoration: none; color: #202d37; text-shadow: 1px 1px 0px #e7eff2; display: block}
                        #side-tabs-tab ul li a img {padding-top: 3px; padding-left: 4px; float: left;}
                        #side-tabs-tab ul li a span {padding-left: 14px; float: left; display: block; padding-top: 12px;}
                    #side-tabs-tab ul li a.activeTab  {width: 191px; color: #ffffff; text-shadow: 1px 1px 0px #3a515a; }

        #main-area-tab {float: left; margin-top: 50px; margin-left: 29px; width:483px;} 
            #main-area-tab p { line-height: 18px; }
            #main-area-tab .tab-content-tab {width: 424px;padding-right:45px;}
                #main-area-tab .tab-content-tab h2.title-tab {font-weight: bold; font-size: 20px; margin-bottom: 20px; }
                #main-area-tab .tab-content-tab p.post {line-height: 18px; padding-bottom: 23px; padding-top: 20px;}

                blockquote {background: url(images/blockquote-tab.png) no-repeat; border: none; margin: 0px; padding-left: 55px;line-height: 18px; color: #202d37; text-shadow: 1px 1px 0px #e7ecee; padding-top: 12px; padding-bottom: 22px; background-position: 0px 15px; }

                #main-area-tab a.readmore-tab { background: url(images/readmore-left-tab.png) no-repeat top right; display: block; height: 33px; padding-right: 18px; line-height: 35px; float: right; font-weight: bold; text-shadow: 1px 1px 0px #2d3a40; font-size: 11px; margin-bottom: 26px; margin-right: -36px; float: right; color: #c0cfd5;}
                    #main-area-tab a.readmore-tab span { display: block; background: url(images/readmore-right-tab.png) no-repeat; padding:0 6px 0 13px; height:33px; }