1. A device for controlling a driven moving element comprising an electronic unit with an object sensor, wherein the electronic unit is designed, by means of the object sensor, to determine an object distance between the driven moving element and an object in the region of the moving element and to control the movement of the moving element depending on said object distance, wherein the electronic unit is furthermore designed to use a front edge of the moving element as reference at the moving element for determining the object distance.