码迷,mamicode.com
首页 > Web开发 > 详细

[AngularJS] TweenList 3D + AngularJS Animate

时间:2014-11-27 18:15:33      阅读:362      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   sp   for   on   

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();
      }
    }
  };
});

 

bubuko.com,布布扣

[AngularJS] TweenList 3D + AngularJS Animate

标签:style   blog   http   io   ar   color   sp   for   on   

原文地址:http://www.cnblogs.com/Answer1215/p/4126827.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!