* snapElement.setSnapping(false); continue; }
*/
continue;
}
Offset newTopDimension = null;
Offset newLeftDimension = null;
if (SnapMode.INNER != snapMode) {
boolean snapTop = Math.abs(snapElementTop - helperBottom) <= snapTolerance;
boolean snapBottom = Math.abs(snapElementBottom - helperTop) <= snapTolerance;
boolean snapLeft = Math.abs(snapElementLeft - helperRight) <= snapTolerance;
boolean snapRight = Math.abs(snapElementRight - helperLeft) <= snapTolerance;
if (snapTop) {
newTopDimension = handler.convertPositionTo(false,
new Offset(0, snapElementTop
- handler.getHelperDimension().getHeight()));
} else if (snapBottom) {
newTopDimension = handler.convertPositionTo(false,
new Offset(0, snapElementBottom));
}
if (snapLeft) {
newLeftDimension = handler.convertPositionTo(false,
new Offset(snapElementLeft
- handler.getHelperDimension().getWidth(), 0));
} else if (snapRight) {
newLeftDimension = handler.convertPositionTo(false,
new Offset(snapElementRight, 0));
}
}
if (SnapMode.OUTER != snapMode) {
boolean snapTop = Math.abs(snapElementTop - helperTop) <= snapTolerance;
boolean snapBottom = Math.abs(snapElementBottom - helperBottom) <= snapTolerance;
boolean snapLeft = Math.abs(snapElementLeft - helperLeft) <= snapTolerance;
boolean snapRight = Math.abs(snapElementRight - helperRight) <= snapTolerance;
if (snapTop) {
newTopDimension = handler.convertPositionTo(false,
new Offset(0, snapElementTop));
} else if (snapBottom) {
newTopDimension = handler.convertPositionTo(false,
new Offset(0, snapElementBottom
- handler.getHelperDimension().getHeight()));
}
if (snapLeft) {
newLeftDimension = handler.convertPositionTo(false,
new Offset(snapElementLeft, 0));
} else if (snapRight) {
newLeftDimension = handler.convertPositionTo(false,
new Offset(snapElementRight
- handler.getHelperDimension().getWidth(), 0));
}
}
if (newTopDimension != null) {
int newTop = newTopDimension.top - handler.getMargin().top;
int newLeft = handler.getPosition().left;
handler.setPosition(new Offset(newLeft, newTop));
}
if (newLeftDimension != null) {
int newTop = handler.getPosition().top;
int newLeft = newLeftDimension.left
- handler.getMargin().left;
handler.setPosition(new Offset(newLeft, newTop));
}
}
}