Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
95
rated 0 times [  99] [ 4]  / answers: 1 / hits: 5174  / 6 Years ago, thu, november 22, 2018, 12:00:00

Can someone please help?
This is my code: https://codesandbox.io/s/5xoj9zw56l



I followed this code: https://codesandbox.io/s/6jr75xj8y3


More From » reactjs

 Answers
1

Drawer creates an elements, it will have structure like this



parent div > nested div > your data


And while getting the ref into drawer you do not get that div reference which you need to scroll.



What you need to do is you can add ref to your data div and go through ref.parent this way you will have parent div ref and there you can scroll the element.



To scroll you must have ref of div where you applied the overflow.



Here is the changes you need to do



Instead of container you will get aprent element



handleScrollTo = () => {

console.log(this.container.parentElement.scrollTop);
this.container.parentElement.scrollTop = 200;
};


instead of using ref on drawer using the data on scroll



<Drawer open={this.state.left} onClose={this.toggleDrawer( left, false)} onScroll={e=> console.log(scroll  + e.target.scrollTop)} >
<div ref={el=> (this.container = el)} tabIndex={1} role=button onKeyDown={this.toggleDrawer(left, false)} > {sideList} </div>
</Drawer>


Here is demo link


[#10183] Wednesday, November 21, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ryderalfonsos

Total Points: 655
Total Questions: 88
Total Answers: 91

Location: Nauru
Member since Thu, Feb 2, 2023
1 Year ago
ryderalfonsos questions
Mon, Sep 9, 19, 00:00, 5 Years ago
Wed, Feb 13, 19, 00:00, 5 Years ago
Tue, Feb 12, 19, 00:00, 5 Years ago
Fri, Dec 28, 18, 00:00, 6 Years ago
;