Skip to content

Instantly share code, notes, and snippets.

@coodoo
Created December 18, 2013 00:14
Show Gist options
  • Save coodoo/8015219 to your computer and use it in GitHub Desktop.
Save coodoo/8015219 to your computer and use it in GitHub Desktop.
# DOM life cycle event
- DOM mutation event ← 最早期,已 retired
- 新版是 Mutation Observers ← angular 與 polymer 都靠這個
- observer.observe()
- 範例: http://stackoverflow.com/questions/3219758/detect-changes-in-the-dom
- android chrome 4.4 前不支援
- polyfill
- https://github.com/Polymer/MutationObservers
- 另一招是用 css keyframe animation event
- http://davidwalsh.name/detect-node-insertion
- 有人寫好 jquery 套件
- Angular 的 ng-include 因為要跑動畫,應該會清楚知道 animation end 時機,再廣播即可
- polymer 的 event
- created, ready, enteredView, leftView, attributeChanged
- 看來都是 observer.observe() 達成的
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment