How to use JS to realize slippery Slide
Editor to share with you how to use JS to achieve slideshow slides, I believe that most people do not understand, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Example
Documentbody {margin: 0;} # wrap {margin: 100px auto;position: relative;width: 400pxTH height: 300px border: 5px solid # 000X height: hidden;} # list {position: absolute;left: 0 position top: 0 position width: 400% position style: none;padding: 0 position margin: 0;} # list li {width: 25% position float: left;} img {vertical-align: top;} # navs {position: absolute;left: 0X bottom: 30pxscape height: 12pxscape width: 100% landscape match: center } # navs a {display: inline-block;width: 12pxposition height: 12pxposition verticalmatch: top;background: # fff;margin: 05pxbordermuri radius: 6px;} # navs .active {background: # f60;}
(function () {var wrap = document.querySelector ('# wrap'); var list = document.querySelector ('# list'); var navs = document.querySelectorAll ('# navs a'); var wrapW = css (wrap, "width"); list.onmousedown = function (e) {clearInterval (list.timer); / / clear animation var startMouseX = e.clientXten var elX = css (list, "left"); _ document.onmousemove = function (e) {var nowMouseX = e.clientXmittcss (list, "left", nowMouseX-startMouseX + elX);} _ document.onmouseup = function (e) {_ document.onmousemove = null;_document.onmouseup = null;var left = css (list, "left"); var now =-Math.round (left/wrapW); / / get several pictures console.log (now); now = nownavs.length-1?navs.length-1:now;left = now * wrapW / / calculate the distance left needs to walk to this picture: startMove ({el: list,target: {left:-left}, type: "easeOutStrong", time: 800}); for (var I = 0; I < navs.length; iTunes +) {navs [I] .className = "";} navs [now] .className = "active";}; return false;// blocks default events (where the role prevents the picture from being selected)};}) () The above is all the contents of the article "how to use JS to achieve slippery screen slides". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!