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/lib/scroll_handler.js | |
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/lib/scroll_handler.js')
-rw-r--r-- | ecomp-portal-FE/client/bower_components/jqTree/lib/scroll_handler.js | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/ecomp-portal-FE/client/bower_components/jqTree/lib/scroll_handler.js b/ecomp-portal-FE/client/bower_components/jqTree/lib/scroll_handler.js deleted file mode 100644 index 2b8e7070..00000000 --- a/ecomp-portal-FE/client/bower_components/jqTree/lib/scroll_handler.js +++ /dev/null @@ -1,137 +0,0 @@ -var $, ScrollHandler; - -$ = jQuery; - -ScrollHandler = (function() { - function ScrollHandler(tree_widget) { - this.tree_widget = tree_widget; - this.previous_top = -1; - this.is_initialized = false; - } - - ScrollHandler.prototype._initScrollParent = function() { - var $scroll_parent, getParentWithOverflow, setDocumentAsScrollParent; - getParentWithOverflow = (function(_this) { - return function() { - var css_values, el, hasOverFlow, i, len, ref; - css_values = ['overflow', 'overflow-y']; - hasOverFlow = function(el) { - var css_value, i, len, ref; - for (i = 0, len = css_values.length; i < len; i++) { - css_value = css_values[i]; - if ((ref = $.css(el, css_value)) === 'auto' || ref === 'scroll') { - return true; - } - } - return false; - }; - if (hasOverFlow(_this.tree_widget.$el[0])) { - return _this.tree_widget.$el; - } - ref = _this.tree_widget.$el.parents(); - for (i = 0, len = ref.length; i < len; i++) { - el = ref[i]; - if (hasOverFlow(el)) { - return $(el); - } - } - return null; - }; - })(this); - setDocumentAsScrollParent = (function(_this) { - return function() { - _this.scroll_parent_top = 0; - return _this.$scroll_parent = null; - }; - })(this); - if (this.tree_widget.$el.css('position') === 'fixed') { - setDocumentAsScrollParent(); - } - $scroll_parent = getParentWithOverflow(); - if ($scroll_parent && $scroll_parent.length && $scroll_parent[0].tagName !== 'HTML') { - this.$scroll_parent = $scroll_parent; - this.scroll_parent_top = this.$scroll_parent.offset().top; - } else { - setDocumentAsScrollParent(); - } - return this.is_initialized = true; - }; - - ScrollHandler.prototype._ensureInit = function() { - if (!this.is_initialized) { - return this._initScrollParent(); - } - }; - - ScrollHandler.prototype.checkScrolling = function() { - var hovered_area; - this._ensureInit(); - hovered_area = this.tree_widget.dnd_handler.hovered_area; - if (hovered_area && hovered_area.top !== this.previous_top) { - this.previous_top = hovered_area.top; - if (this.$scroll_parent) { - return this._handleScrollingWithScrollParent(hovered_area); - } else { - return this._handleScrollingWithDocument(hovered_area); - } - } - }; - - ScrollHandler.prototype._handleScrollingWithScrollParent = function(area) { - var distance_bottom; - distance_bottom = this.scroll_parent_top + this.$scroll_parent[0].offsetHeight - area.bottom; - if (distance_bottom < 20) { - this.$scroll_parent[0].scrollTop += 20; - this.tree_widget.refreshHitAreas(); - return this.previous_top = -1; - } else if ((area.top - this.scroll_parent_top) < 20) { - this.$scroll_parent[0].scrollTop -= 20; - this.tree_widget.refreshHitAreas(); - return this.previous_top = -1; - } - }; - - ScrollHandler.prototype._handleScrollingWithDocument = function(area) { - var distance_top; - distance_top = area.top - $(document).scrollTop(); - if (distance_top < 20) { - return $(document).scrollTop($(document).scrollTop() - 20); - } else if ($(window).height() - (area.bottom - $(document).scrollTop()) < 20) { - return $(document).scrollTop($(document).scrollTop() + 20); - } - }; - - ScrollHandler.prototype.scrollTo = function(top) { - var tree_top; - this._ensureInit(); - if (this.$scroll_parent) { - return this.$scroll_parent[0].scrollTop = top; - } else { - tree_top = this.tree_widget.$el.offset().top; - return $(document).scrollTop(top + tree_top); - } - }; - - ScrollHandler.prototype.isScrolledIntoView = function(element) { - var $element, element_bottom, element_top, view_bottom, view_top; - this._ensureInit(); - $element = $(element); - if (this.$scroll_parent) { - view_top = 0; - view_bottom = this.$scroll_parent.height(); - element_top = $element.offset().top - this.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) && (element_top >= view_top); - }; - - return ScrollHandler; - -})(); - -module.exports = ScrollHandler; |