Commit 754b7779 by Yutaka Kobayashi

変更

1 parent c0ec1fd1
import { throttle } from "throttle-debounce"; import { throttle } from "throttle-debounce";
<<<<<<< HEAD
export function fadeIn() {
// フェードイン
=======
export class Fade { export class Fade {
>>>>>>> 62edc9b6577a872ce95b85c866ef52ea7890671d
fadeIn() { fadeIn() {
window.addEventListener( window.addEventListener(
"scroll", "scroll",
throttle(300, () => { throttle(300, () => {
window.addEventListener("scroll", () => { window.addEventListener("scroll", () => {
<<<<<<< HEAD
var element = document.getElementsByClassName("scrollUp");
if (!element) return;
var scrollY = window.pageYOffset;
var windowHeight = window.innerHeight;
var showTiming = 200;
for (var i = 0; i < element.length; i++) {
var elementClientRect = element[i].getBoundingClientRect();
var elementY = scrollY + elementClientRect.top;
=======
let element = document.getElementsByClassName("scrollUp"); let element = document.getElementsByClassName("scrollUp");
if (!element) return; if (!element) return;
...@@ -31,7 +14,6 @@ export class Fade { ...@@ -31,7 +14,6 @@ export class Fade {
for (let i = 0; i < element.length; i++) { for (let i = 0; i < element.length; i++) {
let elementClientRect = element[i].getBoundingClientRect(); let elementClientRect = element[i].getBoundingClientRect();
let elementY = scrollY + elementClientRect.top; let elementY = scrollY + elementClientRect.top;
>>>>>>> 62edc9b6577a872ce95b85c866ef52ea7890671d
if (scrollY > elementY - windowHeight + showTiming) { if (scrollY > elementY - windowHeight + showTiming) {
element[i].classList.add("is-show"); element[i].classList.add("is-show");
} }
......
<<<<<<< HEAD
window.addEventListener("DOMContentLoaded", () => {
modal();
fadeIn();
});
// import { throttle } from "throttle-debounce";
import { modal } from "./modal";
import { fadeIn } from "./fadeIn";
// class Home {
// constructor() {
// this.modal();
// this.fadeIn();
// }
// }
window.addEventListener("DOMContentLoaded", () => {
new Home();
});
=======
import { Modal } from "./Modal.js"; import { Modal } from "./Modal.js";
import { Fade } from "./fadeIn.js"; import { Fade } from "./fadeIn.js";
...@@ -27,4 +6,3 @@ modal.openModal(); ...@@ -27,4 +6,3 @@ modal.openModal();
const fade = new Fade(); const fade = new Fade();
fade.fadeIn(); fade.fadeIn();
>>>>>>> 62edc9b6577a872ce95b85c866ef52ea7890671d
<<<<<<< HEAD
export function modal() {
const body = document.getElementsByTagName("body")[0];
const button = document.querySelectorAll(".novelList__button");
const modalBack = document.querySelector(".modalBackground");
const modal = document.querySelectorAll(".modal");
const closeButton = document.querySelector(".modal__button");
// モーダルを表示する
for (let i = 0; i < button.length; i++) {
button[i].addEventListener("click", addOpen);
function addOpen(e) {
e.preventDefault();
body.classList.add("open");
modalBack.classList.add("open");
modal[i].classList.add("open");
}
}
// モーダルを非表示にする
closeButton.addEventListener("click", () => {
body.classList.remove("open");
modalBack.classList.remove("open");
for (let i = 0; i < modal.length; i++) {
modal[i].classList.remove("open");
}
});
function menuClick() {
body.classList.remove("open");
modalBack.classList.remove("open");
const mpdalElements = document.querySelectorAll(".modal");
mpdalElements.forEach((item) => {
item.classList.remove("open");
});
}
const closeTrigger = document.querySelectorAll(".closeButton");
closeTrigger.forEach((item) => {
item.addEventListener("click", menuClick);
});
=======
export class Modal { export class Modal {
openModal() { openModal() {
const body = document.querySelector("body"); const body = document.querySelector("body");
...@@ -83,5 +40,4 @@ export class Modal { ...@@ -83,5 +40,4 @@ export class Modal {
item.addEventListener("click", menuClick); item.addEventListener("click", menuClick);
}); });
} }
>>>>>>> 62edc9b6577a872ce95b85c866ef52ea7890671d
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!