fontselect-jquery-plugin icon indicating copy to clipboard operation
fontselect-jquery-plugin copied to clipboard

Clicking dropdown scrolls to selected font every other time

Open TNTitan opened this issue 10 years ago • 2 comments

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);

TNTitan avatar Jul 22 '14 14:07 TNTitan

Great Thanks for sharing :)

mo3aser avatar Apr 09 '16 12:04 mo3aser

I find it works better when you take that line completely out. I kept getting an error trying to get top for undefined...

ghost avatar Dec 03 '16 02:12 ghost