<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous">
</script>
<style>@charset "utf-8";

/*========= スクロールダウンのためのCSS ===============*/

/*スクロールダウン全体の場所*/
.scrolldown {
  /*描画位置※位置は適宜調整してください*/
  position: absolute;
  bottom: 10px;
  right: 50%;
  /*マウスの動き1.6秒かけて動く永遠にループ*/
  animation: mousemove 1.6s ease-in-out infinite;
}

/*下からの距離が変化して上から下に動く*/
@keyframes mousemove {
  0% {
    bottom: 10px;
  }
  50% {
    bottom: 5px;
  }
  100% {
    bottom: 10px;
  }
}

/*Scrollテキストの描写*/
.scrolldown span {
  z-index: 10;
  /*描画位置*/
  position: absolute;
  left: -15px;
  bottom: 45px;
  /*テキストの形状*/
  color: #000;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/*マウスの中の線描写 */
.scrolldown span::after {
  z-index: 10;
  content: "";
  /*描画位置*/
  position: absolute;
  top: 10px;
  left: 17px;
  /*線の形状*/
  width: 1px;
  height: 15px;
  background: #000;
  /*線の動き1.4秒かけて動く。永遠にループ*/
  animation: mousepathmove 1.4s linear infinite;
  opacity: 0;
}

/*上からの距離・不透明度・高さが変化して上から下に流れる*/
@keyframes mousepathmove {
  0% {
    height: 0;
    top: 10px;
    opacity: 0;
  }
  50% {
    height: 15px;
    opacity: 1;
  }
  100% {
    height: 0;
    top: 30px;
    opacity: 0;
  }
}

/*マウスの描写 */
.scrolldown:before {
  z-index: 10;
  content: "";
  /*描画位置*/
  position: absolute;
  bottom: 0;
  left: -10px;
  /*マウスの形状*/
  width: 25px;
  height: 37px;
  border-radius: 10px;
  border: 1px solid #000;
}

/*マウスの中の丸の描写*/
.scrolldown:after {
  z-index: 10;
  content: "";
  /*描画位置*/
  position: absolute;
  bottom: 26px;
  left: 0;
  /*丸の形状*/
  width: 5px;
  height: 5px;
  border-radius: 50%;
  border: 1px solid #000;
}

/*========= スクロールのためのCSS ===============*/
.space {
  padding: 100vh 0;
}

/*========= レイアウトのためのCSS ===============*/
body {
  background-image: linear-gradient(
    68.4deg,
    rgba(248, 182, 204, 1) 0.5%,
    rgba(192, 198, 230, 1) 60%,
    rgba(225, 246, 240, 1) 89.8%
  );
}

p {
  text-align: center;
  padding: 20px 0;
  font-size: clamp(0.9rem, 2vw, 1.5rem);
  letter-spacing: 0.5em;
  white-space: nowrap;
}

.TextTyping {
  text-align: center;
}

/*========= テキストを滑らかに出現させるためのCSS ===============*/
span.smoothText {
  overflow: hidden;
  display: block;
}

/* アニメーションで傾斜がついている文字列を水平に戻す*/
span.smoothTextTrigger {
  transition: 0.8s ease-in-out;
  transform: translate3d(0, 100%, 0) skewY(20deg);
  transform-origin: left;
  display: block;
}
span.smoothTextTrigger.smoothTextAppear {
  transform: translate3d(0, 0, 0) skewY(0);
}</style>
</head>
<body>
<body>
<div class="scrolldown">
<span>Scroll</span>
</div>
<p>
<span class="smoothText">
<span class="smoothTextTrigger">テキストが滑らかに出現テキストが滑らかに出現</span>
</span>
</p>
<div class="space">
</div>
<p>
<span class="smoothText">
<span class="smoothTextTrigger">テキストが滑らかに出現テキストが滑らかに出現</span>
</span>
</p>
<script>// smoothTriggerにsmoothTextAppearというクラス名を付ける定義
function SmoothTextAnime() {
  $(".smoothTextTrigger").each(function () {
    //smoothTextTriggerというクラス名が
    var elemPos = $(this).offset().top - 50; //要素より、50px上の
    var scroll = $(window).scrollTop();
    var windowHeight = $(window).height();
    if (scroll >= elemPos - windowHeight) {
      $(this).addClass("smoothTextAppear"); // 画面内に入ったらsmoothTextAppearというクラス名を追記
    } else {
      $(this).removeClass("smoothTextAppear"); // 画面外に出たらsmoothTextAppearというクラス名を外す
    }
  });
}

// 画面をスクロールをしたら動かしたい場合の記述
$(window).scroll(function () {
  SmoothTextAnime(); /* アニメーション用の関数を呼ぶ*/
}); // ここまで画面をスクロールをしたら動かしたい場合の記述

// 画面が読み込まれたらすぐに動かしたい場合の記述
$(window).on("load", function () {
  SmoothTextAnime(); /* アニメーション用の関数を呼ぶ*/
}); // ここまで画面が読み込まれたらすぐに動かしたい場合の記述
//# sourceURL=pen.js</script>
</body>
</html>
/* 
   外部依存 CSS:
     - https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css
   外部依存 JS (このデモは下記の JS にも依存します):
     - https://code.jquery.com/jquery-3.4.1.min.js
 */

@charset "utf-8";

/*========= スクロールダウンのためのCSS ===============*/

/*スクロールダウン全体の場所*/
.scrolldown {
  /*描画位置※位置は適宜調整してください*/
  position: absolute;
  bottom: 10px;
  right: 50%;
  /*マウスの動き1.6秒かけて動く永遠にループ*/
  animation: mousemove 1.6s ease-in-out infinite;
}

/*下からの距離が変化して上から下に動く*/
@keyframes mousemove {
  0% {
    bottom: 10px;
  }
  50% {
    bottom: 5px;
  }
  100% {
    bottom: 10px;
  }
}

/*Scrollテキストの描写*/
.scrolldown span {
  z-index: 10;
  /*描画位置*/
  position: absolute;
  left: -15px;
  bottom: 45px;
  /*テキストの形状*/
  color: #000;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/*マウスの中の線描写 */
.scrolldown span::after {
  z-index: 10;
  content: "";
  /*描画位置*/
  position: absolute;
  top: 10px;
  left: 17px;
  /*線の形状*/
  width: 1px;
  height: 15px;
  background: #000;
  /*線の動き1.4秒かけて動く。永遠にループ*/
  animation: mousepathmove 1.4s linear infinite;
  opacity: 0;
}

/*上からの距離・不透明度・高さが変化して上から下に流れる*/
@keyframes mousepathmove {
  0% {
    height: 0;
    top: 10px;
    opacity: 0;
  }
  50% {
    height: 15px;
    opacity: 1;
  }
  100% {
    height: 0;
    top: 30px;
    opacity: 0;
  }
}

/*マウスの描写 */
.scrolldown:before {
  z-index: 10;
  content: "";
  /*描画位置*/
  position: absolute;
  bottom: 0;
  left: -10px;
  /*マウスの形状*/
  width: 25px;
  height: 37px;
  border-radius: 10px;
  border: 1px solid #000;
}

/*マウスの中の丸の描写*/
.scrolldown:after {
  z-index: 10;
  content: "";
  /*描画位置*/
  position: absolute;
  bottom: 26px;
  left: 0;
  /*丸の形状*/
  width: 5px;
  height: 5px;
  border-radius: 50%;
  border: 1px solid #000;
}

/*========= スクロールのためのCSS ===============*/
.space {
  padding: 100vh 0;
}

/*========= レイアウトのためのCSS ===============*/
body {
  background-image: linear-gradient(
    68.4deg,
    rgba(248, 182, 204, 1) 0.5%,
    rgba(192, 198, 230, 1) 60%,
    rgba(225, 246, 240, 1) 89.8%
  );
}

p {
  text-align: center;
  padding: 20px 0;
  font-size: clamp(0.9rem, 2vw, 1.5rem);
  letter-spacing: 0.5em;
  white-space: nowrap;
}

.TextTyping {
  text-align: center;
}

/*========= テキストを滑らかに出現させるためのCSS ===============*/
span.smoothText {
  overflow: hidden;
  display: block;
}

/* アニメーションで傾斜がついている文字列を水平に戻す*/
span.smoothTextTrigger {
  transition: 0.8s ease-in-out;
  transform: translate3d(0, 100%, 0) skewY(20deg);
  transform-origin: left;
  display: block;
}
span.smoothTextTrigger.smoothTextAppear {
  transform: translate3d(0, 0, 0) skewY(0);
}
/* 
   外部依存 JS:
     - https://code.jquery.com/jquery-3.4.1.min.js
   外部依存 CSS (このデモは下記の CSS にも依存します):
     - https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css
 */

// smoothTriggerにsmoothTextAppearというクラス名を付ける定義
function SmoothTextAnime() {
  $(".smoothTextTrigger").each(function () {
    //smoothTextTriggerというクラス名が
    var elemPos = $(this).offset().top - 50; //要素より、50px上の
    var scroll = $(window).scrollTop();
    var windowHeight = $(window).height();
    if (scroll >= elemPos - windowHeight) {
      $(this).addClass("smoothTextAppear"); // 画面内に入ったらsmoothTextAppearというクラス名を追記
    } else {
      $(this).removeClass("smoothTextAppear"); // 画面外に出たらsmoothTextAppearというクラス名を外す
    }
  });
}

// 画面をスクロールをしたら動かしたい場合の記述
$(window).scroll(function () {
  SmoothTextAnime(); /* アニメーション用の関数を呼ぶ*/
}); // ここまで画面をスクロールをしたら動かしたい場合の記述

// 画面が読み込まれたらすぐに動かしたい場合の記述
$(window).on("load", function () {
  SmoothTextAnime(); /* アニメーション用の関数を呼ぶ*/
}); // ここまで画面が読み込まれたらすぐに動かしたい場合の記述
//# sourceURL=pen.js