S
S
Spoon in the brain2020-08-21 16:38:50
Vue.js
Spoon in the brain, 2020-08-21 16:38:50

How to change block height as page scrolls in vuejs?

Good afternoon!
I'll start right away with the code , and so, there this mechanic is implemented in pure js, can anyone help transfer all this to vuejs?
(and yes, I realize the stupidity of this question)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-08-21
@vessels

data: () => ({
  scroll: 0,
}),
computed: {
  style() {
    return {
      height: здесь рассчитываете высоту на основе this.scroll,
    };
  },
},
created() {
  const onScroll = () => this.scroll = document.scrollingElement.scrollTop;
  onScroll();
  document.addEventListener('scroll', onScroll);
  this.$on('hook:beforeDestroy', () => document.removeEventListener('scroll', onScroll));
},

<div :style="style">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question