Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Starting point for following along during Demystifying Ember.js by Joe Fiorini" />
<meta charset=utf-8 />
<title>JS Bin</title>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="http://builds.emberjs.com/handlebars-1.0.0.js"></script>
  <script src="http://builds.emberjs.com/stable/ember.js"></script>
</head>
<body>
  b
</body>
</html>
 
.t-rotate {
  display: inline-block;
  -webkit-transition: -webkit-transform 500ms;
  -webkit-transform: rotate3d(0, 1, 0, -90deg);
}
.t-rotate-in {
  -webkit-transform-origin: bottom;
  -webkit-transform: rotate3d(0, 0, 0, 0);
}
.t-rotate-out {
  -webkit-transform-origin: top;
  -webkit-transform: rotate3d(1, 0, 0, 90deg);
}
 
// A current problem with animations in Ember
// This simple example tries to animate a change to a computed property.
// Problem is, the markup changes before the animation can complete. This
// leads to dificult-to-predict behavior given the different sets of timings
// that are going on.
var App = Ember.Application.create();
var controller = Ember.Controller.create({
  name: "John"
});
AnimatedName = Ember.Component.extend({
  tagName: 'span',
  classNameBindings: ['isIn:t-rotate-in:t-rotate-out'],
  classNames: ['t-rotate'],
  template: Ember.Handlebars.compile("{{currentName}}"),
  
  currentName: null,
  isIn: true,
    
  nameDidChange: function() {
    this.set('isIn', false);
    this.$().one("webkitTransitionEnd", function() {
      this.set('currentName', this.get('name'));
      this.set('isIn', true);
    }.bind(this));
  }.observes("name")
});
Ember.Handlebars.helper('animated-name', AnimatedName);
var view = Ember.View.extend({
  controller: controller,
  template: Ember.Handlebars.compile("Hello {{animated-name name=name}}")
}).create();
view.append();
// Change that computed property a few times on a timer.
changeName("Paul")("George")("Ringo");
function changeName(name) {
  changeName.time = changeName.time || 0;
  changeName.time += 2000;
  Ember.run.later(function() {
    controller.set("name", name);
  }, changeName.time);
  return changeName;
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers