Closed xiaosongmao123 closed 3 years ago
I fixed the second error, it was purely my jamb from the very first version. But the error was a bit different. What about onTapDown, it is not a down-click event, it's a mouse button release event, and at this point I end the slider movement. About the first error, I need to think a little, since this appeared exactly after the last update, and I did not change the code associated with this
Vertical scroll bar height calculation and display
i use a tree for filelist (click dir name ,show childs)
show issue
hide issue
Look at the picture carefully,we can find out, When clicking dirname,show the childs (height changed) the ScrollSlider‘s height is not correct ,because when me move the mouse hover on ScrollSlider, it's height will auto refresh
not follow the scrolling,height calculation and display They all seem to be one issue -- need a last refresh
As I understand it, the remaining problems are related to the fact that old data remains in the controller. The problem is that before the update it most likely worked correctly, so at the moment there are difficulties with the fix. I will try to fix it as soon as i can
i test to change the first AdaptiveScrollbar to position: ScrollbarPosition.bottom (horizontalScroll) the second AdaptiveScrollbar be right (verticalScroll)
now all the issue change to horizontal Scrollbar ,(horizontal Scrollbar not follow the scrolling)
@override
Widget build(BuildContext context) {
//return _buildTreeView();
return AdaptiveScrollbar(
controller: horizontalScroll,
width: 12,
sliderActiveColor: Color(0xdd757575),
bottomDecoration: BoxDecoration(shape: BoxShape.rectangle, color: Color(0x88e0e0e0)),
sliderDecoration:
BoxDecoration(shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(12), color: Color(0xffaaaaaa)),
//changed
position: ScrollbarPosition.bottom,
bottomPadding: EdgeInsets.only(bottom: 12),
//changed
child: AdaptiveScrollbar(
controller: verticalScroll,
width: 12,
sliderActiveColor: Color(0xdd757575),
bottomDecoration: BoxDecoration(shape: BoxShape.rectangle, color: Color(0x88e0e0e0)),
sliderDecoration: BoxDecoration(
shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(12), color: Color(0xffaaaaaa)),
child: SingleChildScrollView(
Anyway, thanks for your work, it helped me a lot
i found why Scrollbar don't work well
//1. onscroll
onNotification: (ScrollNotification notification) {
print('onNotification ' + notification.metrics.pixels.toString());
return sendToScrollUpdate(notification.metrics.pixels);
}
//2.add event
sendToScrollUpdate(double position) {
print("sendToScrollUpdate " + position.toString());
scrollSubject.add(true);
return true;
}
//3.recive event
streamSubscriptionScroll = widget.scrollSubject.listen((value) {
print('streamSubscriptionScroll ' + value.toString());
onScrollUpdate();
});
//4 update ScrollSlider
code is right , but 3.recive event Does not trigger
i don't know why,but as the same work , streamSubscriptionClick = widget.clickSubject.listen((value) { work well
I debugged it several times,scrollSubject don't work, clickSubject work well
I've also tried convert scrollSubject to BehaviorSubject
)
/// Used for transmitting information about scrolls to the [ScrollSlider].
BehaviorSubject<double> scrollSubject = BehaviorSubject<double>();
/// Used for transmitting information about clicks to the [ScrollSlider].
BehaviorSubject<double> clickSubject = BehaviorSubject<double>();
I've also tried use clickSubject to transmit event,then clickSubject don’t work too
sendToScrollUpdate(double position) {
print("sendToScrollUpdate " + position.toString());
scrollSubject.add(position);
clickSubject.add(-999999);
return true;
}
====== Maybe it's because Notification add too often? Maybe rxdart error? (20210507 0.27.0)
I think that the scroll events that are sent to the NotificationListener are caught only in the one widget, and do not reach the second NotificationListener. And this problem appeared after the update. I think how to fix it.
I seem to have fixed both issues. you can view and test version 1.0.1
And what about your problem with tree for filelist? i can't have any similar code to test. I solved these 2 problems, but I don't know if the scrollbar reacts to the size change when opening your tree
i tested, it's ok ,
I've used it in the project
Thank you for your help and Thank you for your time
Multiple scrollbars error not follow the scrolling and Trigger onTapDown event error
When I use multiple scrollbars,on Windows 10 ,desktop app:
1 Multiple scrollbars error not follow the scrolling
Vertical scroll bar display error:
Scroll the mouse wheel on the list and scroll down the list. At this time, the right vertical scroll bar does not follow the scroll. Only when you move the mouse over the scroll bar, it will automatically trigger refresh, and the scroll bar will be displayed in the correct position
Press the left mouse button on the list and drag up to scroll up the list. At this time, the right vertical scroll bar does not follow the scrolling, only move the mouse over the scroll bar, it will automatically trigger refresh, and the scroll bar will be displayed in the correct position
But The horizontal scroll bar is displayed correctly:
2 Multiple scrollbars Trigger onTapDown event error
Vertical scroll and horizontal scroll have same error
Expected: ScrollSlider does not move,because ScrollSlider is for Drag,not for click Reality:ScrollSlider's Parent Widget(GestureDetector) Trigger the onTapDown event,and the ScrollSlider move to position
Whatever it is click or Hold down the left mouse button ,is the same ,ScrollSlider move
i think it's because adaptive_scrollbar.dart line : 188
here is my test code