Преглед на файлове

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