


How to realize that clicking on a letter in the WeChat friend list jumps to the corresponding position
Is there a function on WeChat, which is to jump to the corresponding position by clicking on the letter in the list? This article mainly introduces the relevant information on the WeChat applet development of the friend list letter list to jump to the corresponding position. I hope this article can help everyone. Everyone has implemented such a function. Friends who need it can refer to it. I hope it can help everyone.
WeChat applet development friend list letter list jump corresponding position
Foreword:
In the small The program implements the effect of clicking on the letter list on the right side of the WeChat friend list to jump to the corresponding position. I wrote a demo. The core part is very simple, so there are not many comments. If you encounter any problems, please join the group and ask me.
Core technical points:
1. The scroll-into-view and scroll-with-animation. scroll-y attributes of the scroll-view component of the mini program.
2. Application of touch event of mini program.
3. Application of Js timer.
view page code:
index.wxml
class="container" scroll-y> class="info" id="info" scroll-with-animation scroll-y scroll-top="200" scroll-into-view="{{toView}}" style="height:{{height}}px;"> class="iitem" id="{{item.id}}" wx:for="{{info_list}}" wx:key="1"> {{item.id}} . {{item.desc}} class="letter {{active == true ? 'active': ''}}" bindtouchstart='start' bindtouchmove='move' bindtouchend='end'> class="litem" bindtap='down' data-index="999">☆ class="litem" wx:for="{{letter_list}}" bindtap='down' wx:for-index="index" wx:key="2" data-index="{{index}}" style="height: {{letter_height}}px;">{{item}} class="tips" hidden="{{hide}}">{{curView}}
js code:
index.js
//index.js //获取应用实例 const app = getApp() Page({ data: { letter_list: [], info_list: [], hide: true, active: false, toView: 'A', curView: 'A', letter_height: 18 }, onLoad: function () { this.active = false; this.timer = null; var letter_list = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; var info_list = []; for (var i = 0; i < 26; i++) { var obj = {}; obj.id = letter_list; obj.desc = '这是一个用于测试的DEMO。1.目标是用于实现微信好友列表的点击首字母跳转到对应好友位置。2.目标是用于实现微信好友列表的点击首字母跳转到对应好友位置'; info_list.push(obj); } this.setData({ height: app.globalData.height, info_list: info_list, letter_list: letter_list, sHeight: 100 * 26 + 25 }); }, start: function (e) { this.setData({ active: true, hide: false }) }, end: function (e) { if (this.timer) { clearTimeout(this.timer); this.timer = null; } var moveY = e.changedTouches["0"].clientY - 18, that = this; var curIndex = parseInt(moveY / 18); var view = this.data.letter_list[curIndex]; this.setData({ toView: view, active: false }); if (!this.timer) { this.timer = setTimeout(function () { that.setData({ hide: true }) that.timer = null; }, 1000); } }, move: function (e) { var moveY = e.changedTouches["0"].clientY - 18; var curIndex = parseInt(moveY / 18); var view = this.data.letter_list[curIndex]; this.setData({ curView: view }) }, down: function (e) { if (this.timer) { clearTimeout(this.timer); this.timer = null; } var index = e.currentTarget.dataset.index, that = this; if (index != 999) { var view = this.data.letter_list[index]; this.setData({ toView: view, curView: view }) } else { this.setData({ toView: 'A', curView: '☆' }) } if (!this.timer) { this.timer = setTimeout(function () { that.setData({ hide: true }); that.timer = null; }, 1000); } } })
Style part
index.wxss
/**index.wxss**/ text { font-weight: bold } .letter { font-size: 12px; width: 24px; height: 100%; position: fixed; right: 0; top: 0; z-index: +999; } .litem { width: 24px; height: 18px; line-height: 18px; text-align: center; } .info { font-size: 12px; text-align: justify; overflow: hidden; } .active { background: rgba(0, 0, 0, 0.2); } .iitem { padding: 10rpx 10rpx; margin-bottom: 10rpx; border-radius: 8rpx; background: rgba(222,222,222,0.2); box-sizing: border-box; } .tips { width: 40px; height: 40px; background: rgba(0,0,0,0.4); font-size: 20px; text-align: center; line-height: 40px; color: #fff; position: fixed; left: 50%; top: 50%; margin: -20px; z-index: +999; border-radius: 10rpx;
Related recommendations:
How to implement the WeChat applet scroll view container
How to set the URL and token of the WeChat applet
How to obtain user information interface for the Thinkphp5 WeChat applet
The above is the detailed content of How to realize that clicking on a letter in the WeChat friend list jumps to the corresponding position. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Python is a very useful software that can be used for many different purposes depending on the need. Python can be used in web development, data science, machine learning, and many other fields that require automation. It has many different features that help us perform these tasks. Python lists are one of the very useful features of Python. As the name suggests, a list contains all the data you wish to store. It is basically a set of different types of information. Different Ways to Remove Square Brackets Many times, users come across a situation where list items are displayed within square brackets. In this article, we'll detail how to remove these brackets to get a better view of your listing. One of the easiest ways to remove parentheses in strings and replacement functions is in

How to use Python's count() function to calculate the number of an element in a list requires specific code examples. As a powerful and easy-to-learn programming language, Python provides many built-in functions to handle different data structures. One of them is the count() function, which can be used to count the number of elements in a list. In this article, we will explain how to use the count() function in detail and provide specific code examples. The count() function is a built-in function of Python, used to calculate a certain

In the add friend option of WeChat, enter the other party's WeChat ID and click Add. Tutorial Applicable Model: iPhone13 System: iOS15.3.1 Version: WeChat 8.0.19 Analysis 1 First, click the plus icon in the upper right corner of the WeChat homepage. 2 Then click Add Friends in the pop-up options. 3. Then enter the add friend page and enter the other party’s WeChat ID. 4After searching for the friend, click Add to Address Book to add the friend. Supplement: How to delete WeChat friends 1. First open and log in to WeChat, click on the address book at the bottom of the WeChat main page. 2Click to enter the homepage of the friend you want to delete, and click the three dots icon in the upper right corner of the page. 3 Enter the profile settings and click the delete option at the bottom of the page to delete friends. Summary/Precautions What are the friends deleted by WeChat?

In iOS 17, you can set multiple timers on your iPhone using the Clock app, or use Siri to set it hands-free. We discuss both in this article. Let's take a look at them. Set Multiple Timers on iPhone Using the Clock App Open the Clock app on your iPhone and tap the Timers tab in the lower right corner. Now, set the hours, minutes, and seconds. You can use the "Label" and "When does the timer end" options to set a name for the timer and a preferred tone when the timer completes. This will help you differentiate between timers. Once done, click the "Start" button. Then, click the "+" icon in the upper right corner. Now, repeat the above steps to set multiple timers on iPhone. You can also browse

WeChat is one of the most popular social applications currently, and friend management is an inevitable part of daily use. Sometimes, we may be curious whether certain friends have deleted us, but we don’t want to ask directly or cause embarrassment. Below, the editor has compiled 4 methods to check whether WeChat friends have deleted you. Let’s take a look! Method 1. Send a message directly The simplest and most direct method is to try to send a message to the other party. If the other party has deleted you, WeChat will prompt "The other party has turned on friend verification, and you are not his (her) friend yet. Please send a friend verification request first, and you can only chat after the other party has passed the verification." Method 2: Initiate a video or voice call Trying to initiate a video or voice call to the other party is also an effective method. If the other party has deleted you, the call will

You can search for the other party's WeChat ID on the add friend interface to retrieve it. Tutorial Applicable Model: iPhone13 System: iOS15.5 Version: WeChat 8.0.19 Analysis 1 Click the plus button in the upper right corner of the WeChat main interface. 2 Then click the Add Friend option in the pop-up window. 3 Next, enter the friend’s WeChat ID in the pop-up Add Friend page. 4. After finally searching for the friend, click Add to Address Book. Supplement: How to delete WeChat friends 1. First open WeChat and click on the address book at the bottom of the home page. 2 Then click on the friend you want to delete in the address book. 3Then click the three-dot button in the upper right corner of the details page. 4 Next, click the Delete option on the pop-up page. 5Finally, click Delete Contact. Summary/Notes

SolutionYes,Wecaninsertnullvaluestoalisteasilyusingitsadd()method.IncaseofListimplementationdoesnotsupportnullthenitwillthrowNullPointerException.Syntaxbooleanadd(Ee) Appends the specified element to the end of this list. Type parameter E − The runtime type of the element. Parameter e − element to be appended to this list

How to Make a GroceryList on iPhone in iOS17 Creating a GroceryList in the Reminders app is very simple. You just add a list and populate it with your items. The app automatically sorts your items into categories, and you can even work with your partner or flat partner to make a list of what you need to buy from the store. Here are the full steps to do this: Step 1: Turn on iCloud Reminders As strange as it sounds, Apple says you need to enable reminders from iCloud to create a GroceryList on iOS17. Here are the steps for it: Go to the Settings app on your iPhone and tap [your name]. Next, select i
