]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #3764, yet another webkit scrollbar issue fixed. Hopefully got it fixed without...
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 22 Dec 2009 15:14:35 +0000 (15:14 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 22 Dec 2009 15:14:35 +0000 (15:14 +0000)
svn changeset:10530/svn branch:6.2

src/com/vaadin/terminal/gwt/client/Util.java
src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java

index a46f9fa7d7fa708f61fe32278666743b113b75aa..ca0165974a1ca7ed9423fbc666dc020bc31c87f9 100644 (file)
@@ -548,18 +548,29 @@ public class Util {
             if ("hidden".equals(originalOverflow)) {
                 return;
             }
+
+            // check the scrolltop value before hiding the element
+            final int scrolltop = elem.getScrollTop();
             elem.getStyle().setProperty("overflow", "hidden");
 
             DeferredCommand.addCommand(new Command() {
                 public void execute() {
                     // Dough, Safari scroll auto means actually just a moped
                     elem.getStyle().setProperty("overflow", originalOverflow);
-                    if (elem.getScrollTop() > 0) {
+
+                    if (scrolltop > 0 || elem.getScrollTop() > 0) {
+                        int scrollvalue = scrolltop;
+                        if (scrolltop == 0) {
+                            // mysterious are the ways of webkits scrollbar
+                            // handling. In some cases webkit reports bad (0)
+                            // scrolltop before hiding the elment temporary,
+                            // sometimes after.
+                            scrollvalue = elem.getScrollTop();
+                        }
                         // fix another bug where scrollbar remains in wrong
                         // position
-                        int scrolltop = elem.getScrollTop();
-                        elem.setScrollTop(scrolltop - 1);
-                        elem.setScrollTop(scrolltop);
+                        elem.setScrollTop(scrollvalue - 1);
+                        elem.setScrollTop(scrollvalue);
                     }
                 }
             });
index 6e8d672493c2c0771fa0fb9fce6e38afdfb634cc..8c26210369b324177b1f24a48740dd3a30c75683 100644 (file)
@@ -2702,10 +2702,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
                 if (currentlyVisible < pageLength
                         && currentlyVisible < totalRows) {
                     // shake scrollpanel to fill empty space
-                    bodyContainer.setScrollPosition(bodyContainer
-                            .getScrollPosition() + 1);
-                    bodyContainer.setScrollPosition(bodyContainer
-                            .getScrollPosition() - 1);
+                    bodyContainer.setScrollPosition(scrollTop + 1);
+                    bodyContainer.setScrollPosition(scrollTop - 1);
                 }
             }
         }
@@ -2876,6 +2874,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
     }
 
     private int contentAreaBorderHeight = -1;
+    private int scrollLeft;
+    private int scrollTop;
 
     /**
      * @return border top + border bottom of the scrollable area of table
@@ -2954,8 +2954,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
      * user scrolls
      */
     public void onScroll(ScrollEvent event) {
-        int scrollLeft = bodyContainer.getElement().getScrollLeft();
-        int scrollTop = bodyContainer.getScrollPosition();
+        scrollLeft = bodyContainer.getElement().getScrollLeft();
+        scrollTop = bodyContainer.getScrollPosition();
         if (!initializedAndAttached) {
             return;
         }
@@ -2967,6 +2967,19 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
 
         rowRequestHandler.cancel();
 
+        if (BrowserInfo.get().isSafari() && event != null && scrollTop == 0) {
+            // due to the webkitoverflowworkaround, top may sometimes report 0
+            // for webkit, although it really is not. Expecting to have the
+            // correct
+            // value available soon.
+            DeferredCommand.addCommand(new Command() {
+                public void execute() {
+                    onScroll(null);
+                }
+            });
+            return;
+        }
+
         // fix headers horizontal scrolling
         tHead.setHorizontalScrollPosition(scrollLeft);