+ bool startMovingAnim = m_itemSize.isEmpty();
+ if (!startMovingAnim) {
+ // When having a grid the moving-animation should only be started, if it is done within
+ // one row in the vertical scroll-orientation or one column in the horizontal scroll-orientation.
+ // Otherwise instead of a moving-animation a create-animation on the new position will be used
+ // instead. This is done to prevent overlapping (and confusing) moving-animations.
+
+ int zoomDiff = 0;
+ if (widget->size() != itemBounds.size()) {
+ // The item-size has been increased or decreased
+ const bool zoomOut = (widget->size().width() >= itemBounds.size().width()) &&
+ (widget->size().height() >= itemBounds.size().height());
+ zoomDiff = zoomOut ? -1 : +1;
+ }
+
+ const qreal xMax = m_itemSize.width();
+ const qreal yMax = m_itemSize.height();
+ qreal xDiff = oldPos.x() - newPos.x();
+ qreal yDiff = oldPos.y() - newPos.y();
+ if (scrollOrientation() == Qt::Vertical) {
+ if (zoomDiff != 0) {
+ // Skip moving animations that changed the row
+ startMovingAnim = (zoomDiff > 0 && xDiff < xMax) ||
+ (zoomDiff < 0 && -xDiff < xMax);
+ } else {
+ xDiff = qAbs(xDiff);
+ yDiff = qAbs(yDiff);
+ startMovingAnim = (xDiff > yDiff && yDiff < yMax);
+ }
+ } else {
+ if (zoomDiff != 0) {
+ // Skip moving animations that changed the column
+ startMovingAnim = (zoomDiff > 0 && yDiff < yMax) ||
+ (zoomDiff < 0 && -yDiff < yMax);
+ } else {
+ xDiff = qAbs(xDiff);
+ yDiff = qAbs(yDiff);
+ startMovingAnim = (yDiff > xDiff && xDiff < xMax);
+ }
+ }
+ }
+