[AngularJS] TweenList 3D + AngularJS Animate

來源:互聯網
上載者:User

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

 

[AngularJS] TweenList 3D + AngularJS Animate

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.