 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 module.exports = angular.module('ponyfm').controller "sidebar", [
-    '$scope', '$modal', 'playlists', '$rootScope'
-    ($scope, $modal, playlists, $rootScope) ->
+    '$scope', '$modal', 'playlists', '$rootScope', '$timeout'
+    ($scope, $modal, playlists, $rootScope, $timeout) ->
         $scope.playlists = playlists.pinnedPlaylists
         $scope.menuVisible = false
         $scope.menuActive = false

        touchingNav = false

        onStart = (e) ->
            if !$scope.menuVisible
                return


        $scope.navStyle = {}

        $rootScope.$on('sidebarToggled', () ->
            $timeout(() ->
                if $scope.menuVisible
                    $scope.navStyle.transform = ''
                    $scope.menuAnimated = true

                $scope.menuVisible = !$scope.menuVisible
                $scope.menuActive = $scope.menuVisible

                console.log $scope.menuActive
            )
        )

        $rootScope.$on('sidebarHide', () ->
            $timeout(() ->
                $scope.navStyle.transform = ''
                $scope.menuAnimated = true
                $scope.menuVisible = false
                $scope.menuActive = false
            )
        )

        $scope.createPlaylist = () ->
