From 66f40960a4e4e4d5f9ea6c1b9c69b9d4d31053cb Mon Sep 17 00:00:00 2001 From: kycarr Date: Fri, 16 Aug 2019 14:38:58 -0700 Subject: [PATCH] testing without autoscroll (#97) * fix bug where clicking topic buttons or panel buttons doesn't work on iPhone X in PAL3 * smooth animation of auto scroll for Chrome and Firefox --- client/src/components/input.jsx | 1 + client/src/components/questions.jsx | 16 ++--- client/src/components/scrolling-questions.jsx | 68 +++++++++++-------- client/src/styles/layout.css | 8 ++- 4 files changed, 53 insertions(+), 40 deletions(-) diff --git a/client/src/components/input.jsx b/client/src/components/input.jsx index 24efc006..f685173b 100644 --- a/client/src/components/input.jsx +++ b/client/src/components/input.jsx @@ -33,6 +33,7 @@ const Input = ({ height, ...props }) => { } dispatch(sendQuestion(text)); setText(""); + window.focus(); }; // Input field key was entered (check if user hit enter) diff --git a/client/src/components/questions.jsx b/client/src/components/questions.jsx index b67d993f..dfe63898 100644 --- a/client/src/components/questions.jsx +++ b/client/src/components/questions.jsx @@ -1,6 +1,5 @@ import React from "react"; import { useSelector } from "react-redux"; -import { List } from "@material-ui/core"; import { MuiThemeProvider, createMuiTheme } from "@material-ui/core/styles"; import ScrollingQuestions from "components/scrolling-questions"; @@ -42,14 +41,13 @@ const Questions = ({ height, onSelected }) => { return ( - - - + ); }; diff --git a/client/src/components/scrolling-questions.jsx b/client/src/components/scrolling-questions.jsx index a7714b78..78dd1168 100644 --- a/client/src/components/scrolling-questions.jsx +++ b/client/src/components/scrolling-questions.jsx @@ -1,10 +1,11 @@ import React, { useEffect } from "react"; -import { ListItem, ListItemText } from "@material-ui/core"; +import { List, ListItem, ListItemText } from "@material-ui/core"; import { Whatshot } from "@material-ui/icons"; import { normalizeString } from "funcs/funcs"; const ScrollingQuestions = ({ + height, questions, questions_asked, recommended, @@ -14,41 +15,50 @@ const ScrollingQuestions = ({ const top_question = questions.find(q => { return !questions_asked.includes(normalizeString(q)); }); - + const parent = document.getElementById("scrolling-questions-list"); const node = document.getElementById(top_question); - if (!(top_question && node)) { + if (!(parent && node)) { return; } - - node.scrollIntoView({ + parent.scrollTo({ behavior: "smooth", - block: "start", + top: node.offsetTop, + left: 0, }); - }); + }, [questions, questions_asked]); - return questions.map((question, i) => ( - onQuestionSelected(question)} + return ( + - - {recommended.includes(question) ? ( - - ) : ( - undefined - )} - {question} - - - )); + {questions.map((question, i) => ( + onQuestionSelected(question)} + > + + {recommended.includes(question) ? ( + + ) : ( + undefined + )} + {question} + + + ))} + + ); }; export default ScrollingQuestions; diff --git a/client/src/styles/layout.css b/client/src/styles/layout.css index c6079c58..0c5008f4 100644 --- a/client/src/styles/layout.css +++ b/client/src/styles/layout.css @@ -2,6 +2,7 @@ body { height: 100%; margin: 0; text-align: center; + -webkit-overflow-scrolling: touch; } #video-container { position: relative; @@ -24,15 +25,18 @@ body { } .expand { flex: 1 1; - -webkit-overflow-scrolling: touch; +} +.scroll { + overflow-y: auto; + -webkit-overflow-scrolling: touch; } .carousel { width: 100%; overflow-x: visible; overflow-y: hidden; - white-space: nowrap; -webkit-overflow-scrolling: touch; + white-space: nowrap; } .carousel .slide { position: relative;