Browse Source

Revert "Fixed touch scrolling issue in Surface and WP devices (#18737)"

The patch prevents Escalator and Grid from ever being rendered on IE8 because element.addEventListener does not exist there

This reverts commit eb2f5ac3a7.

Change-Id: I58f6db7432a1cd10299891b2d8c55c855e87265f
tags/7.7.4
Artur Signell 7 years ago
parent
commit
9726f1581a

+ 0
- 4
client/src/main/java/com/vaadin/client/BrowserInfo.java View File

return browserDetails.isEdge(); return browserDetails.isEdge();
} }


public boolean isIEOrEdge() {
return browserDetails.isIE() || browserDetails.isEdge();
}

public boolean isFirefox() { public boolean isFirefox() {
return browserDetails.isFirefox(); return browserDetails.isFirefox();
} }

+ 4
- 76
client/src/main/java/com/vaadin/client/widgets/Escalator.java View File

} }


int pagePosition(CustomTouchEvent event) { int pagePosition(CustomTouchEvent event) {
// Use native event's screen x and y for IEs and Edge
// since there is no touches for these browsers (#18737)
if (BrowserInfo.get().isIEOrEdge()) {
return vertical
? event.getNativeEvent().getClientY()
+ Window.getScrollTop()
: event.getNativeEvent().getClientX()
+ Window.getScrollLeft();
}
JsArray<Touch> a = event.getNativeEvent().getTouches(); JsArray<Touch> a = event.getNativeEvent().getTouches();
return vertical ? a.get(0).getPageY() : a.get(0).getPageX(); return vertical ? a.get(0).getPageY() : a.get(0).getPageX();
} }
}; };


public void touchStart(final CustomTouchEvent event) { public void touchStart(final CustomTouchEvent event) {
if (allowTouch(event)) {
if (event.getNativeEvent().getTouches().length() == 1) {
if (yMov == null) { if (yMov == null) {
yMov = new Movement(true); yMov = new Movement(true);
xMov = new Movement(false); xMov = new Movement(false);
} }
} }


// Allow touchStart for IE and Edge even though there is no touch
// (#18737),
// otherwise allow touch only if there is a single touch in the
// event
private boolean allowTouch(final CustomTouchEvent event) {
return BrowserInfo.get().isIEOrEdge()
|| event.getNativeEvent().getTouches().length() == 1;
}

private double easingInOutCos(double val, double max) { private double easingInOutCos(double val, double max) {
return 0.5 - 0.5 * Math.cos(Math.PI * Math.signum(val) return 0.5 - 0.5 * Math.cos(Math.PI * Math.signum(val)
* Math.min(Math.abs(val), max) / max); * Math.min(Math.abs(val), max) / max);


public native void attachTouchListeners(Element element) public native void attachTouchListeners(Element element)
/* /*
* Attaching events with JSNI instead of the GWT event mechanism because
* Detaching events with JSNI instead of the GWT event mechanism because
* GWT didn't provide enough details in events, or triggering the event * GWT didn't provide enough details in events, or triggering the event
* handlers with GWT bindings was unsuccessful. Maybe, with more time * handlers with GWT bindings was unsuccessful. Maybe, with more time
* and skill, it could be done with better success. JavaScript overlay * and skill, it could be done with better success. JavaScript overlay
} }
}-*/; }-*/;


/**
* Using mousedown, mousemove, and mouseup for IE and Edge instead of
* touch* listeners (#18737)
*
* @param element
*/
public native void attachMouseDragListeners(Element element)
/*
* Attaching events with JSNI instead of the GWT event mechanism because
* GWT didn't provide enough details in events, or triggering the event
* handlers with GWT bindings was unsuccessful. Maybe, with more time
* and skill, it could be done with better success. JavaScript overlay
* types might work. This might also get rid of the JsniWorkaround
* class.
*/
/*-{
element.addEventListener("mousedown", this.@com.vaadin.client.widgets.JsniWorkaround::touchStartFunction);
element.addEventListener("mousemove", this.@com.vaadin.client.widgets.JsniWorkaround::touchMoveFunction);
element.addEventListener("mouseup", this.@com.vaadin.client.widgets.JsniWorkaround::touchEndFunction);
}-*/;

/**
* Using mousedown, mousemove, and mouseup for IE and Edge instead of
* touch* listeners (#18737)
*
* @param element
*/
public native void detachMouseDragListeners(Element element)
/*
* Detaching events with JSNI instead of the GWT event mechanism because
* GWT didn't provide enough details in events, or triggering the event
* handlers with GWT bindings was unsuccessful. Maybe, with more time
* and skill, it could be done with better success. JavaScript overlay
* types might work. This might also get rid of the JsniWorkaround
* class.
*/
/*-{
element.removeEventListener("mousedown", this.@com.vaadin.client.widgets.JsniWorkaround::touchStartFunction);
element.removeEventListener("mousemove", this.@com.vaadin.client.widgets.JsniWorkaround::touchMoveFunction);
element.removeEventListener("mouseup", this.@com.vaadin.client.widgets.JsniWorkaround::touchEndFunction);
}-*/;

public void scrollToColumn(final int columnIndex, public void scrollToColumn(final int columnIndex,
final ScrollDestination destination, final int padding) { final ScrollDestination destination, final int padding) {
assert columnIndex >= columnConfiguration.frozenColumns : "Can't scroll to a frozen column"; assert columnIndex >= columnConfiguration.frozenColumns : "Can't scroll to a frozen column";
scroller.attachScrollListener(verticalScrollbar.getElement()); scroller.attachScrollListener(verticalScrollbar.getElement());
scroller.attachScrollListener(horizontalScrollbar.getElement()); scroller.attachScrollListener(horizontalScrollbar.getElement());
scroller.attachMousewheelListener(getElement()); scroller.attachMousewheelListener(getElement());

if (BrowserInfo.get().isIEOrEdge()) {
// Touch listeners doesn't work for IE and Edge (#18737)
scroller.attachMouseDragListeners(getElement());
} else {
scroller.attachTouchListeners(getElement());
}
scroller.attachTouchListeners(getElement());
} }


@Override @Override
scroller.detachScrollListener(verticalScrollbar.getElement()); scroller.detachScrollListener(verticalScrollbar.getElement());
scroller.detachScrollListener(horizontalScrollbar.getElement()); scroller.detachScrollListener(horizontalScrollbar.getElement());
scroller.detachMousewheelListener(getElement()); scroller.detachMousewheelListener(getElement());

if (BrowserInfo.get().isIEOrEdge()) {
// Touch listeners doesn't work for IE and Edge (#18737)
scroller.detachMouseDragListeners(getElement());
} else {
scroller.detachTouchListeners(getElement());
}
scroller.detachTouchListeners(getElement());


/* /*
* We can call paintRemoveRows here, because static ranges are simple to * We can call paintRemoveRows here, because static ranges are simple to

+ 0
- 3
themes/src/main/themes/VAADIN/themes/base/escalator/escalator.scss View File

} }


.#{$primaryStyleName}-body { .#{$primaryStyleName}-body {
-ms-touch-action: none;
touch-action: none;

z-index: 0; z-index: 0;
top: 0; top: 0;



Loading…
Cancel
Save