[AngularJS] TweenList 3D + AngularJS Animate

AngularJS animations and TweenLite make it really easy to create cool 3d effects in your application.

复制代码
<!DOCTYPE html>
<html ng-app="helloGreensock">
    <head lang="en">
        <meta charset="UTF-8">
        <title>Hello Greensock!</title>

        <link rel="stylesheet" href="css/greensock.css"/>
    </head>
    <body ng-controller="MainCtrl">
        <question class="cardWrapper answer-animation"
                  ng-class="{'answer':showAnswer}"
                  ng-repeat="q in questions"
                  ng-mouseenter="showAnswer = true"
                  ng-mouseleave="showAnswer = false">
            <div class="card">
                <div class="cardFace front"><img height="200px"; ng-src="{{q.question}}"/></div>
                <div class="cardFace back">><img height="200px"; ng-src="{{q.answer}}"/></div>
            </div>
        </question>
    </body>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-animate.min.js"></script>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.11.6/TweenMax.min.js"></script>

    <script src="js/greensock.3d.js"></script>
</html>
复制代码

 

复制代码
var app = angular.module('helloGreensock', ['ngAnimate']);

app.controller('MainCtrl', function ($scope) {
  $scope.questions = [
    {question: 'img/1480.jpg', answer: 'img/30.jpg'},
    {question: 'img/7081.jpg', answer: 'img/70.jpg'}
  ];
});

app.directive('question', function () {
  var controller = function ($scope) {
    $scope.showAnswer = false;
  };

  return {
    restrict: 'E',
    scope: true,
    controller: controller
  }
});

app.animation('.answer-animation', function () {
  TweenLite.set('.cardWrapper', {perspective: 400});
  TweenLite.set('.card', {transformStyle: 'preserve-3d'});
  TweenLite.set('.back', {rotationY: -180});
  TweenLite.set(['.back', '.front'], {backfaceVisibility: 'hidden'});

  return {
    beforeAddClass: function (element, className, done) {
      if (className == 'answer') {
        TweenLite.to(element.find('.card'), 2,
          {rotationY:180, ease:Back.easeOut, onComplete:done});
      }
      else {
        done();
      }
    },

    beforeRemoveClass: function (element, className, done) {
      if (className == 'answer') {
        TweenLite.to(element.find('.card'), 1.2,
          {rotationY:0, ease:Back.easeOut, onComplete:done});
      }
      else {
        done();
      }
    }
  };
});
复制代码

 

posted @   Zhentiw  阅读(660)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示