Skip to content

Commit db0588e

Browse files
authored
Merge pull request zhuzichu520#588 from Polaris-Night/main
修复FluCarousel手动翻页的问题
2 parents 7a6efa4 + 99f6b16 commit db0588e

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

src/Qt5/imports/FluentUI/Controls/FluCarousel.qml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Item {
2424
}
2525
QtObject{
2626
id:d
27-
property bool flagXChanged: true
27+
property bool flagXChanged: false
2828
property bool isAnimEnable: control.autoPlay && list_view.count>3
2929
function setData(data){
3030
if(!data){
@@ -88,14 +88,17 @@ Item {
8888
}
8989
}
9090
onMovementEnded:{
91+
d.flagXChanged = false
92+
list_view.highlightMoveDuration = 0
9193
currentIndex = list_view.contentX/list_view.width
9294
if(currentIndex === 0){
9395
currentIndex = list_view.count-2
9496
}else if(currentIndex === list_view.count-1){
9597
currentIndex = 1
9698
}
97-
d.flagXChanged = false
98-
timer_run.restart()
99+
if(d.isAnimEnable){
100+
timer_run.restart()
101+
}
99102
}
100103
onMovementStarted: {
101104
d.flagXChanged = true
@@ -104,12 +107,12 @@ Item {
104107
onContentXChanged: {
105108
if(d.flagXChanged){
106109
var maxX = Math.min(list_view.width*(currentIndex+1),list_view.count*list_view.width)
107-
var minY = Math.max(0,(list_view.width*(currentIndex-1)))
110+
var minX = Math.max(0,(list_view.width*(currentIndex-1)))
108111
if(contentX>=maxX){
109112
contentX = maxX
110113
}
111-
if(contentX<=minY){
112-
contentX = minY
114+
if(contentX<=minX){
115+
contentX = minX
113116
}
114117
}
115118
}

src/Qt5/imports/FluentUI/Controls/FluProgressBar.qml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ ProgressBar{
1414
id:d
1515
property real _radius: strokeWidth/2
1616
}
17-
onIndeterminateChanged:{
18-
if(!indeterminate){
19-
animator_x.duration = 0
20-
rect_progress.x = 0
21-
animator_x.duration = control.duration
22-
}
23-
}
2417
background: Rectangle {
2518
implicitWidth: 150
2619
implicitHeight: control.strokeWidth
@@ -45,6 +38,11 @@ ProgressBar{
4538
id: animator_x
4639
running: control.indeterminate && control.visible
4740
loops: Animation.Infinite
41+
onRunningChanged: {
42+
if(!running){
43+
rect_progress.x = 0
44+
}
45+
}
4846
PropertyAnimation {
4947
from: -rect_progress.width
5048
to: control.width + rect_progress.width

src/Qt6/imports/FluentUI/Controls/FluCarousel.qml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Item {
2424
}
2525
QtObject{
2626
id:d
27-
property bool flagXChanged: true
27+
property bool flagXChanged: false
2828
property bool isAnimEnable: control.autoPlay && list_view.count>3
2929
function setData(data){
3030
if(!data){
@@ -88,14 +88,17 @@ Item {
8888
}
8989
}
9090
onMovementEnded:{
91+
d.flagXChanged = false
92+
list_view.highlightMoveDuration = 0
9193
currentIndex = list_view.contentX/list_view.width
9294
if(currentIndex === 0){
9395
currentIndex = list_view.count-2
9496
}else if(currentIndex === list_view.count-1){
9597
currentIndex = 1
9698
}
97-
d.flagXChanged = false
98-
timer_run.restart()
99+
if(d.isAnimEnable){
100+
timer_run.restart()
101+
}
99102
}
100103
onMovementStarted: {
101104
d.flagXChanged = true
@@ -104,12 +107,12 @@ Item {
104107
onContentXChanged: {
105108
if(d.flagXChanged){
106109
var maxX = Math.min(list_view.width*(currentIndex+1),list_view.count*list_view.width)
107-
var minY = Math.max(0,(list_view.width*(currentIndex-1)))
110+
var minX = Math.max(0,(list_view.width*(currentIndex-1)))
108111
if(contentX>=maxX){
109112
contentX = maxX
110113
}
111-
if(contentX<=minY){
112-
contentX = minY
114+
if(contentX<=minX){
115+
contentX = minX
113116
}
114117
}
115118
}

src/Qt6/imports/FluentUI/Controls/FluProgressBar.qml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ ProgressBar{
1515
id:d
1616
property real _radius: strokeWidth/2
1717
}
18-
onIndeterminateChanged:{
19-
if(!indeterminate){
20-
animator_x.duration = 0
21-
rect_progress.x = 0
22-
animator_x.duration = control.duration
23-
}
24-
}
2518
background: Rectangle {
2619
implicitWidth: 150
2720
implicitHeight: control.strokeWidth
@@ -46,6 +39,11 @@ ProgressBar{
4639
id: animator_x
4740
running: control.indeterminate && control.visible
4841
loops: Animation.Infinite
42+
onRunningChanged: {
43+
if(!running){
44+
rect_progress.x = 0
45+
}
46+
}
4947
PropertyAnimation {
5048
from: -rect_progress.width
5149
to: control.width + rect_progress.width

0 commit comments

Comments
 (0)