Trying to copy animatedView class and it's difficult to understand