package com.vaadin.terminal.gwt.client.ui;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
import com.google.gwt.animation.client.Animation;
import com.google.gwt.core.client.Duration;
private static final double DECELERATION = 0.002;
private static final int MAX_DURATION = 1500;
private int origY;
- private Element[] scrollableElements;
+ private HashSet<Element> scrollableElements;
private Element scrolledElement;
private int origScrollTop;
private HandlerRegistration handlerRegistration;
} else {
delegate = null;
}
- setElements(scrollables);
+ for (Element scrollable : scrollables) {
+ addElement(scrollable);
+ }
}
public void onTouchStart(TouchStartEvent event) {
delegate.onTouchStart(event);
}
- public void setElements(Element... scrollables) {
- for (Element scrollable : scrollables) {
- scrollable.addClassName("v-scrollable");
+ public void addElement(Element scrollable) {
+ scrollable.addClassName("v-scrollable");
+ if (requiresDelegate) {
+ delegate.scrollableElements.add(scrollable);
}
+ }
+
+ public void removeElement(Element scrollable) {
+ scrollable.removeClassName("v-scrollable");
if (requiresDelegate) {
- delegate.setElements(scrollables);
+ delegate.scrollableElements.remove(scrollable);
}
}
}
}
public TouchScrollDelegate(Element... elements) {
- scrollableElements = elements;
+ scrollableElements = new HashSet<Element>(Arrays.asList(elements));
}
public void setScrollHandler(ScrollHandler scrollHandler) {
}
}
- public void setElements(Element[] elements) {
- scrollableElements = elements;
- }
-
/**
* long calcucation are not very efficient in GWT, so this helper method
* returns timestamp in double.