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     @since Version 1.10
 15   */
 16   POP_IN: {
 17 
 18     /* @private */
 19     layoutProperties: ['scale'],
 20 
 21     /** @private */
 22     setup: function (view, options, inPlace) {
 23       view.adjust({ scale: inPlace ? view.get('layout').scale || 0 : 0 });
 24     },
 25 
 26     /** @private */
 27     run: function (view, options, finalLayout, finalFrame) {
 28       var bigScale,
 29         duration,
 30         frames,
 31         poppiness = options.poppiness || 0.2,
 32         scale;
 33 
 34       scale = finalLayout.scale || 1;
 35       bigScale = scale * (poppiness + 1);
 36 
 37       duration = options.duration || 0.25;
 38 
 39       frames = [
 40         { value: { scale: bigScale }, duration: duration * 0.6, timing: 'ease-out' },
 41         { value: { scale: scale }, duration: duration * 0.4, timing: 'ease-in-out' }
 42       ];
 43 
 44       var callback = function (data) {
 45         if (!data.isCancelled) {
 46           view.didTransitionIn();
 47         }
 48       };
 49 
 50       // Animate through the frames.
 51       view._animateFrames(frames, callback, options.delay || 0);
 52     }
 53   },
 54 
 55   /** @class
 56 
 57     @extends SC.ViewTransitionProtocol
 58     @since Version 1.10
 59   */
 60   POP_OUT: {
 61 
 62     /* @private */
 63     layoutProperties: ['scale'],
 64 
 65     /** @private */
 66     run: function (view, options) {
 67       var bigScale,
 68         duration,
 69         frames,
 70         poppiness = options.poppiness || 0.15,
 71         scale;
 72 
 73       scale = view.get('layout').scale || 1;
 74       bigScale = scale * (poppiness + 1);
 75 
 76       duration = options.duration || 0.2;
 77 
 78       frames = [
 79         { value: { scale: bigScale }, duration: duration * 0.4, timing: 'ease-out' },
 80         { value: { scale: 0 }, duration: duration * 0.6, timing: 'ease-in-out' }
 81       ];
 82 
 83       var callback = function (data) {
 84         if (!data.isCancelled) {
 85           view.didTransitionOut();
 86         }
 87       };
 88 
 89       // Animate through the frames.
 90       view._animateFrames(frames, callback, options.delay || 0);
 91     }
 92   }
 93 });
 94