Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JS
- Изменил привязку слушателей для курсора на слайдере
- function cursor() {
- var body = document.querySelector("body");
- var cursor = document.getElementById("cursor"),
- follower = document.getElementById("aura"),
- links = document.getElementsByTagName("a"),
- mouseX = 0,
- mouseY = 0,
- posX = 0,
- posY = 0;
- function mouseCoords(e) {
- mouseX = e.pageX;
- if (body.classList.contains("admin-bar")) {
- mouseY = e.pageY - 32;
- } else {
- mouseY = e.pageY;
- }
- cursor.classList.remove("hidden");
- follower.classList.remove("hidden");
- }
- gsap.to({}, 0.01, {
- repeat: -1,
- onRepeat: function onRepeat() {
- posX += (mouseX - posX) / 11;
- posY += (mouseY - posY) / 11;
- gsap.set(cursor, {
- css: {
- left: mouseX,
- top: mouseY,
- },
- });
- gsap.set(follower, {
- css: {
- left: posX - 1,
- top: posY - 1,
- },
- });
- },
- });
- for (var i = 0; i < links.length; i++) {
- links[i].addEventListener("mouseover", function () {
- cursor.classList.add("active");
- follower.classList.add("active");
- });
- links[i].addEventListener("mouseout", function () {
- cursor.classList.remove("active");
- follower.classList.remove("active");
- });
- }
- body.addEventListener("mousemove", function (e) {
- mouseCoords(e);
- });
- body.addEventListener("mouseout", function () {
- cursor.classList.add("hidden");
- follower.classList.add("hidden");
- });
- if (document.querySelector(".cases-slider__swiper-slide")) {
- (function () {
- var slides = document.querySelectorAll(".cases-slider__swiper-slide"),
- dragText = document.querySelector(".drag-text"),
- skiderLink = document.querySelectorAll(".cases-slider__slider-link");
- for (var _i24 = 0; _i24 < skiderLink.length; _i24++) {
- skiderLink[_i24].addEventListener("mouseover", function () {
- cursor.classList.add("discover");
- dragText.innerHTML = "discover";
- });
- skiderLink[_i24].addEventListener("mouseout", function () {
- cursor.classList.remove("discover");
- dragText.innerHTML = "drag";
- });
- }
- slides.forEach((slide) => {
- slide.addEventListener("mouseover", function () {
- cursor.classList.remove("active");
- cursor.classList.add("drag");
- follower.style.display = "none";
- dragText.style.opacity = "1";
- });
- slide.addEventListener("mouseout", function () {
- cursor.classList.remove("drag");
- follower.style.display = "block";
- dragText.style.opacity = "0";
- });
- });
- })();
- }
- }
- CSS
- !!! Это задаёт расстояние между слайдами, размеры взял с настроек слайдера в js. Просто в корень CSS файла кинуть !!!
- @media (min-width: 320px) {
- .cases-slider__swiper-wrapper {
- gap: 26px;
- }
- }
- @media (min-width: 1200px) {
- .cases-slider__swiper-wrapper {
- gap: 100px;
- }
- }
- !!! Тут последняя строка убивает spaceBetween который вешается свайпером !!!
- .cases-slider__swiper-slide {
- display: -webkit-box;
- display: -ms-flexbox;
- display: flex;
- -webkit-box-align: center;
- -ms-flex-align: center;
- align-items: center;
- -webkit-box-orient: vertical;
- -webkit-box-direction: normal;
- -ms-flex-direction: column;
- flex-direction: column;
- -webkit-box-pack: end;
- -ms-flex-pack: end;
- justify-content: flex-end;
- -webkit-box-align: start;
- -ms-flex-align: start;
- align-items: flex-start;
- height: 466px;
- margin-right: 0 !important;
- }
- !!! Заблокировал user select !!!
- .cases-slider__wrapper {
- display: -webkit-box;
- display: -ms-flexbox;
- display: flex;
- -webkit-box-orient: vertical;
- -webkit-box-direction: normal;
- -ms-flex-direction: column;
- flex-direction: column;
- -webkit-box-pack: center;
- -ms-flex-pack: center;
- justify-content: center;
- height: 100%;
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- }
Advertisement
Add Comment
Please, Sign In to add comment