


Simplified version of mobile phone photo preview component_javascript skills
Poor, I use a Huawei 3C mobile phone, and it’s easy to use other people’s ready-made components. In order to adapt to a loser like me, I simplified and wrote a version of the photo preview effect. There is no zoom function for the time being. I may try it again when I have time. Add it, you can also add it yourself, this is an open source project on github. Its github address is: https://github.com/tianxiangbing/mobile-photo-preview
The following is a preview,
Usage examples:
var photoPreview = new MobilePhotoPreview(); photoPreview.init({ target: $('.preview-list'), trigger: '.preview', show: function(c) { var del = $('<span class="icon-del"><span>'); $('.imgViewTop', c).append(del); del.tap(function() { photoPreview.current.remove(); photoPreview.hide(); }); } });
or:
$('.preview-list').MobilePhotoPreview({ trigger: '.preview', show: function(c) { var del = $('<span class="icon-del"><span>'); $('.imgViewTop', c).append(del); var _this = this; del.tap(function() { _this.current.remove(); _this.hide(); }); } });
Note: There is no essential difference between the two methods. The first one is recommended.
API properties, methods and callbacks:
target:
It means that the elements in this container will trigger the event. It is a range and is used together with trigger to delegate the event node, so it is necessary. It is recommended not to delegate the root node.
trigger:
Represents the object that triggers the event. It can be dynamic. By default, it is triggered by a link under the target
show:
The callback after display, the parameter is the dialog container, and this currently points to the instance of MobilePhotoPreview. This is a callback method to extend more functions. In order to better use this callback, you may be interested in the following properties
Properties and methods under this:
current:
Current node object
currentIndex:
Current index
objArr:
Array object, here, you can get a collection, including index, element, width, and height. This will be very useful stuff.
hide:
What is called is the hide.
The above is the entire content of this article, I hope you all like it.

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



NumPy is a very useful and widely used library in data processing and machine learning applications. An important feature of NumPy is that it provides a large number of tool functions for mathematical operations on arrays and matrices in Python, which makes NumPy an important tool in the field of scientific computing. However, in many cases we need to convert NumPy arrays to Python lists (or other similar data types) for better use in our code. Although NumPy arrays are in many ways better than P

PHP Arrow Function: How to Simplify Loop Processing, Need Specific Code Examples Introduction: With the release of PHP7.4, arrow functions have become a very interesting new feature in PHP. The emergence of arrow functions makes us more concise and convenient when dealing with loops. This article will introduce the basic syntax of arrow functions and how to use arrow functions to simplify loop processing, and give specific code examples. The basic syntax of arrow functions The syntax of arrow functions is very simple and can be regarded as a shortcut way of writing anonymous functions. its grammatical structure

How to solve the problem of mobile keyboard blocking input box in Vue development. With the popularity of mobile devices, more and more web applications are widely used on mobile phones. However, during development, we often encounter a very common problem, that is, the keyboard on the mobile phone blocks the input box. When the user uses the input box to input, if the keyboard blocks the input box, it will cause inconvenience and trouble to the user. How to solve this problem in Vue development? Below, I'll introduce a few solutions. Solution 1: Use vue-keyboar

NullCoalesce operator in PHP7: How to simplify the conditional judgment of the code? During the development process, we often need to perform conditional judgments on variables to determine whether they have a value or whether they are null. The traditional way is to use if statements or ternary operators to perform conditional judgments, but this way of writing seems lengthy and complicated in some cases. Fortunately, the NullCoalesce operator (??) was introduced in PHP7, which can help us simplify the way we write code and improve development efficiency. N

CakePHP Middleware: Simplify your application development process Introduction: Middleware is a common development concept used to add reusable functionality to the request processing process of an application. In CakePHP, middleware can help developers simplify the application development process and improve code reusability and maintainability. This article will introduce how to use CakePHP middleware, and how to write and apply middleware to optimize your application. 1. What is CakePHP middleware? Middleware is used after request processing

With the rapid development of mobile Internet, more and more websites are beginning to adopt mobile development. In mobile phone development, sliding to switch pages is a common requirement. As a popular front-end framework, Vue provides us with a convenient solution to achieve sliding switching pages. In Vue development, we usually use VueRouter to manage page routing. VueRouter provides a router-link component that can easily jump between pages. But on the mobile side, we

How to choose the appropriate CSS framework on mobile phones? With the popularity of mobile devices and the rapid development of the Internet, more and more people browse the Internet through their mobile phones. In order to present a good user experience on mobile phones, developers need to choose a suitable CSS framework for development. This article will introduce how to choose the appropriate CSS framework on the mobile phone to help developers better develop mobile web pages. 1. Understand different CSS frameworks Before choosing a CSS framework, you first need to understand different CSS frameworks. Common CSS at the moment

How to use third-party libraries to simplify Java function development Introduction: Java, as a widely used programming language, has rich functions and libraries. These libraries are valuable resources for developers and can help them develop applications more efficiently. Among them, third-party libraries refer to libraries written by third-party developers and available for developers to use. This article will introduce how to use third-party libraries to simplify the development of Java functions and illustrate it through code examples. 1. Understand the needs Before starting to use third-party libraries, you first need to understand your own development needs.
