Skip to content

Commit

Permalink
Ensuring infinite scrolling does not collide with newly added lasso s…
Browse files Browse the repository at this point in the history
…upport.
  • Loading branch information
dlemmermann committed Sep 12, 2022
1 parent a732152 commit c9544cc
Showing 1 changed file with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ private void mousePressed(MouseEvent evt) {
return;
}

VirtualGrid availabilityGrid = dayViewBase.getAvailabilityGrid();
setLassoStart(grid(dayViewBase.getInstantAt(evt), availabilityGrid));
setLassoEnd(grid(dayViewBase.getInstantAt(evt), availabilityGrid).plus(availabilityGrid.getAmount(), availabilityGrid.getUnit()));
if (!dayViewBase.isScrollingEnabled()) {
VirtualGrid availabilityGrid = dayViewBase.getAvailabilityGrid();
setLassoStart(grid(dayViewBase.getInstantAt(evt), availabilityGrid));
setLassoEnd(grid(dayViewBase.getInstantAt(evt), availabilityGrid).plus(availabilityGrid.getAmount(), availabilityGrid.getUnit()));
}

dragMode = null;
handle = null;
Expand All @@ -186,7 +188,7 @@ private void mousePressed(MouseEvent evt) {
LOGGER.finer("mouse event y-coordinate:" + evt.getY());
LOGGER.finer("time: " + dayViewBase.getZonedDateTimeAt(evt.getX(), evt.getY(), dayViewBase.getZoneId()));

if (evt.getTarget() instanceof DayView) {
if (!dayViewBase.isScrollingEnabled() && evt.getTarget() instanceof DayView) {
Optional<Calendar> calendar = dayViewBase.getCalendarAt(evt.getX(), evt.getY());
Instant instantAt = dayViewBase.getInstantAt(evt);
ZonedDateTime time = ZonedDateTime.ofInstant(instantAt, dayViewBase.getZoneId());
Expand Down Expand Up @@ -274,14 +276,17 @@ private void mouseReleased(MouseEvent evt) {
return;
}

getOnLassoFinished().accept(getLassoStart(), getLassoEnd());
if (!dayViewBase.isScrollingEnabled()) {
getOnLassoFinished().accept(getLassoStart(), getLassoEnd());

setLassoStart(null);
setLassoEnd(null);
setLassoStart(null);
setLassoEnd(null);
}

if (!evt.getButton().equals(MouseButton.PRIMARY) || dragMode == null || !dragging) {
return;
}

dragging = false;

Calendar calendar = entry.getCalendar();
Expand Down Expand Up @@ -311,7 +316,9 @@ private void mouseReleased(MouseEvent evt) {
}

private void mouseDragged(MouseEvent evt) {
setLassoEnd(grid(dayViewBase.getInstantAt(evt), dayViewBase.getAvailabilityGrid()));
if (!dayViewBase.isScrollingEnabled()) {
setLassoEnd(grid(dayViewBase.getInstantAt(evt), dayViewBase.getAvailabilityGrid()));
}

if (!evt.getButton().equals(MouseButton.PRIMARY) || dragMode == null || !dragging) {
return;
Expand All @@ -322,12 +329,6 @@ private void mouseDragged(MouseEvent evt) {
return;
}

// if (dayViewBase.getDraggedEntry() == null || dayEntryView.getParent() == null) {
// // we might see "mouse dragged" events close before "mouse pressed". in this case, our drag/dro handling
// // has not been fully initialized yet.
// return;
// }

switch (dragMode) {
case START_TIME:
switch (handle) {
Expand Down

0 comments on commit c9544cc

Please sign in to comment.