瀏覽代碼

[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 年之前
父節點
當前提交
725cd3b598
共有 1 個文件被更改,包括 17 次插入0 次删除
  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);