jquery - 如何在 jquery animate 中使用 css3 转换?

标签 jquery css transform jquery-animate

我有来自 here 的轮播我正在尝试向其中添加一些 css3 转换选项。

更确切地说:

-webkit-transform-style: preserve-3d;
-webkit-transform: rotateY(45deg);

在我的 javascript 中

if (newPosition == 1) {
    new_width = pluginData.largeFeatureWidth;
    new_height = pluginData.largeFeatureHeight;
    new_top = options.topPadding;
    new_zindex = $feature.css("z-index");
    new_fade = 1.0;
  } else {
    new_width = pluginData.smallFeatureWidth;
    new_height = pluginData.smallFeatureHeight;
    new_top = options.smallFeatureOffset + options.topPadding;
    new_zindex = 1;
    new_fade = 0.4;
  }

动画函数在这里运行

 .animate(
      {
        width: new_width,
        height: new_height,
        top: new_top,
        left: new_left,
        opacity: new_fade
      }

生成的CSS是:

element.style {
    width: 225px;
    height: 115px;
    top: 70px;
    left: 50px;
    opacity: 0.4;
    z-index: 1;
}

现在,所有这些变量都由这个插件计算,我只对将转换选项添加到这个动画函数感兴趣,就像这样:

....
} else {
    new_width = pluginData.smallFeatureWidth;
    new_height = pluginData.smallFeatureHeight;
    new_top = options.smallFeatureOffset + options.topPadding;
    new_zindex = 1;
    new_fade = 0.4;
    new_transform_style = 'preserve-3d';
    new_transform = 'rotateY(45deg)';
}

.animate(
      {
        width: new_width,
        height: new_height,
        top: new_top,
        left: new_left,
        opacity: new_fade,
        transform_style = new_transform_style;
        transform = new_transform;
      }

但我不确定这些是动画的正确样式符号

有什么想法吗?

谢谢

最佳答案

默认情况下,您不能在 jQuery 中设置旋转/缩放动画。

但是有一个插件可以解决这个问题:

Animate Rotation and Scale in CSS

关于jquery - 如何在 jquery animate 中使用 css3 转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10131806/

相关文章:

javascript - jQuery/Javascript > onClick 将文本放置在最后已知的光标位置

javascript - focus() 无法进行第二次调用

css - jQuery Mobile 和 CSS 按钮

javascript - 在不使用绝对定位的情况下将 div 拉伸(stretch)到其他可变高度 div 的顶部

javascript - 如何使连续动画附加到悬停按钮内的 svg 平滑?

javascript - JQuery 聊天应用程序仅在收到新消息时滚动到 div 的底部?

javascript - Typeahead 没有自由输入

html - 如何设置两个div的高度等于css

html - IE中列表之间的差距

xslt - 与另一个模板一起使用时身份转换奇怪的行为