Browse Source

HUE-6088 [core] Scroll top top and to left should be aligned with the app panel

Enrico Berti 8 years ago
parent
commit
3dfa59d

+ 3 - 3
desktop/core/src/desktop/static/desktop/js/jquery.scrollleft.js

@@ -67,9 +67,10 @@
     }
 
     function positionOtherAnchors() {
-      var right = -30;
+      var upPosition = $('#jHueScrollUpAnchor').css('right').replace(/px/ig, '')*1;
+      var right = upPosition - 30;
       if ($('#jHueScrollUpAnchor').is(':visible')){
-        right = 20;
+        right = upPosition;
       }
 
       if ($('#jHueScrollLeftAnchor').is(':visible')){
@@ -80,7 +81,6 @@
       $('.hue-datatable-search').css('right', (right + 50) + 'px');
     }
 
-
     function setScrollBehavior(scrolled, scrollable) {
       scrolled.scroll(function () {
         if (scrolled.scrollLeft() > _this.options.threshold) {

+ 18 - 2
desktop/core/src/desktop/static/desktop/js/jquery.scrollup.js

@@ -71,9 +71,10 @@
     }
 
     function positionOtherAnchors() {
-      var right = -30;
+      var upPosition = $('#jHueScrollUpAnchor').css('right').replace(/px/ig, '')*1;
+      var right = upPosition - 30;
       if ($('#jHueScrollUpAnchor').is(':visible')){
-        right = 20;
+        right = upPosition;
       }
 
       if ($('#jHueScrollLeftAnchor').is(':visible')){
@@ -84,6 +85,18 @@
       $('.hue-datatable-search').css('right', (right + 50) + 'px');
     }
 
+    huePubSub.subscribe('reposition.scroll.anchor.up', function(){
+      $('#jHueScrollUpAnchor').css('right', '20px');
+      if (!$(_this.element).is('body')) {
+        var adjustRight = $(window).width() - $(_this.element).offset().left - $(_this.element).width();
+        if (adjustRight > 20) {
+          $('#jHueScrollUpAnchor').css('right', adjustRight + 'px');
+        }
+      }
+      positionOtherAnchors();
+    });
+
+
     function setScrollBehavior(scrolled, scrollable) {
       scrolled.scroll(function () {
         if (scrolled.scrollTop() > _this.options.threshold) {
@@ -100,6 +113,9 @@
           checkForAllScrolls();
         }
       });
+      window.setTimeout(function() {
+        huePubSub.publish('reposition.scroll.anchor.up');
+      }, 0);
     }
 
     function checkForAllScrolls() {

+ 5 - 0
desktop/core/src/desktop/templates/hue.mako

@@ -847,6 +847,11 @@ ${ assist.assistPanel() }
         self.apiHelper = ApiHelper.getInstance();
         self.leftAssistVisible = ko.observable();
         self.rightAssistVisible = ko.observable();
+        self.rightAssistVisible.subscribe(function () {
+          window.setTimeout(function () {
+            huePubSub.publish('reposition.scroll.anchor.up')
+          }, 0);
+        });
         self.rightAssistAvailable = ko.observable(false);
         self.assistantAvailable = ko.observable(false);
         self.activeRightTab = ko.observable();