diff --git a/src/animations/baranimation.cpp b/src/animations/baranimation.cpp index a16a26d..8dc4056 100644 --- a/src/animations/baranimation.cpp +++ b/src/animations/baranimation.cpp @@ -45,10 +45,22 @@ QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qr Q_ASSERT(startVector.count() == endVector.count()); for(int i = 0; i < startVector.count(); i++) { - qreal w = endVector[i].width(); - qreal h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress); - qreal x = endVector[i].topLeft().x(); - qreal y = endVector[i].topLeft().y() + endVector[i].height() - h; + QRectF start = startVector[i].normalized(); + QRectF end = endVector[i].normalized(); + + qreal x = end.left(); + qreal y; + qreal w = end.width(); + qreal h; + + if (endVector[i].height() < 0) { + // Negative bar + y = end.top(); + h = start.height() + ((end.height() - start.height()) * progress); + } else { + h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress); + y = endVector[i].top() + endVector[i].height() - h; + } QRectF value(x,y,w,h); result << value.normalized(); diff --git a/src/animations/horizontalbaranimation.cpp b/src/animations/horizontalbaranimation.cpp index eda9e05..d03802a 100644 --- a/src/animations/horizontalbaranimation.cpp +++ b/src/animations/horizontalbaranimation.cpp @@ -46,10 +46,22 @@ QVariant HorizontalBarAnimation::interpolated(const QVariant &from, const QVaria Q_ASSERT(startVector.count() == endVector.count()); for(int i = 0; i < startVector.count(); i++) { - qreal h = endVector[i].height(); - qreal w = startVector[i].width() + ((endVector[i].width() - startVector[i].width()) * progress); - qreal x = endVector[i].left(); - qreal y = endVector[i].top(); + QRectF start = startVector[i].normalized(); + QRectF end = endVector[i].normalized(); + + qreal x; + qreal y = end.top(); + qreal w; + qreal h = end.height(); + + if (endVector[i].width() < 0) { + // Negative bar + w = start.width() + ((end.width() - start.width()) * progress); + x = endVector[i].right() - endVector[i].width() - w; + } else { + w = startVector[i].width() + ((endVector[i].width() - startVector[i].width()) * progress); + x = end.left(); + } QRectF value(x,y,w,h); result << value.normalized();