return options.isScroll();
}
public void onDrag(DraggableHandler handler, DragContext ctx, GqEvent e) {
DraggableOptions options = handler.getOptions();
Element draggableElement = ctx.getDraggable();
GQuery scrollParent = handler.getHelperScrollParent();
Element scrollParentElement = scrollParent.get(0);
if (scrollParentElement == null) {
return;
}
AxisOption axis = options.getAxis();
Offset overflowOffset = $(draggableElement).data(OVERFLOW_OFFSET_KEY,
Offset.class);
int scrollSensitivity = options.getScrollSensitivity();
int scrollSpeed = options.getScrollSpeed();
boolean scrolled = false;
if (scrollParentElement != null
&& scrollParentElement != $(GQuery.document).get(0)
&& !"html".equalsIgnoreCase(scrollParentElement.getTagName())) {
if (AxisOption.NONE == axis || AxisOption.Y_AXIS == axis) {
// test if we have to scroll down...
if ((overflowOffset.top + scrollParentElement.getOffsetHeight())
- e.pageY() < scrollSensitivity) {
scrollParentElement.setScrollTop(scrollParentElement.getScrollTop()
+ scrollSpeed);
scrolled = true;
// test if we have to scroll up...
} else if (e.pageY() - overflowOffset.top < scrollSensitivity) {
scrollParentElement.setScrollTop(scrollParentElement.getScrollTop()
- scrollSpeed);
scrolled = true;
}
}
if (AxisOption.NONE == axis || AxisOption.X_AXIS == axis) {
// test if we have to scroll left...
if ((overflowOffset.left + scrollParentElement.getOffsetWidth())
- e.pageX() < scrollSensitivity) {
scrollParentElement.setScrollLeft(scrollParentElement.getScrollLeft()
+ scrollSpeed);
scrolled = true;
// test if we have to scroll right...
} else if (e.pageX() - overflowOffset.left < scrollSensitivity) {
scrollParentElement.setScrollLeft(scrollParentElement.getScrollLeft()
- scrollSpeed);
scrolled = true;
}
}