<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;
transition: transform 500ms;
transform: rotate3d(0, 1, 0, -90deg);
}
.t-rotate-in {
transform-origin: bottom;
transform: rotate3d(0, 0, 0, 0);
}
.t-rotate-out {
transform-origin: top;
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
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |