Giter VIP home page Giter VIP logo

Comments (9)

Dadibom avatar Dadibom commented on June 3, 2024 1

Doesn't work I'm afraid ):

from vue-in-viewport-mixin.

weotch avatar weotch commented on June 3, 2024 1

This has been released now: https://github.com/BKWLD/vue-in-viewport-mixin/releases/tag/v2.0.0

from vue-in-viewport-mixin.

weotch avatar weotch commented on June 3, 2024

Could you describe more what you mean by "moving in the dom"? Like touching CSS top / left with JS?

from vue-in-viewport-mixin.

Dadibom avatar Dadibom commented on June 3, 2024

Sure, sorry. I am using this for an auto scroller. When the element is in view, more content will be loaded. However, when that content is added to the dom, causing the autoscroller element to be pushed outside the viewport, inViewport.now will remain true until the user scrolls.

from vue-in-viewport-mixin.

weotch avatar weotch commented on June 3, 2024

What happens if you call updateInViewport() on the component you've mixed the package into AFTER the additional content has loaded? Does that update the state? If it doesn't, the next problem to solve is how to get scrollMonitor (a package this one consumes) to update it's measurements.

Perhaps you could call (if my first suggestion doesn't work):

this.scrollMonitor.recalculateLocation()
this.updateInViewport()

from vue-in-viewport-mixin.

ca11ado avatar ca11ado commented on June 3, 2024

The same problem.

  • component loaded in viewport; inViewport.now === true
  • another component loads big image and component now not in viewport; Still inVieport.now === true

inViewport.now properly recalculted if I do some scroll

this.scrollMonitor.recalculateLocation()
this.updateInViewport()

doesn't work

from vue-in-viewport-mixin.

bluetomato avatar bluetomato commented on June 3, 2024

I'm having the same issue.
I've got a grid with lots of products, so i'm loading only images of products in viewport (or almost). if i change the product order via button and javascript, it appears that the products now in viewport don't know their new state. at least not until the user scrolls again.

also i dont want to call a function for updating the inViewport everywhere i change the dom via javascript, the component should handle this by itself!

from vue-in-viewport-mixin.

weotch avatar weotch commented on June 3, 2024

Yeah, ScrollMonitor doesn't have an API method to fully recaculate itself ... like I haven't had a lot of success with it's recalculateLocation() method. However, I have done this on some projects to get it to recaculate:

window.dispatchEvent(new CustomEvent('resize'))

Essentially, I fake a resize event and this forces ScrollMonitor to reassess itself.

from vue-in-viewport-mixin.

weotch avatar weotch commented on June 3, 2024

I'll soon be releasing a breaking 2.0 version of this package that uses the IntersectionObserver and will fix issues like this since it's not scroll based. It's is on master right now: https://github.com/BKWLD/vue-in-viewport-mixin

from vue-in-viewport-mixin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.