
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
<template>
<div id="Chapter1_1" class="content-wrap">
<div style="margin: 30px 0px 50px">
<router-link to="/MyPlan.page">
<div class="logo mb25"><img src="../../../../resources/img/logo2.png" alt=""></div>
</router-link>
</div>
<div class="title-box mb25 flex align-center mt40">
<span class="title mr40">1. Hello WORLD</span>
<span class="subtitle">my name is dd</span>
</div>
<div class="flex justify-between align-center">
<div class="pre-btn" @click="goToPage('Chapter2_8')"><img src="../../../../resources/img/left.png" alt=""></div>
<div class="content title-box">
<div style="display: flex; justify-content: space-between;">
<p class="title mt25 title-bg">step3-놀면서 배우는 영어</p>
<button id="returnButton" @click="returnPage" style="margin: 4rem;">
<img src="../../../../resources/img/btn_return_50x50.png" alt="">
<p>되돌리기</p>
</button>
</div>
<div class="flex align-center mb30">
<p class="subtitle2 mr20">앗! 다리가 무너져서 건널 수가 없어! 다리 조각을 옮겨줘!</p>
</div>
<div class="text-ct flex justify-center" style="gap: 80px;">
<div class="dropGroup flex align-center justify-center">
<div class="flex" style="gap: 20px; position: relative;">
<img src="../../../../resources/img/img70_39s.png" alt="">
<div class="textbox">
<p style="left: -180px;bottom: -200px;">I</p>
<p id="bridgeTarget" style="left: -105px;bottom: -150px;" @dragover.prevent @drop="handleDrop">?</p>
<p style="left: -30px;bottom: -65px;">banana</p>
</div>
</div>
</div>
<div class="dragGroup mt40">
<div>
<button id="have" draggable="true" @dragstart="handleDragStart">
<img src="../../../../resources/img/img71_39s.png" alt="">
<p>have</p>
</button>
<button id="has" draggable="true" @dragstart="handleDragStart">
<img src="../../../../resources/img/img71_39s.png" alt="">
<p>has</p>
</button>
<button id="had" draggable="true" @dragstart="handleDragStart">
<img src="../../../../resources/img/img71_39s.png" alt="">
<p>had</p>
</button>
</div>
</div>
</div>
</div>
<div class="next-btn" @click="goToPage('Chapter2_5')"><img src="../../../../resources/img/right.png" alt=""></div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
draggedElementId: null, // 드래그한 요소의 ID를 저장
correctAnswer: "have", // 정답 설정
};
},
methods: {
goToPage(page) {
this.$router.push({ name: page });
},
returnPage() {
// 페이지 새로 고침
window.location.reload();
},
handleDragStart(event) {
// 드래그한 요소의 ID를 저장
this.draggedElementId = event.target.id;
},
handleDrop(event) {
const dropZone = event.target;
const draggedElement = document.getElementById(this.draggedElementId);
if (draggedElement) {
// 새로운 버튼을 드롭 영역에 추가
const cloneElement = draggedElement.cloneNode(true);
cloneElement.style.position = 'absolute';
cloneElement.style.top = "-70px";
cloneElement.style.left = "-50px";
dropZone.innerHTML = ""; // 기존 ? 텍스트 제거
dropZone.appendChild(cloneElement);
// 드래그한 버튼 숨기기
draggedElement.style.visibility = "hidden";
// DOM 업데이트 후 알림을 비동기적으로 처리
setTimeout(() => {
if (this.draggedElementId === this.correctAnswer) {
alert("정답입니다!");
} else {
alert("오답입니다!");
window.location.reload();
}
// 드래그 상태 초기화
this.draggedElementId = null;
}, 0);
}
}
},
};
</script>
<style scoped>
.textbox p {
position: absolute;
}
.dragGroup button {
display: block;
}
.dragGroup button p,
.textbox p {
width: fit-content;
height: fit-content;
background: #ffffffb8;
border-radius: 5px;
padding: 10px;
font-size: 30px;
font-family: 'ONEMobilePOP';
}
.dragGroup button {
cursor: grab;
}
.dragGroup button[draggable="true"]:active {
cursor: grabbing;
}
</style>