1 // ==========================================================================
  2 // Project:   SproutCore
  3 // Copyright: @2013 7x7 Software, Inc.
  4 // License:   Licensed under MIT license (see license.js)
  5 // ==========================================================================
  6 
  7 
  8 SC.mixin(SC.View,
  9   /** @scope SC.View */ {
 10 
 11   /** @class
 12 
 13     @extends SC.ViewTransitionProtocol
 14     @see SC.View#animate for other timing functions.
 15     @since Version 1.10
 16   */
 17   FADE_IN: {
 18 
 19     /* @private */
 20     layoutProperties: ['opacity'],
 21 
 22     /** @private */
 23     setup: function (view, options, inPlace) {
 24       view.adjust({ opacity: inPlace ? view.get('layout').opacity || 0 : 0 });
 25     },
 26 
 27     /** @private */
 28     run: function (view, options, finalLayout, finalFrame) {
 29       view.animate('opacity', finalLayout.opacity || 1, {
 30         delay: options.delay || 0,
 31         duration: options.duration || 0.4,
 32         timing: options.timing || 'ease'
 33       }, function (data) {
 34         if (!data.isCancelled) {
 35           this.didTransitionIn();
 36         }
 37       });
 38     }
 39   },
 40 
 41   /** @class
 42 
 43     @extends SC.ViewTransitionProtocol
 44     @see SC.View#animate for other timing functions.
 45     @since Version 1.10
 46   */
 47   FADE_OUT: {
 48 
 49     /* @private */
 50     layoutProperties: ['opacity'],
 51 
 52     /** @private */
 53     run: function (view, options) {
 54       view.animate('opacity', 0, {
 55         delay: options.delay || 0,
 56         duration: options.duration || 0.4,
 57         timing: options.timing || 'ease'
 58       }, function (data) {
 59         if (!data.isCancelled) {
 60           this.didTransitionOut();
 61         }
 62       });
 63     }
 64 
 65   }
 66 
 67 });
 68