1

нужно сделать, чтобы при скроллинге веб-страницы какой-то объект блюрился. То есть чем больше проскролена страница, тем сильнее заблюривался объект.

1

1 ответ 1

4

Такой вариант?

let docH = $(document).height() - $(window).height(),
    blur;

$(window).on({
    'scroll': function() {
        blur = Math.floor((1 - (docH - $(this).scrollTop()) / docH) * 10); // Где 10 - это конечная "степень блюра" в конце страницы.
    $('.blur').css('--blur', blur+'px');
    },
  'resize': function() {
        docH = $(document).height() - $(window).height();
  }
});
body {
  height: 1500px;
}

.blur {
  display: inline-block;
  width: 300px;
  position: fixed;
  left: 10px;
  top: 10px;
  -ms-filter: blur(var(--blur, 0));
  filter: blur(var(--blur, 0));
}

.blur img {
  display: block;
  max-width: 100%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="blur">
  <img src="https://i.imgur.com/o2W6F4f.png">
</div>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.