Added beforeChange and afterChange method and fix the last to first opacity bug