Explorar o código

[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 %!s(int64=10) %!d(string=hai) anos
pai
achega
725cd3b598
Modificáronse 1 ficheiros con 17 adicións e 0 borrados
  1. 17 0
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

+ 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);