D
D
Darkness2019-08-02 11:39:51
Vue.js
Darkness, 2019-08-02 11:39:51

How to fix a bug. And why only on the phone?

There is a site on it (in the articles), just click on the card, the articles change. Those. not all are fully loaded, but when the user scrolls.
The problem is mobile. He just behaves differently. It does not load on scroll, but simply unloads all the articles. What is the error I can't find. I can't check on localhost. in devtools on mobile. normal behaviour.
Here is the scroll code, for better understanding it is better to go to the site from your phone and click on any card.

mounted() {
    this.scroll()
  },
  methods: {
    scrollToTop() {
      if (scrolled > 0) {
        window.scrollTo(0, scrolled)
        scrolled = scrolled - 100
        timer = setTimeout(() => {
          this.scrollToTop()
        }, 10)
      } else {
        clearTimeout(timer)
        window.scrollTo(0, 0)
      }
    },
    scroll() {
      /* eslint-disable */
      let iCan = false
      window.onscroll = () => {
        window.pageYOffset > 1 ? iCan = true : false
        const bottomOfWindow =
          document.documentElement.scrollTop + window.innerHeight >=
          document.documentElement.offsetHeight

        if (bottomOfWindow && iCan) {
          if (!this.loading) {
            this.loading = true
            // добавляем старую статью в слайдер
            this.$store.dispatch('addArticle')
            // при этом удаляем предыдущие

            if (this.$store.state.prev != null) {
              this.$store.dispatch('deleteArticles')
                .then(success => {
                  this.mySwiper.slideNext()
                })
            }
          }
          this.mySwiper.slideNext()
          setTimeout(() => {
            this.loading = false
          }, 1000)
        } else if (document.documentElement.scrollTop === 0 && iCan) {
          // добавляем новую статью в слайдер
          this.$store.dispatch('returnArticle')
          // при этом удаляем предыдущие
          if (this.$store.state.next != null) {
            this.$store.dispatch('deleteArticles')
              .then(success => {
                this.mySwiper.slidePrev()
              })
              /* eslint-enable */
          }
        }
      }
    },
    imgFor() {
      if (screen.width <= 500) {
        const img = document.getElementsByTagName('img')
        for (let i = 0; i <= img.length; i++) {
          img[i].style = 'max-width:280px'
        }
      } else return null
    }
  }

Thanks a lot!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Ololoshchenko, 2019-08-02
@veremii

Connect mobile phone to chrome via DevTools and debug. https://webbeaver.ru/instructions/debugging-on-mobile/ here is the instruction.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question