fontselect-jquery-plugin
fontselect-jquery-plugin copied to clipboard
Clicking dropdown scrolls to selected font every other time
I noticed that when I click the dropdown, the selected font would only be moved to the top of the list every other time. The other clicks would incorrectly leave the list scrolled to a position near the top of the list. I found the problem to be the calculation of the position to which the list is scrolled. Since the selected font was already near the top from the previous dropdown click, the position().top used for the scrollTop function was 0 (or something close to that). Therefore, the list would be scrolled back to the top of the list instead of the position of the selected font. I fixed it by adding a scrollTop(0) to first return to the top of the list so that the position of the selected font would be calculated correctly. Here is the corrected line 304:
this.$results.scrollTop(0).scrollTop($li.addClass('active').position().top);
Great Thanks for sharing :)
I find it works better when you take that line completely out. I kept getting an error trying to get top for undefined...