js update and centroid position