滑动解锁插件SlideUnlock

slideunlock-plugin

html

<div class="slideunlock-wrapper"> <input type="hidden" value="" class="slideunlock-lockable"/> <div class="slideunlock-slider"> <span class="slideunlock-label"></span> <span class="slideunlock-lable-tip">Slide to unlock!</span> </div> </div> css

In this case, just set the slider and container style, according to the needs of custom css or pictures, etc.

.slideunlock-wrapper{ width: 360px; position: relative; padding: 50px; background: #ECF0F1; margin: 0 auto; } .slideunlock-slider{ padding:20px; position: relative; border-radius: 2px; background-color: #FDEB9C; overflow: hidden; text-align: center; } .slideunlock-slider.success{ background-color: #E5EE9F; } .slideunlock-label{ width: 40px; position: absolute; left: 0; top: 0; height: 100%; background: #E67E22; z-index: 999; border-radius: 2px; cursor: pointer; } .slideunlock-label-tip{ z-index: 9; } @media screen and (max-width: 640px) { .slideunlock-wrapper{ width: 64%; } } JavaScript

independent of jQuery. See the demo

<script type="text/javascript" src="js/slideunlock.min.js"></script> <script type="text/javascript"> window.onload = function () { var slider = new SliderUnlock(".slideunlock-slider", {}, function(){ alert('success'); }, function(){ document.querySelector(".warn").innerText = "index:" + slider.index + ", max:" + slider.max + ", lableIndex:" + slider.lableIndex + ", value:" + document.querySelector(".slideunlock-lockable").value + ", date:" + new Date().getUTCDate(); }); slider.init(); document.querySelector("#reset-btn").addEventListener('click', function(){ slider.reset(); }); } </script>

depend on jQuery. See the demo

<script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.slideunlock.min.js"></script> <script type="text/javascript"> $(function () { var slider = new SliderUnlock(".slideunlock-slider", { labelTip: "滑动解锁", successLabelTip: "解锁成功", duration: 200 // 动画效果执行时间,默认200ms }, function(){ alert('success'); }, function(){ $(".warn").text("index:" + slider.index + ", max:" + slider.max + ", lableIndex:" + slider.lableIndex + ", value:" + $(".slideunlock-lockable").val() + ", date:" + new Date().getUTCDate()); }); slider.init(); $("#reset-btn").on('click', function(){ slider.reset(); }); }) </script>

var slider = new SliderUnlock(element, options, success, always); slider.init(); // element is required and right. id or class or any identifying which can be loaded by jquery. // if you dont want to give options, please give a null object, like this -- {}

If you need to support mobile,Please add jQuery mobile plugin:

<script type="text/javascript" src="js/jquery.mobile.min.js"></script> Demo

See the Pen jquery-slide-unlock by Arron.y (@ArronYR) on CodePen.

<script async src="//assets.codepen.io/assets/embed/ei.js"></script> About me

Article:SlideUnlock-Plugin

Blog:http://blog.helloarron.com

版权声明:

1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。
2、网站不提供资料下载,如需下载请到原作者页面进行下载。