BKWLD / vue-in-viewport-directive

Vue 2 directive that adds css classes when the element is the viewport

Home Page:https://bkwld.github.io/vue-in-viewport-directive

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make work with components that also set there own class

weotch opened this issue · comments

Like so it can be used on a vue-visual instance.

I came up with a solution by passing the vnode through to the update function and then setting this at the end:

vnode.data.staticClass += ' ' + el.classList.value

This fixed the specific issue I was investigating this for. But then I ran across this: vuejs/vue#3871. Also, it seems risky, like I don't totally understand how staticClass works and I would be touching it as viewport changes. Like it's not really static ...

I think in cases where this would be used on a component that sets a dynamic class, it should instead be applied to a parent element.