fix Illegal Invocation error and resize calculations (paddings)

fix Illegal invocation error. CancelAnim must be invocated with window context instead container element.
improve width and height calculations on resize (exclude paddings, may need exclude margins).