question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loaded event triggering on every scroll event

See original GitHub issue

I’m using the loaded adapter alongside vue-router. I’m finding that on initial page load the loaded event is triggered once per image, which is expected. After changing routes I find that the loaded event is triggered on every scroll event for every visible image, even if the image has already loaded. Setup like this:

Vue.use(VueLazyload, {
  preLoad: 1.8,
  error: false,
  loading: false,
  attempt: 1,
  supportWebp: false,
  adapter: {
    loaded({ el }) {
      console.log(el);
    },
  },
});

Is this expected behaviour?

Online example here: http://requirebin.com/?gist=rdunk/1371389794270c9672bb15f4e24d40c3

Try changing route a few times and then scrolling, should see the events in the console.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rdunkcommented, Sep 8, 2020

@fawadaslam1993 Managed to dig it out. This is just a replacement for the component, not the directive, so not sure if it will do what you need it to do.

Hope it helps.

https://gist.github.com/rdunk/98c9c2a80dace8e73472b81e3e9ce97b

0reactions
fawadaslam1993commented, Sep 9, 2020

Thanks. I’ll try 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to trigger an on scroll event without scrolling
If you want to fire a scroll event, just literally scroll to where you already are by typing window.scrollTo(window.scrollX, window.scrollY); in ...
Read more >
JavaScript Scroll Events, Event Throttling & Passive Events
You can trigger the scroll events in the following ways, for example: ... The scrollX and scrollY are 0 if the document hasn't...
Read more >
Document: scroll event - Web APIs - MDN Web Docs - Mozilla
The scroll event fires when the document view has been scrolled. To detect when scrolling has completed, see the Document: scrollend event.
Read more >
onscroll Event - W3Schools
The onscroll event occurs when an element's scrollbar is being scrolled. Tip: use the CSS overflow style property to create a scrollbar for...
Read more >
.scroll() | jQuery API Documentation
The scroll event is sent to an element when the user scrolls to a different place in the element. It applies to window...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found