overleaf/services/web/public/coffee/ide/review-panel/directives/reviewPanelCollapseHeight.coffee

18 lines
508 B
CoffeeScript
Raw Normal View History

define [
"base"
], (App) ->
App.directive "reviewPanelCollapseHeight", ($parse) ->
return {
restrict: "A",
link: (scope, element, attrs) ->
scope.$watch (() -> $parse(attrs.reviewPanelCollapseHeight)(scope)), (shouldCollapse) ->
neededHeight = element.prop("scrollHeight")
if neededHeight > 0
if shouldCollapse
element.animate { height: 0 }, 150
else
element.animate { height: neededHeight }, 150
2017-02-21 09:27:57 -05:00
else
if shouldCollapse
element.height 0
}