|
@@ -9,9 +9,12 @@ import Button from '@mui/material/Button';
|
9
|
9
|
import Collapse from '@mui/material/Collapse';
|
10
|
10
|
import List from '@mui/material/List';
|
11
|
11
|
import { TransitionGroup } from 'react-transition-group';
|
|
12
|
+import * as Scroll from 'react-scroll';
|
12
|
13
|
|
13
|
14
|
export function Cleaver() {
|
14
|
15
|
|
|
16
|
+var scroll = Scroll.animateScroll;
|
|
17
|
+
|
15
|
18
|
let auth = useAuth();
|
16
|
19
|
let token = useMemo(() => auth.getToken(), [auth])
|
17
|
20
|
|
|
@@ -30,28 +33,20 @@ export function Cleaver() {
|
30
|
33
|
}, [token]);
|
31
|
34
|
|
32
|
35
|
const handleAddQuestion = () => {
|
|
36
|
+ let op = { smooth: true, duration: 200, delay :1, offset :900}
|
|
37
|
+ scroll.scrollToBottom(op);
|
33
|
38
|
let currentAnswer = totalRespondidas[totalRespondidas.length - 1];
|
34
|
39
|
const nextHiddenItem = totalPreguntas.filter(({id}) => id !== currentAnswer.id );
|
35
|
40
|
if (nextHiddenItem) {
|
36
|
41
|
setPreguntas(nextHiddenItem);
|
37
|
42
|
let temp = nextHiddenItem.shift()
|
38
|
43
|
setRespondidas([...totalRespondidas,temp]);
|
39
|
|
- console.log('RESPONDIDAS: ', totalRespondidas)
|
40
|
|
- scrollToBottom();
|
41
|
44
|
}
|
42
|
45
|
};
|
43
|
46
|
|
44
|
|
- let last = useRef(null)
|
45
|
47
|
|
46
|
|
-const scrollToBottom = () => {
|
47
|
|
- if(last.current){
|
48
|
|
- last.current.scrollIntoView()
|
49
|
|
- }
|
50
|
|
- }
|
|
48
|
+var scroll = Scroll.animateScroll;
|
51
|
49
|
|
52
|
|
- // useEffect(() => {
|
53
|
|
- // scrollToBottom()
|
54
|
|
- // }, [totalRespondidas]);
|
55
|
50
|
|
56
|
51
|
return (
|
57
|
52
|
|
|
@@ -71,7 +66,6 @@ const scrollToBottom = () => {
|
71
|
66
|
</Box>
|
72
|
67
|
|
73
|
68
|
<Button
|
74
|
|
- ref={last}
|
75
|
69
|
variant="contained"
|
76
|
70
|
disabled={totalRespondidas.length >= totalPreguntas.length}
|
77
|
71
|
onClick={handleAddQuestion}
|