ovidiuch / dragdealer

Drag-based vanilla JS component
http://ovidiuch.github.io/dragdealer
MIT License
1.05k stars 149 forks source link

Can't initiate Dragdealer with DOM element while parent is hidden #101

Open onassar opened 9 years ago

onassar commented 9 years ago

Having trouble initiating a Dragdealer instance, passing in the DOM element itself. The catch is, if I run the code once it's parent container has had it's display: none; style removed, it works.

Here's the code I'm using:

new Dragdealer(el, {
    steps: 65,
    slide: false,
    snap: true,
    animationCallback: function(x, y) {

    }
});

I think if you try the same, ensuring that the parent container is hidden, you'll notice it.

onassar commented 9 years ago

Oh also worth mentioning is that the DOM element is not yet part of the document tree. I create the Dragdealer instance, and after that, add the element to the document tree.

ovidiuch commented 9 years ago

Known limitation. Currently Dragdealer only works on DOM elements attached to a document. Sorry for the inconvenience. Feel free to propose an addition to the documentation page to specify this.