Implement better scrolling via conditionalScroll

Refactor ui.js to a cleaner and simpler format
Clean up other Flow JS and implement event namespacing

Bug: 58880
Change-Id: I6aa67183a1b9c5b07fe1f1cc30681602f3341065
Merge "Implement better scrolling via conditionalScroll"