Created
December 30, 2018 21:03
-
-
Save lifeart/c48ae815d283d945be3c6cca6901327d to your computer and use it in GitHub Desktop.
Ember lazy-rendered component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@ember/component'; | |
import { later, run } from '@ember/runloop'; | |
export default class UiLazyRendered extends Component.extend({ | |
// anything which *must* be merged to prototype here | |
showContent: false, | |
timeout: 36, | |
didInsertElement() { | |
run('afterRender', () => { | |
later(this, 'toggleContent', this.timeout + Math.random() * 100); | |
}); | |
}, | |
toggleContent() { | |
if (this.isDestroying || this.isDestroyed) { | |
return; | |
} | |
this.toggleProperty('showContent'); | |
}, | |
tagName: '' | |
}) { | |
// normal class body definition here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to use it?