轉盤抽獎外掛-jquery.lottery.js
外掛說明:
用於轉盤隨機抽獎,現在設的是轉盤的指標動,指標停留的位置需要自己設定,需要後端返回的資料型別格式為 一等獎:{code : 1 ,msg :'一等獎' } 失敗 {code : 5XX,msg:' '}
可以把成功和失敗返回的後臺資料, 利用 success 和 error回撥函式進行處理。效果:
關於如何設定指標停留的角度,開啟控制檯,選中指標,修改其
外掛依賴:
jquery.easing.js jQueryRotate.js
引數說明:
duration
轉動的時間 單位ms 預設為 duration: 5000
round
轉動的圈數 360 * n 預設為 round:1440
success
中獎後的回撥 預設為 success:function(){}
error
出錯後的回撥 預設為 error:function(){}
setAngle
設定指標停的位置 該引數必須自己根據實際開發情景配置
setAngel:{
0:[70,114,201,289,335], //未中獎代表的角度
1:158, //一等獎的角度
2:244, //二等獎
3: 25 //三等獎
}
url
後臺資料來源的url 預設為 url:‘’
data
向後臺傳的資料 預設為 data : ‘’
呼叫:
$('#luckyDraw').lottery(options);
原始碼:
/* 抽獎外掛 依賴後端資料型別{code:0} code代表幾等獎 {code : 5XX}代表失敗 需要配置的引數:setAngel:{ 0:[70,114,201,289,335], //未中獎代表的角度 1:158, //一等獎的角度 2:244, //二等獎 3: 25 //三等獎 } 呼叫 $('#luckyDraw').lottery(options); 依賴的檔案 jquery.easing.js jQueryRotate.js */ ;(function($,window,document){ var defaults = { //指標轉動的時間 ms duration : 5000, //圈數 360* n round : 1440, //指標初始位置 angel : 0, //中獎後的回撥 success: function (rs) { }, //出錯後的回撥 error : function(rs){ }, //角度及獎項設定 setAngle: { 0:[70,114,201,289,335], 1:158, 2:244, 3: 25 }, //資料來源 url:'', //傳送的資料 data:'' }, //快取 _that, //建構函式 Plugin = function(element,options){ this.element = element; this.options = $.extend({},defaults,options); this.init(); }; Plugin.prototype.init = function(element,options){ _that = this; //繫結元素click $(this.element).rotate({ bind:{ click:function(){ sendMsg(_that.options.url,_that.options.data) } } }); }; //外掛 jQuery.fn.lottery = function(options){ return this.each(function(){ if(!$.data(this,'lottery')){ $.data(this,'lottery',new Plugin(this,options)); } }) }; //傳送請求 var sendMsg = function(url ,data){ $.get(url,data,function(rs){ var rs = window._rs = JSON.parse(rs); //成功後的回撥 rs.code > 500 ? _that.options.error(rs) : //失敗後的回撥 rotateFunc(rs.code,_that.options.setAngle[rs.code],_that.options.success); }); }, //指標移動 rotateFunc = function(awards, angel, callback){ $(_that.element).stopRotate(); $(_that.element).rotate({ angel : 0, duration : _that.options.duration, callback : function(){ callback.call(null,window._rs); } }) }; })(jQuery,window,document,undefined);
DEMO
相關推薦
轉盤抽獎外掛-jquery.lottery.js
外掛說明: 用於轉盤隨機抽獎,現在設的是轉盤的指標動,指標停留的位置需要自己設定,需要後端返回的資料型別格式為 一等獎:{code : 1 ,msg :'一等獎' } 失敗 {code : 5XX,msg:' '} 可以把成功和失敗返回的後臺資料, 利用 succes
分頁外掛jquery.simplePagination.js使用筆記
1. test_box.jsp頁面: <script type="text/javascript" src="${ctxJs}/jquery-1.7.2.min.js"></script> <script src="${ctxJs}/jquery.simpl
JS-- jQuery遮罩外掛 jquery.blockUI.js
Overview jQuery BlockUI 外掛可以在不同鎖定瀏覽器的同時,模擬同步模式下發起Ajax請求的行為。該外掛啟用時,會組織使用者在頁面進行的操作,直到外掛被關閉。BlockUI通過向DOM中新增元素實現其外觀和組織使用者互動的行為。 使用jQuery Blo
表單驗證外掛jquery.validate.js
<spanstyle="white-space:pre"></span>class="required" 必須填寫 <spanstyle="white-space:pre"></span>class="required email"
jQuery外掛jquery.kxbdmarquee.js實現無縫滾動效果
轉:https://www.jb51.net/article/105618.htm 這篇文章主要為大家詳細介紹了jQuery常用外掛jquery.kxbdmarquee.js使用方法詳解,具有一定的參考價值,感興趣的小夥伴們可以參考一下 1.html程式碼 <head> &
jQuery懶載入外掛 – jquery.lazyload.js簡單呼叫
Lazy Load 是一個用 JavaScript 編寫的 jQuery 外掛. 它可以延遲載入長頁面中的圖片. 在瀏覽器可視區域外的圖片不會被載入, 直到使用者將頁面滾動到它們所在的位置. 這與圖片預載入的處理方式正好是相反的.在包含很多大圖片長頁面中延遲載入圖片可以加快
jQuery延遲載入(懶載入)外掛 – jquery.lazyload.js
Lazy Load 是一個用 JavaScript 編寫的 jQuery 外掛. 它可以延遲載入長頁面中的圖片. 在瀏覽器可視區域外的圖片不會被載入, 直到使用者將頁面滾動到它們所在的位置. 這與圖片預載入的處理方式正好是相反的.在包含很多大圖片長頁面中延遲載入圖片可以加快頁
jQuery外掛 -- 動態事件繫結外掛jquery.livequery.js
動態事件繫結外掛livequery, 可以利用它給相應的DOM元素註冊事件或者觸發回撥函式。不僅當選擇器匹配的元素會被繫結事件,而且後來通過JavaScript新增的元素都會被繫結事件。當元素不再和選擇器匹配時,livequery會自動取消事件註冊,使得開發者不再需要關注H
圖片裁剪上傳外掛—jquery.photoClip.js
.img-preview { overflow: hidden; } .img-preview-box .img-preview-lg { width: 150px; height: 150px; } .img-prev
JavaScript操作SVG畫相簿:基於jquery的外掛jquery.svgmagic.js
1.svgmagic.js外掛操作SVG方法: 示例:http://blog.csdn.net/linshutao/article/details/30053233 jquery.svgmagic.js地址:https://github.com/dirkgroenen/SV
jQuery旋轉外掛jquery.rotate.js 讓圖片旋轉
演示1 直接旋轉一個角度 $('#img1').rotate(45); 演示2 滑鼠移動效果 $('#img2').rotate({ bind : { mouseover : function(){ $(this).rotate({animateTo: 1
一款很好用的Jquery 列印外掛——jQuery.print.js
在進行網頁開發中不可避免會使用到列印功能,下面就來學習一下一款簡單易用的外掛吧! 配置引數 你可以在呼叫列印方法時傳入一些引數: $("#myElementId").print({ globalStyles:true,//是否包含父文件的樣式,預設為t
一個很好的滾動條外掛jquery.slimscroll.js
該外掛的下載地址: https://codeload.github.com/rochal/jQuery-slimScroll/zip/v1.3.0 安裝Set up 首先需要引入jquery 在次需要引入:<script s
使用jQuery的外掛jquery.corner.js來實現圓角效果-詳解
jquery.corner.js可以實現各種塊級元素的角效果,以下為演示,詳見jquery_corner.html中的註釋部分,並附百度盤下載 jquery_corner.html程式碼如下: 1 <!DOCTYPE html> 2 <html> 3 <head>
jquery.rotate.js 轉盤抽獎示例
使用jquery.rotate.js 外掛簡單的轉盤抽獎示例: 1.引入jQuery和jquery.rotate.js外掛 <script src="static/js/jquery.min.js"></script> <script src="static/j
利用jQuery旋轉外掛jqueryrotate製作轉盤抽獎
<!DOCTYPE html><html> <head lang="en"> <meta charset="UTF-8"/> <meta name="viewport" conte
jquery.rotate外掛實現轉盤抽獎示例
css程式碼:.draw-out{width:400px;height:400px;margin:30px auto;position:relative} .draw-bottom{width:400px;height:400px;position:relative}
js實現遊戲轉盤抽獎
document .cn itl interval 空格 device max floor star <!DOCTYPE html> <html> <head> <title>js抽獎</title>
前端外掛jquery.singlePageNav.min.js(導航點選選單跳轉與點選縮放選單摺疊按鈕緩衝效果外掛)
Bootstrap導航點選選單跳轉與點選縮放選單摺疊按鈕緩衝效果外掛jquery.singlePageNav.min.js 引入步驟: <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"><
jquery外掛匯出與word:jquery.wordexport.js
前言 今天專案中遇到一個需求把我們系統中的統計資料匯出來(主要是表格)。其實實現的的方法有很多,而此次針對我的系統第一獲取資料有點慢,加上前不久寫了一個線上閱讀pdf與word,故此這次也想用前端的方式來匯出。其實網上大致是兩種一種是微軟那種直接排除了,選擇了運用第三方外掛的方式。我用的jquery.w