implemented auto-scrolling and changed resize handling into a directive