卡片形式(swipeable cards)的界面:swing

jopen 10年前發布 | 29K 次閱讀 JavaScript開發工具包 Swing

一個卡片形式(swipeable cards)的界面,用左右滑動來判斷是否輸入。就像在 JellyTinder等App中看到效果。
card-stack.gif

var stack,
    cards;

// Prepare the cards in the stack for iteration. cards = [].slice.call(document.querySelectorAll('ul li'))

// An instance of the Stack is used to attach event listeners. stack = Swing.Stack();

cards.forEach(function (targetElement) { // Add card element to the Stack. stack.createCard(targetElement); });

// Add event listener for when a card is thrown out of the stack. stack.on('throwout', function (e) { // e.target Reference to the element that has been thrown out of the stack. // e.throwDirection Direction in which the element has been thrown (Card.DIRECTION_LEFT, Card.DIRECTION_RIGHT).

console.log('Card has been thrown out of the stack.');
console.log('Throw direction: ' + (e.throwDirection == Card.DIRECTION_LEFT ? 'left' : 'right'));

});

// Add event listener for when a card is thrown in the stack, including the spring back into place effect. stack.on('throwin', function (e) { console.log('Card has snapped back to the stack.'); });</pre>

項目主頁:http://www.baiduhome.net/lib/view/home/1414738287340

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!