make video can change position and js handle select character
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
67d9c6f1d9
commit
4d22f2ca0b
3 changed files with 149 additions and 38 deletions
|
@ -3,18 +3,27 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
} */
|
} */
|
||||||
.video-container {
|
.video-container {
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 0;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
width: 100%;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
@media only screen and (max-device-width: 600px) {
|
||||||
@media (orientation: landscape) {
|
.video-container.middle {
|
||||||
.video-container {
|
width: 200%;
|
||||||
position: absolute;
|
height: 150vh;
|
||||||
top: 50%;
|
left: 0%;
|
||||||
left: 50%;
|
}
|
||||||
transform: translate(-50%, -50%);
|
.video-container.left {
|
||||||
width: 100%;
|
width: 300%;
|
||||||
height: 100%;
|
left: 0%;
|
||||||
|
}
|
||||||
|
.video-container.right {
|
||||||
|
width: 200%;
|
||||||
|
left: -100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import '../../css/video.css';
|
import '../../css/video.css';
|
||||||
|
|
||||||
function PlayVideo({ src = "hallway_FFF.mp4", onVideoReady }) {
|
function PlayVideo({ src = "hallway_MMM.mp4" ,side = "middle", onVideoReady }) {
|
||||||
const urlSource = `${import.meta.env.VITE_ASSETS_URL}/${src}`;
|
const urlSource = `${import.meta.env.VITE_ASSETS_URL}/${src}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="video-container">
|
<div className={`video-container ${side}`}>
|
||||||
<video
|
<video
|
||||||
autoPlay
|
autoPlay
|
||||||
muted
|
muted
|
||||||
|
|
|
@ -5,29 +5,24 @@ import Animation from './components/animation.jsx';
|
||||||
import PlayVideo from './components/playVideo.jsx';
|
import PlayVideo from './components/playVideo.jsx';
|
||||||
import LoadingScene from './components/loadingScene.jsx';
|
import LoadingScene from './components/loadingScene.jsx';
|
||||||
|
|
||||||
function IntroductionPageData(){
|
function IntroductionData({onClickedIntroduction}){
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<div style={{
|
<div
|
||||||
display: 'flex',
|
onClick={onClickedIntroduction}
|
||||||
justifyContent: 'center',
|
style={{
|
||||||
alignItems: 'center',
|
position: "fixed",
|
||||||
height: '100vh',
|
top: 0,
|
||||||
maxWidth:"100vw",
|
left: 0,
|
||||||
flexDirection: 'column',
|
width: "100vw",
|
||||||
}}>
|
height: "100vh",
|
||||||
|
background: "rgba(var(--black), 0.5)",
|
||||||
<div style={{
|
display: 'flex',
|
||||||
position: "fixed",
|
justifyContent: 'center',
|
||||||
top: 0,
|
alignItems: 'center',
|
||||||
left: 0,
|
zIndex: 1 // Ensure this is above other elements
|
||||||
width: "100vw",
|
}}
|
||||||
height: "100vh",
|
>
|
||||||
background: "rgba(var(--black), 0.5)",
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
zIndex: 1 // Ensure this is above other elements
|
|
||||||
}}>
|
|
||||||
<label style={{color:"rgb(var(--white))", fontWeight:"bold"}}>
|
<label style={{color:"rgb(var(--white))", fontWeight:"bold"}}>
|
||||||
You are a new student who just <br />
|
You are a new student who just <br />
|
||||||
transfered to this school not long ago. <br />
|
transfered to this school not long ago. <br />
|
||||||
|
@ -35,26 +30,133 @@ function IntroductionPageData(){
|
||||||
but eventually you meet...
|
but eventually you meet...
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function SelectionCharacter(){
|
||||||
|
const [numChar, setNumChar] = useState(1);
|
||||||
|
|
||||||
|
const handleLeftClicked = () => {
|
||||||
|
var temp = numChar - 1
|
||||||
|
if (temp<1){
|
||||||
|
setNumChar(3)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
setNumChar(temp)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const handleRightClicked = () => {
|
||||||
|
var temp = numChar + 1
|
||||||
|
if (temp>3){
|
||||||
|
setNumChar(1)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
setNumChar(temp)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Character {
|
||||||
|
name(num) {
|
||||||
|
if (num === 1) {
|
||||||
|
return "Porsche";
|
||||||
|
} else if (num === 2) {
|
||||||
|
return "Pie";
|
||||||
|
} else if (num === 3) {
|
||||||
|
return "Patt";
|
||||||
|
} else {
|
||||||
|
return "Invalid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
position(num) {
|
||||||
|
if (num === 1) {
|
||||||
|
return "left";
|
||||||
|
} else if (num === 2) {
|
||||||
|
return "middle";
|
||||||
|
} else if (num === 3) {
|
||||||
|
return "right";
|
||||||
|
} else {
|
||||||
|
return "Invalid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const character = new Character();;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{
|
||||||
|
position: "fixed",
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
width: "100vw",
|
||||||
|
height: "100vh",
|
||||||
|
zIndex: 1,
|
||||||
|
}}>
|
||||||
|
<div className="button left"
|
||||||
|
onClick={handleLeftClicked}
|
||||||
|
style={{
|
||||||
|
// background: 'white',
|
||||||
|
width:'10vw',
|
||||||
|
height:'20vh'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img src="https://placehold.co/400x600" style={{width:'100%',height:'100%'}}/>
|
||||||
|
</div>
|
||||||
|
<div className="textBox"
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
width:'10vw',
|
||||||
|
height:'20vh'
|
||||||
|
}}>
|
||||||
|
{character.name(numChar)}
|
||||||
|
</div>
|
||||||
|
<div className="button right"
|
||||||
|
onClick={handleRightClicked}
|
||||||
|
style={{
|
||||||
|
// background: 'white',
|
||||||
|
width:'10vw',
|
||||||
|
height:'20vh'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img src="https://placehold.co/400x600" style={{width:'100%',height:'100%'}}/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function IntroductionPage() {
|
function IntroductionPage() {
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [positionState, setPositionState] = useState("middle");
|
||||||
|
const [isClickedIntroduction, setIsClickedIntroduction] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
|
const handleClickIntroduction = () => {
|
||||||
|
setIsClickedIntroduction(true);
|
||||||
|
console.log(isClickedIntroduction)
|
||||||
|
};
|
||||||
|
|
||||||
const handleVideoReady = () => {
|
const handleVideoReady = () => {
|
||||||
setLoading(false); // Set loading to false when the video is ready
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div style={{
|
||||||
|
width: "100vw",
|
||||||
|
height: "100vh",
|
||||||
|
}}>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<LoadingScene />
|
<LoadingScene />
|
||||||
) : (
|
) : (
|
||||||
<IntroductionPageData />
|
!isClickedIntroduction ? (
|
||||||
|
<IntroductionData onClickedIntroduction={handleClickIntroduction} />
|
||||||
|
) : (
|
||||||
|
<SelectionCharacter />
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<PlayVideo onVideoReady={handleVideoReady} />
|
<PlayVideo src='hallway_FFF.mp4' side='middle' onVideoReady={handleVideoReady} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue