<br> problem
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/js/swiper.min.js"></script>
<!-- The corresponding part is at the bottom. (It is faster to count from the bottom)
(There is a mark in the comment) -->
<div class="solid-ti"></div>
<div id="wrap">
<div id="left">
<h1 class="title">動と静を共有する椅子「Rollse」</h1>
<div class="swiper-pagination"></div>
<div class="swiper-container swiperCnt max">
<div class="swiper-wrapper imgs max-inner">
<div class="swiper-slide"><img class="work" src="http://placehold.jp/45/1920a6/ffffff/693x350.png?text=1" alt="Rollse-logo" /></div>
<div class="swiper-slide"><img class="work" src="http://placehold.jp/45/199fa6/ffffff/693x350.png?text=2" alt="Rollse-killer" /></div>
<div class="swiper-slide"><img class="work" src="http://placehold.jp/45/a61972/ffffff/693x350.png?text=3" alt="Rollse-data" /></div>
<div class="swiper-slide"><img class="work" src="http://placehold.jp/45/a6a619/ffffff/693x350.png?text=4" alt="Rollse-image" /></div>
</div>
</div>
<div class="L-under">
<div class="mis">
<h3 class="mission">MISSION:</h3>
<p class="m-p">触覚に訴えるプロダクト ▶︎ 3人チームの1人が、この触り心地を発見</p>
</div>
<div class="solid-mc"></div>
<div class="con">
<h2 class="concept">CONCEPT:</h2>
<p class="c-p">緊張感のある空間をつくる。</p>
</div>
<div class="what">
<img src="http://placehold.jp/45/d4d4d4/d4d4d4/28x20.png?text=_" alt="2nd" /><img src="http://placehold.jp/45/d4d4d4/d4d4d4/20x20.png?text=_" alt="ai" /><img src="http://placehold.jp/45/d4d4d4/d4d4d4/20x20.png?text=_" alt="vw" />
<span>企画</span>
<span>雑貨の設計</span>
<span>ネーミング</span>
<span>文章</span>
<span>展開</span>
</div>
</div>
</div>
<div id="right">
<div class="top">
<div class="cat">
<h5...
CSS
/* The corresponding part is at the bottom too. (It is faster to count from the bottom)
(There is a mark in the comment) */
html {
font-size: 62.5%;
height: 100%;
}
body {
font-size: 1.5rem;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: #c6d2dd;
color: white;
}
#wrap {
display: flex;
width: 100%;
height: 100vh;
padding: 1.8rem 4.7rem 2.7rem 2.4rem;
}
h2, h3, h4, h5, h6 {
display: inline;
}
.mission, .m-p, .concept, .c-p, .what, .target, .t-p, .main-p, .nb, .nb-p, .period, .p-p, .category, .cg-p, .class, .cl-p, .release, .r-p, .nbb, .per, .cat, .cla, .rel {
display: inline-block;
}
#left, #right {
display: flex;
flex-direction: column;
height: 100%;
max-height: 100%;
}
#left {
width: 57%;
}
#right {
position: relative;
width: 43%;
padding-left: 6.5rem;
}
.title {
height: 3.55rem;
font-size: 1.8rem;
padding-bottom: 1.7rem;
}
.solid-ti {
position: absolute;
width: 100%;
border-top: 0.1rem solid white;
margin-top: 5.35rem;
}
.solid-mc {
border-bottom: 0.1rem solid white;
margin-left: -2.4rem;
}
.solid-tm {
border-bottom: 0.1rem solid white;
margin-right: -4.7rem;
}
.swiper-pagination {
top: 6rem;
}
.max {
position: relative;
width: 100%;
flex: 1;
}
.max-inner {
position: absolute;
width: 100%;
height: 100%;
}
.swiper-slide {
display: flex;
align-items: center;
}
.swiper-slide img {
width: 100%;
}
.swiperP {
height: auto;
}
.swiper-pagination-bullet {
background: none;
font-size: 1rem;
margin-right: 0.5rem;
opacity: 0.3;
}
.swiper-pagination-bullet::before {
content: "0";
font-weight: bold;
}
.swiper-pagination-bullet:hover::before {
content: "1";
font-weight: bold;
}
.swiper-pagination-bullet-active {
background: none;
transform: scale(1);
transition-duration: 0.16s;
opacity: 0.7;
}
.swiper-pagination-bullet-active::before {
content: "1";
font-weight: bold;
}
.mis {
padding: 2.6rem 0...
JavaScript
/* 1 */
// Get the center of the height of .main
const rect = document.getElementsByClassName("main")[0].getBoundingClientRect();
console.log(rect)
const mainHCenter =rect.top +( rect.height / 2);
const mainWCenter =rect.left +( rect.width / 2);
console.log(mainHCenter); // Match
// Get the element at the center of the height of .main
var centerElm = document.elementFromPoint(mainWCenter, mainHCenter);
console.log(centerElm); // Wrong
/* 2 */
/*
// Get the center of the height of .main
const main = document.querySelector(".main");
const centerY = main.offsetHeight / 2;
const centerX = main.offsetWidth / 2;
console.log('h:' + centerY + 'w:' + centerX); // Almost match
// Get the element at the center of the height of .main
const element = document.elementFromPoint(centerX, centerY);
console.log(element); // Wrong
*/
/* swiper (doesn't matter) */
var swiperCnt = new Swiper('.swiperCnt', {
direction: 'vertical',
autoHeight: true,
pagination: {
el: '.swiper-pagination',
type: 'bullets',
clickable: 'true',
},
keyboard: {
enabled: true,
},
mousewheel: {
forceToAxis: true,
invert: true,
},
renderBullet: function(index, className) {
return '<span class="' + className + '">' + (index + 1) + '</span>';
},
});
$(function() {
var that;
var i = 0;
var j = $(".main > p").length - 1;
$('.mai').bind('mousewheel', function(e) {
if (e.originalEvent.wheelDelta < 0) {
//scroll down
i++;
if (i >= j) {
i = j;
}
if (i <= j) {
$(".main > p").each(function(i) {
if ($(this).hasClass('active')) {
if ($(this).hasClass(i)) {
if (i < j) {
that = $(this).next();
} else {
that = $(this);
}
}
}
$(this).removeClass('active');
});
$(that).addClass('active');
}
} else {
//scroll up
i--;
if (i <= 0) {
...