How to intercept scrollEvents on tablets (which does not have a scroll mouse) ?

114 views
Skip to first unread message

regnoult axel

unread,
Dec 11, 2012, 8:22:00 PM12/11/12
to google-we...@googlegroups.com
Hello,

My issue is indirectly related to an unforeseen behavior on tablets because they do not have a scroll mouse and so I cannot intercept a scroll event.

Actually I am mainly working on a desktop application, but I would like to know how I could handle the following scroll event : "The users uses the scrollbar instead of the scroll mouse to scroll on the page..."

Q1 - Do you have any idea how to intercept an event realized when the user click on the scrollbar arrow or when he moves the scrollbar track ?

Q2 - Does the recommended solution will work on tablets ?

Thanks you, 



ashwin....@gmail.com

unread,
Dec 11, 2012, 9:51:17 PM12/11/12
to google-we...@googlegroups.com

Checkout this guide from Apple, gives detailed information on events being generated pertaining to ios devices. https://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html


There are two approaches, 

1. using TouchStart and TouchEnd events. You can single/ double touches etc depending on the experience you want to achieve in your app.

2. using onScrollEvent and implementing a ScrollHandler. 

example to handle simple scrolling using TouchStart and End events.

HTMLPanel searchPage;
int scrollStartPosX = 0;
int scrollStartPosY = 0;

public init() {

            if (TouchEvent.isSupported()) {
searchPage.addDomHandler(this, TouchStartEvent.getType());
searchPage.addDomHandler(this, TouchMoveEvent.getType());
}
}

/* (non-Javadoc)
* @see com.google.gwt.event.dom.client.TouchStartHandler#onTouchStart(com.google.gwt.event.dom.client.TouchStartEvent)
*/
@Override
public void onTouchStart(TouchStartEvent event) {
scrollStartPosY = searchPage.getElement().getScrollTop()
+ event.getTouches().get(0).getPageY();
scrollStartPosX = searchPage.getElement().getScrollLeft()
+ event.getTouches().get(0).getPageX();
}

/* (non-Javadoc)
* @see com.google.gwt.event.dom.client.TouchMoveHandler#onTouchMove(com.google.gwt.event.dom.client.TouchMoveEvent)
*/
@Override
public void onTouchMove(TouchMoveEvent event) {
searchPage.getElement().setScrollTop(
scrollStartPosY - event.getTouches().get(0).getPageY());
searchPage.getElement().setScrollLeft(
scrollStartPosX - event.getTouches().get(0).getPageX());
event.preventDefault();
}







--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/0MDo7Yd2ZKsJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Reply all
Reply to author
Forward
0 new messages