jQuery Alphabetical Search by Sliding Letters
Add-ons

Plugin Description: Implements an alphabetical search feature similar to the Apple Contacts list using jQuery.
Note: For the best display experience, please view on a mobile device.
Key Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | var domH = $(".term_nav li").height();var domY,moveY,index,item_top;$(".term_nav").on({ touchstart: function (e) { startY = e.originalEvent.targetTouches[0].pageY; }, touchmove: function (e) { e.preventDefault(); $("body").on({ touchmove: function (e) { e.preventDefault(); } }); domY = $(this).offset().top; moveY = e.originalEvent.targetTouches[0].pageY;index = parseInt((moveY-domY)/domH);$(".term_nav li").eq(index).addClass("on").siblings().removeClass("on"); item_top=$('.term_box').eq(index).offset().top-100;$(window).scrollTop(item_top); }, touchend: function () { $("body").off("touchmove") }}); |
评论