'Prevent safari mobile address bar from hiding when canvas is touched
Hello please someone help me with this. I want to prevent the safari address bar on my mobile from hiding whenever I interact with the canvas. what happens is that when I rotate my modal on canvas on mobile the browser detects that I am scrolling and hides the apple safari bar but in reality I am just rotating the modal not scrolling.
I tried to add a touch-action property to none on canvas but no vail.
Please help me with this.
// MAIN CANVAS COMPONENT
import React from 'react';
import {OrbitControls, OrthographicCamera } from "@react-three/drei";
import { Canvas } from "@react-three/fiber";
import { Suspense } from "react";
import Scene from "./Scene";
import "./style.css"
function Ring() {
return (
<Canvas className="canvas" colorManagement>
<Suspense fallback={null}>
<Scene />
<OrbitControls enableZoom={false} enableRotate={true} rotateSpeed={0.3} />
<ambientLight intensity={0.6} />
<pointLight color="#f6f3ea" position={[2, 0, 2]} intensity={0.7} />
<OrthographicCamera
makeDefault
zoom={20}
near={1}
far={1000}
position={[0, 0, 200]}
/>
</Suspense>
</Canvas>
)
}
export default Ring
// CANVAS CSS
//.canvas {
// width: 50% !important;
// overflow: hidden !important;
// touch-action: none !important;
// margin: 0 auto !important;
// height: 100vh;
//}
// COMPONENT WHERE CANVAS IS USED
import React from "react";
import arrowDown from "../../assets/arrowDown.svg";
import Logo from "../../assets/logo.png";
import scrollToComponent from "react-scroll-to-component";
import Ring from "./Ring";
import Media from "react-media"
const Hero = () => {
return (
<>
<div className="hero" id="hero">
<div style={{width: '100%', height: '100%'}}>
<div className="logo-wrapper">
<Media queries={{
extraSmall: "(max-width: 330px)",
small: "(min-width: 330px) and (max-width: 599px)",
medium: "(min-width: 600px) and (max-width: 1199px)",
large: "(min-width: 1200px)"
}}>
{matches => (
<div>
{matches.extraSmall &&
<img
style={{position: 'absolute', zIndex: '1',touchAction: 'none', overflow: 'hidden', pointerEvents: 'none', margin: '0 auto', top: '47%', left: '0', right: '0', width: '250px'}}
src={Logo}
alt="Brand Logo" />
}
{matches.small &&
<img
style={{position: 'absolute', zIndex: '1',touchAction: 'none', overflow: 'hidden', pointerEvents: 'none', margin: '0 auto', top: '47%', left: '0', right: '0', width: '300px'}}
src={Logo}
alt="Brand Logo" />
}
{matches.medium &&
<img
style={{position: 'absolute', zIndex: '1',touchAction: 'none', overflow: 'hidden', pointerEvents: 'none', margin: 'auto', top: '0', left: '0', right: '0', bottom: '0', width: '400px'}}
src={Logo}
alt="Brand Logo" />
}
{matches.large &&
<img
style={{position: 'absolute', zIndex: '1',touchAction: 'none', overflow: 'hidden', pointerEvents: 'none', margin: 'auto', top: '0', left: '0', right: '0', bottom: '0', width: '500px'}}
src={Logo}
alt="Brand Logo" />
}
</div>
)}
</Media>
<Ring />
<div className="overlay"></div>
</div>
<div className="scroll-btn">
<img
onClick={() =>
scrollToComponent(document.querySelector("#launch"), {
offset: 0,
align: "top",
duration: 250,
ease: "inExpo",
})
}
src={arrowDown}
alt=""
className="arrow-down"
/>
</div>
</div>
</div>
</>
);
};
export default Hero;
Solution 1:[1]
It is very simple.
- configure your bucket to be used to serve static content. You can find the steps here.
- configure your build process to add your static files to the react bundle.
- build your react app and upload the dist/build folder to the root of the bucket.
That will allow you to serve your static files and your Rect App from S3. Your URL will be a little bit ugly: it will be something like: http://bucket-name.s3-website-region.amazonaws.com.
If you want to have a special URL, like www,yourappname.com you'll need to perform a few more steps:
- You'll need to create an SSL public certificate.
- You'll need to configure a CloudFront Distribution.
Here you can find more info about these extra steps.
IMPORTANT: S3 does not support Express/Node. For that, you'll need a web server.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gustavo Tavares |
