Implementing carousel with a single DOM node You can use backgroundImage to add multiple images and offset them to achieve a carousel effect.
/** * Play picture */ function playImage(src) { if (animaitionFinshed) return; if (!_imageEl) { _imageEl = document.createElement('div') _imageEl.className = `swiper_container`; _imageEl.style.backgroundImage = `url(${src.url})`; _imageEl.setAttribute("data-img", src.url); elContainer.appendChild(_imageEl); } else { animaitionFinshed = true; let width = elContainer.clientWidth, height = elContainer.clientHeight; let preImage = _imageEl.getAttribute("data-img"); _imageEl.style.backgroundImage = `url(${preImage}),url(${src.url})`; _imageEl.style.backgroundPositionX = `center,${width + 20}px`; setTimeout(() => { _imageEl.style.transition = "all 0.8s ease"; _imageEl.style.backgroundPositionX = `-${width + 20}px,center`; }, 0); setTimeout(() => { _imageEl.style.transition = "none"; _imageEl.style.backgroundImage = `url(${src.url}) `; _imageEl.style.backgroundPositionX = `center`; _imageEl.setAttribute("data-img", src.url) animaitionFinshed = false; }, 800) } } source code The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: Summary of the differences between Html, sHtml and XHtml
>>: Example of deploying MySQL on Docker
Table of contents Preface Generation of redo log ...
Table of contents 1. Use scripts to encrypt TLS f...
mysql copy one table column to another table Some...
Table of contents 1. Check whether MySQL has been...
Table of contents 1. Synchronous AJAX 2. Asynchro...
1. Introduction to VMware vSphere VMware vSphere ...
Preface In order to ensure the consistency and in...
If there is a table product with a field add_time...
1. <body background=image file name bgcolor=co...
Preface During my internship at the company, I us...
background Getting the slow query log from mysql....
Table of contents 1. Values within loop objects...
This article shares the specific code for JavaScr...
Copy code The code is as follows: <html> &l...
This article shares the specific code of videojs+...