Skip to content

Instantly share code, notes, and snippets.

@samselikoff
Created November 7, 2018 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samselikoff/aa34e42b1344205c19ce06db00928f7c to your computer and use it in GitHub Desktop.
Save samselikoff/aa34e42b1344205c19ce06db00928f7c to your computer and use it in GitHub Desktop.
CSS transition demo
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
activeClass: 'faded-in',
actions: {
toggleActiveClass() {
if (this.activeClass === 'faded-in') {
this.set('activeClass', 'faded-out');
} else {
this.set('activeClass', 'faded-in');
}
}
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.faded-in {
opacity: 1;
}
.faded-out {
opacity: 0;
}
.transition {
transition: opacity 1s;
}
<h1>Welcome to {{appName}}</h1>
<br>
<button {{action 'toggleActiveClass'}}>Click me</button>
<div class={{concat 'transition ' activeClass}}>
<p>Lorem ipsum dolor</p>
</div>
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment