buzinas / simple-scrollbar

Very simple and lightweight vanilla javascript library for creating a custom scrollbar cross-browser.
MIT License
575 stars 159 forks source link

Fix to rebuild scrollbar with ajax or other callbacks #55

Closed sazanof closed 4 years ago

sazanof commented 5 years ago

I tried to use you cool & lightweight scrollbal in my solution, ex xhr:

..................
for (var i = 0; i < data.features.length; i++) {
            var li = createLI(data.features[i]);
            ul.appendChild(li);
        }
        document.querySelector('#lists').innerHTML = '';
        document.querySelector('#lists').appendChild(ul);
        SimpleScrollbar.initEl(document.querySelector('#lists'));
        ul.childNodes.forEach(function(el,index){
            el.onclick = function(){
                //console.log(el,i)
                console.log(index)
                clickOnLI(el,objectManager);
            }
        })
............

But its do not want to refresh scroll. I did this fix, If it useful - it will be cool

buzinas commented 4 years ago

Thanks for your contribution!