2

更新:我设置了一个小提琴,它似乎工作正常 - 第一次滑入的部分包含谷歌地图 - 我想知道这是否真的是问题......

我最近在我正在开发的 HTML5 应用程序中添加了一个 -webkit-transform 卡片翻转功能。这具有使水平移动的简单旋转木马表现出一些奇怪行为的不幸效果。

我的轮播结构是这样的

<div id="wrapper">
    <div id="sections">
        <section id="startPage" class="page">
            <div id="card">
                <div class="face front">
                    <p>Some content here</p>
                    <button id="flipFront">A label</button>
                </div>
                <div class="face back">
                    <p>Some content here</p>
                    <button id="flipBack">A label</button>
                </div>
            </div>
        </section>
        <section></section>
        <section></section>
    </div>
</div>

我的 jQuery .click() 循环通过它的行为是这样的:

$('#sections').stop().animate({"left": -($('#someDiv').position().left)}, 500);

这绝对没问题,直到我为卡片翻转添加 -webkit-transform CSS:

#startPage {
    -webkit-perspective: 1000;
}

#card {
    height: 940px;
    width: 640px; 
    -webkit-transform-style: preserve-3d;
    -webkit-transition: 0.5s;
}

.back {
    -webkit-transform: rotateY(180deg);
    background-color:#000;
}

.rotated{
    -webkit-transform: rotateY(180deg);
}

.back, .front {
    height: 940px;
    width: 640px; 
}

.face {position: absolute;-webkit-backface-visibility: hidden;}

现在我的卡在我使用时可以正常翻转

$('#setup, #back').click(function() {
    $('#card').toggleClass('rotated');
});

我的旋转木马仍然可以工作,但似乎卡住了 - 例如,它会部分滑出,并保持卡在原位,直到我以某种方式与 div 交互,之后它会卡入正确的位置。

问题似乎是

-webkit-transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;

当我从 CSS 中删除它们时,轮播可以正常工作,但翻转不能。

我在 Safari 和 Chrome 上都进行了测试,结果是一样的。任何想法将不胜感激。

4

2 回答 2

0

只有 webkit 转换才能搞砸,添加更多信息,如

-webkit-transform: rotateY(180deg) scale(2);
-moz-transform: rotateY(180deg) scale(2);
-o-transform: rotateY(180deg) scale(2);
-ms-transform: rotateY(180deg) scale(2);

所以它被更多的浏览器支持,你有一个后备。我已经多次看到这是这个问题,但是我不能保证它,因为我没有用你的代码测试它。

于 2012-04-20T08:29:07.757 回答
0

transform 属性不适用于 jquery 中的 animate() 函数,因为 animate() 函数只接受本质上是数字的值。例如。数字(如“margin:30px”)。

transform 属性采用非数字值。

参考: http ://www.w3schools.com/jquery/eff_animate.asp

但是,您可以使用“步进函数”通过动画或使用 Transit 插件来实现变换效果。 http://ricostacruz.com/jquery.transit/

希望这可以帮助。

于 2016-10-26T11:56:39.957 回答