added automatic scrolling

This commit is contained in:
2026-05-02 23:05:50 +02:00
parent 8c49ac0066
commit b423885c55
4 changed files with 34 additions and 11 deletions
+2
View File
@@ -13,11 +13,13 @@
.custom-button:hover { .custom-button:hover {
border-color: white; border-color: white;
color: white;
} }
.custom-button.inactive { .custom-button.inactive {
opacity: 0.3; opacity: 0.3;
cursor: default; cursor: default;
color: black;
} }
.custom-button.inactive:hover { .custom-button.inactive:hover {
+21 -6
View File
@@ -15,26 +15,41 @@ function Bird_CNN() {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const fileInputRef = useRef(null); const fileInputRef = useRef(null);
const uploadButton = useRef(null); const uploadButton = useRef(null);
const scrollRef = useRef(null); const scrollRefClassifiction = useRef(null);
const scrollRefUploadButton = useRef(null);
const isPartiallyInViewport = (el) => {
if (!el) return false;
const rect = el.getBoundingClientRect();
return (
rect.top < window.innerHeight &&
rect.bottom > 0
);
};
const handleImageDivClick = () => { const handleImageDivClick = () => {
fileInputRef.current.click(); fileInputRef.current.click();
} }
const handleImage = (e) => { const handleImage = (e) => {
if (e.target.files[0]) { if (!e.target.files[0]) { return; }
setFile(e.target.files[0]); setFile(e.target.files[0]);
setPreview(URL.createObjectURL(e.target.files[0])); setPreview(URL.createObjectURL(e.target.files[0]));
uploadButton.current.classList.remove("inactive"); uploadButton.current.classList.remove("inactive");
}
scrollRefUploadButton.current.scrollIntoView({ behavior: "smooth" });
setConfidence(null); setConfidence(null);
setBirdClass(null); setBirdClass(null);
}; };
const sendImage = async (e) => { const sendImage = async (e) => {
if (!file) return; if (!file) return;
scrollRef.current.scrollIntoView({ behavior: "smooth" }); scrollRefClassifiction.current.scrollIntoView({ behavior: "smooth" });
const formData = new FormData(); const formData = new FormData();
formData.append("file", file); formData.append("file", file);
@@ -76,7 +91,7 @@ function Bird_CNN() {
</div> </div>
<div className='request-box' style={{ height: "800px", width: "700px", display: "flex", flexDirection: "column", alignItems: "center", flex: "0 0 auto", margin: "100px 50px 0px 50px" }}> <div className='request-box' style={{ height: "800px", width: "700px", display: "flex", flexDirection: "column", alignItems: "center", flex: "0 0 auto", margin: "100px 50px 0px 50px" }}>
<div className='input-box' style={{ marginBottom: "80px", width: "500px", height: "40px", display: "flex", justifyContent: "space-evenly", alignItems: "center" }}> <div ref={scrollRefUploadButton} className='input-box' style={{ scrollMarginTop: "100px", marginBottom: "80px", width: "500px", height: "40px", display: "flex", justifyContent: "space-evenly", alignItems: "center" }}>
<div> <div>
<input disabled={loading} ref={fileInputRef} type="file" id='fileUpload' accept="image/jpeg" onChange={handleImage} style={{ display: "none" }} /> <input disabled={loading} ref={fileInputRef} type="file" id='fileUpload' accept="image/jpeg" onChange={handleImage} style={{ display: "none" }} />
<label htmlFor="fileUpload" className="custom-button"> <label htmlFor="fileUpload" className="custom-button">
@@ -102,7 +117,7 @@ function Bird_CNN() {
/> />
</div> </div>
<div ref={scrollRef} style={{ paddingTop: "10px", marginTop: "30px", width: "85px", height: "35px", display: "flex", justifyContent: "center", minHeight: "25px", minWidth: "85px" }}> <div ref={scrollRefClassifiction} style={{ scrollMarginTop: "100px", paddingTop: "10px", marginTop: "30px", width: "85px", height: "35px", display: "flex", justifyContent: "center", minHeight: "25px", minWidth: "85px" }}>
{loading && <div className='loader'></div>} {loading && <div className='loader'></div>}
</div> </div>
+1 -1
View File
@@ -1,7 +1,7 @@
function Homepage() { function Homepage() {
return ( return (
<> <>
<p>Homepage</p> <h1 style={{ margin: "120px 40px 40px 40px" }}>Ignore this page</h1>
</> </>
); );
} }
+6
View File
@@ -6,7 +6,13 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
border-bottom: 1px solid rgb(47, 168, 208); border-bottom: 1px solid rgb(47, 168, 208);
position: fixed;
top: 0;
left: 0;
z-index: 10;
background: rgb(4, 0, 10);
} }
.navbar-item { .navbar-item {
text-decoration: none; text-decoration: none;
height: 80px; height: 80px;