<!DOCTYPE html>
<html>
 <head>
    <meta charset="UTF-8">
    <title>Animation Easing Functions</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="style.css">

    <!-- Polyfill for Web Animations -->
    <script src="https://npmcdn.com/web-animations-js@2.2.1"></script>

    <!-- Polyfill(s) for older browsers -->
    <script src="https://npmcdn.com/core-js/client/shim.min.js"></script>

    <script src="https://npmcdn.com/zone.js@0.6.12?main=browser"></script>
    <script src="https://npmcdn.com/reflect-metadata@0.1.3"></script>
    <script src="https://npmcdn.com/systemjs@0.19.27/dist/system.src.js"></script>

    <script src="systemjs.config.js"></script>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>
  </head>
  <body>
    
    <my-app>
      ... loading.
    </my-app>
    
  </body>
</html>


<!-- 
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
-->
/* Styles go here */

a {
  color: blue ;
  cursor: pointer ;
  text-decoration: underline ;
}

.dummyComponent{
  height: 400px;
  width: 200px;;
  background-color: purple;
} 
//main entry point
import {bootstrap} from '@angular/platform-browser-dynamic';
import {App} from './app';

bootstrap(App, [])
  .catch(err => console.error(err));

import {Component, animate, style, state, transition, trigger} from '@angular/core';

@Component({
  selector: 'my-app',
  providers: [],
  animations: [
    trigger("fadeInOut", [
      state("open", style({opacity: 1})),
      state("closed", style({opacity: 0})),
      transition("open <=> closed", animate( "3000ms" )),
    ])
  ],
  template: 
  `
  <h1> Angular 2 Animation State Transition Test </h1>
  
  <p> Trying to replicate old animation API behaviour of animationBuilder.css().setToFromStyles() etc </p>
  <p> The old animations API used to play from CURRENT style. Now it starts from beginning of state. </p>
  <p> i.e. A state transition of 'open' -> 'closed' -> 'open' before the 'closed' animation completed<br/> would result in
      a FULL 'closed' to 'open' transition instead of a PARTIAL transition (from whatever css <br/>styles were currently applied 
      at the time of when the second 'open' state transition occurred.</p>
  
  <h3> As of RC3 I can't figure this out with the new API syntax. </h3>
  <h4> Instructions:</h4>
  <ul>
  <li> Click 'Toggle State' to fade out the component over 3 seconds (i.e. change state to 'closed')</li>
  <li> Click 'Toggle State' again after ~1.5 seconds, i.e. change state back to 'open'</li>
  <li> <b>Expect:</b> Nice fadeout/fadein from {opacity: 1} to {opacity: 0.5} back to {opacity: 1}</li>
  <li> <b>Actual Result:</b> Fadeout for 1.5s then harsh fadein from 0 opacity</li>
  </ul>
    <p>
      <a (click)="beginAnim()">Toggle State</a>
    </p>
    
    <div class="dummyComponent" @fadeInOut="state">
      
    </div>
    
    <br/>
    <div>Current State: <b>{{state}}</b></div>
  `
})
export class App {
  state = 'open';
  timeOutRef;

  beginAnim() {
     // toggle state to kickstart animation
      this.state = this.state === 'open' ? 'closed' : 'open';
  }
}
/**
 * PLUNKER VERSION (based on systemjs.config.js in angular.io)
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function(global) {

  var ngVer = '@2.0.0-rc.3'; // lock in the angular package version; do not let it float to current!
  var routerVer = '@3.0.0-alpha.8'; // lock router version

  //map tells the System loader where to look for things
  var  map = {
    'app':                        'src',

    '@angular':                   'https://npmcdn.com/@angular', // sufficient if we didn't pin the version
    '@angular/router':            'https://npmcdn.com/@angular/router' + routerVer,
    'angular2-in-memory-web-api': 'https://npmcdn.com/angular2-in-memory-web-api', // get latest
    'rxjs':                       'https://npmcdn.com/rxjs@5.0.0-beta.6',
    'ts':                         'https://npmcdn.com/plugin-typescript@4.0.10/lib/plugin.js',
    'typescript':                 'https://npmcdn.com/typescript@1.9.0-dev.20160409/lib/typescript.js',
 };

  //packages tells the System loader how to load when no filename and/or no extension
  var packages = {
    'app':                        { main: 'main.ts',  defaultExtension: 'ts' },
    'rxjs':                       { defaultExtension: 'js' },
    'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
  };

  var ngPackageNames = [
    'common',
    'compiler',
    'core',
    'http',
    'platform-browser',
    'platform-browser-dynamic',
    'router-deprecated',
    'upgrade',
  ];

  // Add map entries for each angular package
  // only because we're pinning the version with `ngVer`.
  ngPackageNames.forEach(function(pkgName) {
    map['@angular/'+pkgName] = 'https://npmcdn.com/@angular/' + pkgName + ngVer;
  });

  // Add package entries for angular packages
  ngPackageNames.forEach(function(pkgName) {

    // Bundled (~40 requests):
    packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };

    // Individual files (~300 requests):
    //packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
  });

  // No umd for router yet
  packages['@angular/router'] = { main: 'index.js', defaultExtension: 'js' };

  var config = {
    // DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
    transpiler: 'ts',
    typescriptOptions: {
      tsconfig: true
    },
    meta: {
      'typescript': {
        "exports": "ts"
      }
    },
    map: map,
    packages: packages
  };

  System.config(config);

})(this);


/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  }
}