script for moving elements into viewport and avoid clipping