zoukankan      html  css  js  c++  java
  • [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();
          }
        }
      };
    });

  • 相关阅读:
    Python数据分析与机器学习-Matplot_2
    Python数据分析与机器学习-Matplot_1
    1008. 数组元素循环右移问题 (20)
    Latex小技巧
    执行PowerShell脚本的时候出现"在此系 统上禁止运行脚本"错误
    Linux使用MentoHust联网线上校园网, 回到普通有线网络却连不上?
    Re:uxul
    Linux下nautilus的右键快捷菜单项设置
    从入门到入狱——搭讪技巧
    Latex命令
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4126827.html
Copyright © 2011-2022 走看看