


Introduction
In the Noah Wealth Project, the address book is used. If it is just a simple view, I personally think it may be too monotonous, so on the basis of viewing, the click and slide effect is added. There are two purposes: 1. A good experience. 2. The address book has a large amount of data. When we click on a module and slide the module to the top, the visible range will also become larger.
Effect
Click a module and the page will start to slide upward until the module is at the top of the page.
This is the place before clicking. We click on the operation center:
After clicking, there will be a sliding animation to slide this module to the top:
Implementation
Get elements and dynamically generate ids
When we click on an element, we need to let the program know where we clicked, which is specific to a p, not our finger click place.
As introduced in the previous wiki, the data format returned by the interface is a one-dimensional array. When converting into a multi-dimensional array, the data needs to be traversed once. At this time, we can add ids to each piece of data. :
Bind the id like this on the front-end page
<p><br/></p>
scrolltop in Jquery
Generally everyone will think of this method of using jquery,
The method of use is:
$(selector).scrollTop(offset)
This can realize sliding, but during use, I found that: when you click on the same module, the distance of clicking and sliding is different at different sliding positions, and the content slid to the upper layer cannot be slid back. This is inconsistent with our The needs are seriously inconsistent.
We also researched some other plug-ins, but none of them can achieve the effect we want. Will such a powerful ionic framework provide us with such a method?
$ionicScrollDelegate
Delegates control of the scroll view (created through the ion-centent and ion-scroll directives).
This method is directly triggered by the $ionicScrollDelegate service to control all scroll views. Use the $getByHandle method to control a specific scroll view.
This contains more methods, among which the resize() method will be often used in ng-if. In addition,
it provides a method to get the current scroll height of the screen, getPositionScroll( ):
getScrollPosition()
• Return: The position where the object scrolls to this view, with the following properties:
o {value} left The distance from the left to the user's scroll ( starts at 0).
o {Number} top The distance from the top to where the user has scrolled (starts at 0).
Here we only need to use the vertical height, so use $ionicScrollDelegate.getPositionScroll().top to get the current scroll height.
ScrollTo and scrollBy
These two methods are similar to the relationship between absolute path (scrollTo) and relative position (scrollBy).
We get the position of the currently clicked module using the following method:
document.getElementById(x.id).offsetTop
What we get here is the position of this p from the top, But our requirement every time is that we want the module we click to slide to the top of the screen, not the top of the entire content, so it is better for us to use scrollBy here.
In this case, you only need to move the distance from the top of the screen to the clicked module each time. The method is:
var scroll = document.getElementById(x.id).offsetTop - $ionicScrollDelegate. getScrollPosition().top;
Then call ionic’s own scrollBy method in the click method:
$ionicScrollDelegate.resize();
$ionicScrollDelegate.scrollBy(0,scroll ,true);
So far, this function has been implemented, I hope it will be helpful to everyone.
This is the end of this article. Ionic has implemented imitation address book click sliding and $ionicscrolldelegate usage analysis. I hope it will be helpful to everyone.

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

This tutorial shows you how to integrate a custom Google Search API into your blog or website, offering a more refined search experience than standard WordPress theme search functions. It's surprisingly easy! You'll be able to restrict searches to y

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

This article series was rewritten in mid 2017 with up-to-date information and fresh examples. In this JSON example, we will look at how we can store simple values in a file using JSON format. Using the key-value pair notation, we can store any kind

Enhance Your Code Presentation: 10 Syntax Highlighters for Developers Sharing code snippets on your website or blog is a common practice for developers. Choosing the right syntax highlighter can significantly improve readability and visual appeal. T

Leverage jQuery for Effortless Web Page Layouts: 8 Essential Plugins jQuery simplifies web page layout significantly. This article highlights eight powerful jQuery plugins that streamline the process, particularly useful for manual website creation

This article presents a curated selection of over 10 tutorials on JavaScript and jQuery Model-View-Controller (MVC) frameworks, perfect for boosting your web development skills in the new year. These tutorials cover a range of topics, from foundatio

Core points This in JavaScript usually refers to an object that "owns" the method, but it depends on how the function is called. When there is no current object, this refers to the global object. In a web browser, it is represented by window. When calling a function, this maintains the global object; but when calling an object constructor or any of its methods, this refers to an instance of the object. You can change the context of this using methods such as call(), apply(), and bind(). These methods call the function using the given this value and parameters. JavaScript is an excellent programming language. A few years ago, this sentence was


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
