From bb486ff26ad6f43197aba42d5af53508bf2c5235 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Fri, 11 May 2012 12:42:04 +0000 Subject: #8723 Add touch scrolling support to Accordion svn changeset:23716/svn branch:6.8 --- .../vaadin/terminal/gwt/client/ui/VAccordion.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java b/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java index 4d0776a5f9..73d7eba2d6 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java @@ -24,6 +24,7 @@ import com.vaadin.terminal.gwt.client.RenderSpace; import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.Util; import com.vaadin.terminal.gwt.client.VCaption; +import com.vaadin.terminal.gwt.client.ui.TouchScrollDelegate.TouchScrollHandler; public class VAccordion extends VTabsheetBase implements ContainerResizedListener { @@ -48,12 +49,16 @@ public class VAccordion extends VTabsheetBase implements private RenderInformation renderInformation = new RenderInformation(); + private final TouchScrollHandler touchScrollHandler; + public VAccordion() { super(CLASSNAME); // IE6 needs this to calculate offsetHeight correctly if (BrowserInfo.get().isIE6()) { DOM.setStyleAttribute(getElement(), "zoom", "1"); } + + touchScrollHandler = TouchScrollDelegate.enableTouchScrolling(this); } @Override @@ -198,7 +203,6 @@ public class VAccordion extends VTabsheetBase implements } } } - if (!alreadyOpen) { item.open(); activeTabIndex = itemIndex; @@ -442,11 +446,15 @@ public class VAccordion extends VTabsheetBase implements DOM.appendChild(captionNode, caption.getElement()); DOM.appendChild(getElement(), captionNode); DOM.appendChild(getElement(), content); - setStyleName(CLASSNAME + "-item"); - DOM.setElementProperty(content, "className", CLASSNAME - + "-item-content"); - DOM.setElementProperty(captionNode, "className", CLASSNAME - + "-item-caption"); + + getElement().addClassName(CLASSNAME + "-item"); + captionNode.addClassName(CLASSNAME + "-item-caption"); + content.addClassName(CLASSNAME + "-item-content"); + + touchScrollHandler.addElement(getContainerElement()); + + sinkEvents(Event.TOUCHEVENTS | Event.MOUSEEVENTS); + close(); } @@ -640,6 +648,8 @@ public class VAccordion extends VTabsheetBase implements protected void removeTab(int index) { StackItem item = getStackItem(index); remove(item); + + touchScrollHandler.addElement(item.getContainerElement()); } @Override -- cgit v1.2.3