Forráskód Böngészése

[core] Add ko binding that delays overflow

When this binding is added to an element the overflow is hidden until the mouse has been in the element for .5 second. When scrolling through a long page, with multiple fixed height elements, this prevents the scrolling from getting stuck.
Johan Ahlen 10 éve
szülő
commit
725cd3b598

+ 17 - 0
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -1625,6 +1625,23 @@ ko.toCleanJSON = function (koObj) {
 }
 
 
+ko.bindingHandlers.delayedOverflow = {
+  init: function (element) {
+    var $element = $(element);
+    $element.css("overflow", "hidden");
+
+    var scrollTimeout = -1;
+    $element.hover(function() {
+      scrollTimeout = window.setTimeout(function() {
+        $element.css("overflow", "auto");
+      }, 500);
+    }, function() {
+      clearTimeout(scrollTimeout);
+      $element.css("overflow", "hidden");
+    });
+  }
+};
+
 ko.bindingHandlers.aceEditor = {
   init: function (element, valueAccessor) {
     var $el = $(element);