jQuery 拉霸機- jQuery-jSlots
簡單說就是用 jQuery 來做拉霸機,外掛網址
jQuery-jSlots
準備 html
- <ul class="slot">
- <li>1</li>
- <li>2</li>
- <li>3</li>
- <li>4</li>
- <li>5</li>
- <li>6</li>
- <li>7</li>
- </ul>
簡單使用
- $('.slot').jSlots({
- spinner : '#playBtn',
- winnerNumber : 7
- });
可以用的變數
- $.jSlots.defaultOptions = {
- number : 3, // Number: number of slots
- winnerNumber : 1, // Number or Array: list item number(s) upon which to trigger a win, 1-based index, NOT ZERO-BASED
- spinner : '', // CSS Selector: element to bind the start event to
- spinEvent : 'click', // String: event to start slots on this event
- onStart : $.noop, // Function: runs on spin start,
- onEnd : $.noop, // Function: run on spin end. It is passed (finalNumbers:Array). finalNumbers gives the index of the li each slot stopped on in order.
- onWin : $.noop, // Function: run on winning number. It is passed (winCount:Number, winners:Array, finalNumbers:Array)
- easing : 'swing', // String: easing type for final spin. I recommend the easing plugin and easeOutSine, or an easeOut of your choice.
- time : 7000, // Number: total time of spin animation
- loops : 6 // Number: times it will spin during the animation
- };
這個 plugin 的優點是可以自己訂樣式,所以只要熟 css,想要把拉霸機變得很漂亮也沒問題。
留言