diff options
author | 2017-05-04 07:48:42 -0400 | |
---|---|---|
committer | 2017-05-04 12:28:17 -0400 | |
commit | b54df0ddd0c6a0372327c5aa3668e5a6458fcd64 (patch) | |
tree | e69cfa9b314a801bd187cf0145d1d4306436229c /ecomp-portal-FE/client/bower_components/jqTree/src/scroll_handler.coffee | |
parent | 39d1e62c84041831bfc52cca73b5ed5efaf57d27 (diff) |
[PORTAL-7] Rebase
This rebasing includes common libraries and common overlays projects
abstraction of components
Change-Id: I9a24a338665c7cd058978e8636bc412d9e2fdce8
Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-portal-FE/client/bower_components/jqTree/src/scroll_handler.coffee')
-rw-r--r-- | ecomp-portal-FE/client/bower_components/jqTree/src/scroll_handler.coffee | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/ecomp-portal-FE/client/bower_components/jqTree/src/scroll_handler.coffee b/ecomp-portal-FE/client/bower_components/jqTree/src/scroll_handler.coffee deleted file mode 100644 index 3456dec5..00000000 --- a/ecomp-portal-FE/client/bower_components/jqTree/src/scroll_handler.coffee +++ /dev/null @@ -1,114 +0,0 @@ -$ = jQuery - - -class ScrollHandler - constructor: (tree_widget) -> - @tree_widget = tree_widget - @previous_top = -1 - @is_initialized = false - - _initScrollParent: -> - getParentWithOverflow = => - css_values = ['overflow', 'overflow-y'] - - hasOverFlow = (el) -> - for css_value in css_values - if $.css(el, css_value) in ['auto', 'scroll'] - return true - - return false - - if hasOverFlow(@tree_widget.$el[0]) - return @tree_widget.$el - - for el in @tree_widget.$el.parents() - if hasOverFlow(el) - return $(el) - - return null - - setDocumentAsScrollParent = => - @scroll_parent_top = 0 - @$scroll_parent = null - - if @tree_widget.$el.css('position') == 'fixed' - setDocumentAsScrollParent() - - $scroll_parent = getParentWithOverflow() - - if $scroll_parent and $scroll_parent.length and $scroll_parent[0].tagName != 'HTML' - @$scroll_parent = $scroll_parent - @scroll_parent_top = @$scroll_parent.offset().top - else - setDocumentAsScrollParent() - - @is_initialized = true - - _ensureInit: -> - if not @is_initialized - @_initScrollParent() - - checkScrolling: -> - @_ensureInit() - - hovered_area = @tree_widget.dnd_handler.hovered_area - - if hovered_area and hovered_area.top != @previous_top - @previous_top = hovered_area.top - - if @$scroll_parent - @_handleScrollingWithScrollParent(hovered_area) - else - @_handleScrollingWithDocument(hovered_area) - - _handleScrollingWithScrollParent: (area) -> - distance_bottom = @scroll_parent_top + @$scroll_parent[0].offsetHeight - area.bottom - - if distance_bottom < 20 - @$scroll_parent[0].scrollTop += 20 - @tree_widget.refreshHitAreas() - @previous_top = -1 - else if (area.top - @scroll_parent_top) < 20 - @$scroll_parent[0].scrollTop -= 20 - @tree_widget.refreshHitAreas() - @previous_top = -1 - - _handleScrollingWithDocument: (area) -> - distance_top = area.top - $(document).scrollTop() - - if distance_top < 20 - $(document).scrollTop($(document).scrollTop() - 20) - else if $(window).height() - (area.bottom - $(document).scrollTop()) < 20 - $(document).scrollTop($(document).scrollTop() + 20) - - scrollTo: (top) -> - @_ensureInit() - - if @$scroll_parent - @$scroll_parent[0].scrollTop = top - else - tree_top = @tree_widget.$el.offset().top - $(document).scrollTop(top + tree_top) - - isScrolledIntoView: (element) -> - @_ensureInit() - - $element = $(element) - - if @$scroll_parent - view_top = 0 - view_bottom = @$scroll_parent.height() - - element_top = $element.offset().top - @scroll_parent_top - element_bottom = element_top + $element.height() - else - view_top = $(window).scrollTop() - view_bottom = view_top + $(window).height() - - element_top = $element.offset().top - element_bottom = element_top + $element.height() - - return (element_bottom <= view_bottom) and (element_top >= view_top) - - -module.exports = ScrollHandler |