һ
 ע

QQ¼

ֻһٿʼ

ƼĶ

+
̳ WEBҳǰ뿪 ǰ̨ű

ƶֻAPPָлͼƬЧ

[]
37387 happy175 2016-3-3 11:50:35
| ʾȫ¥
1F

һЧdzſƶֻAPPָлͼƬЧAPPЧƶֻûָͨһлͼƬ豸ͨҲɴﵽͬЧ




Ԥ     أ



ʹ÷
HTMLṹ

ƶֻAPPлͼƬЧHTMLṹǶ׵HTMLṹÿһͼƬƬ div.demo__card УͼƬϢһЩͼ㡣


  1. <div class="demo__card">
  2.   <div class="demo__card__top brown">
  3.     <div class="demo__card__img"></div>
  4.     <p class="demo__card__name">Hungry cat</p>
  5.   </div>
  6.   <div class="demo__card__btm">
  7.     <p class="demo__card__we">Whatever</p>
  8.   </div>
  9.   <div class="demo__card__choice m--reject"></div>
  10.   <div class="demo__card__choice m--like"></div>
  11.   <div class="demo__card__drag"></div>
  12. </div>
ƴ


m--reject ƶͼƬʱͼ㣬m--like ƶͼƬʱͼ㣬demo__card__drag ϶㡣


JavaScript

jqueryУpullChange() תǶȺ͸ȡrelease() жûһָΪЩDOMԪӦclass

  1. function pullChange() {
  2.     animating = true;
  3.     deg = pullDeltaX / 10;
  4.     $card.css('transform', 'translateX(' + pullDeltaX + 'px) rotate(' + deg + 'deg)');
  5.     var opacity = pullDeltaX / 100;
  6.     var rejectOpacity = opacity >= 0 ? 0 : Math.abs(opacity);
  7.     var likeOpacity = opacity <= 0 ? 0 : opacity;
  8.     $cardReject.css('opacity', rejectOpacity);
  9.     $cardLike.css('opacity', likeOpacity);
  10. }
  11. ;
  12. function release() {
  13.     if (pullDeltaX >= decisionVal) {
  14.         $card.addClass('to-right');
  15.     } else if (pullDeltaX <= -decisionVal) {
  16.         $card.addClass('to-left');
  17.     }
  18.     if (Math.abs(pullDeltaX) >= decisionVal) {
  19.         $card.addClass('inactive');
  20.         setTimeout(function () {
  21.             $card.addClass('below').removeClass('inactive to-left to-right');
  22.             cardsCounter++;
  23.             if (cardsCounter === numOfCards) {
  24.                 cardsCounter = 0;
  25.                 $('.demo__card').removeClass('below');
  26.             }
  27.         }, 300);
  28.     }
  29.     if (Math.abs(pullDeltaX) < decisionVal) {
  30.         $card.addClass('reset');
  31.     }
  32.     setTimeout(function () {
  33.         $card.attr('style', '').removeClass('reset').find('.demo__card__choice').attr('style', '');
  34.         pullDeltaX = 0;
  35.         animating = false;
  36.     }, 300);
  37. };
ƴ

mousedown touchstart ¼Է .inactive ĿƬԪִпƬл

  1. $(document).on('mousedown touchstart', '.demo__card:not(.inactive)', function (e) {
  2.     if (animating)
  3.         return;
  4.     $card = $(this);
  5.     $cardReject = $('.demo__card__choice.m--reject', $card);
  6.     $cardLike = $('.demo__card__choice.m--like', $card);
  7.     var startX = e.pageX || e.originalEvent.touches[0].pageX;
  8.     $(document).on('mousemove touchmove', function (e) {
  9.         var x = e.pageX || e.originalEvent.touches[0].pageX;
  10.         pullDeltaX = x - startX;
  11.         if (!pullDeltaX)
  12.             return;
  13.         pullChange();
  14.     });
  15.     $(document).on('mouseup touchend', function () {
  16.         $(document).off('mousemove touchmove mouseup touchend');
  17.         if (!pullDeltaX)
  18.             return;
  19.         release();
  20.     });
  21. });
ƴ




аԴ

Ҫ ¼ ſػ鿴ûʺţע  

x
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ
kaorou37 2016-3-4 04:26:39
| ʾȫ¥
2F
Ҫ,¥ͷDz
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
kaorou37 2016-3-4 15:03:26
| ʾȫ¥
3F
Ҫ,¥ͷDz
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
fhuj3d96 2016-12-3 02:47:09
| ʾȫ¥
4F
ǺܺõӶ
ȷӡˢ http://www.bjard.com
ӡˢ http://www.bjard.com
ȷֽ䳧 http://www.bjard.com
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
fhuj3d96 2016-12-7 15:31:54
| ʾȫ¥
5F
DZģУ
http://www.xszsz.com/tai/1860.html
http://www.xszsz.com/tai/1861.html
http://www.xszsz.com/tai/1862.html
http://www.xszsz.com/tai/1863.html
http://www.xszsz.com/tai/1864.html
http://www.xszsz.com/tai/1865.html
http://www.xszsz.com/tai/1880.html
http://www.xszsz.com/tai/1881.html
http://www.xszsz.com/tai/1882.html
http://www.xszsz.com/tai/1897.html
http://www.xszsz.com/tai/1898.html
http://www.xszsz.com/tai/1899.html
http://www.xszsz.com/tai/1883.html
http://www.xszsz.com/tai/1884.html
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
fhuj3d96 2017-1-14 04:01:08
| ʾȫ¥
6F
ллˣ
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
fhuj3d96 2017-1-17 22:46:54
| ʾȫ¥
7F
Ҳˣܲղ
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
lushan517034 2017-7-2 09:13:51
| ʾȫ¥
8F

μccc֤         http://www.rlzlt.com/
ѡCCC֤         http://www.rlzlt.com/
CCCȫ         http://www.rlzlt.com/
ϵȫ         http://www.rlzlt.com/
TS16919֤         http://www.rlzlt.com/
Ts27001֤         http://www.rlzlt.com/
רҵѹ         http://www.rlzlt.com/
ҵϵ         http://www.rlzlt.com/
йϵ֤         http://www.rlzlt.com/
йCCC֤         http://www.rlzlt.com/
ȡ֤         http://www.rlzlt.com/
й֤         http://www.rlzlt.com/
cqcй֤         http://www.rlzlt.com/
й֤         http://www.rlzlt.com/
ϵ֤Ȩ         http://www.rlzlt.com/
Ȩisoϵ֤         http://www.rlzlt.com/
йccc֤         http://www.rlzlt.com/
йǿ֤ccc         http://www.rlzlt.com/
йccc֤         http://www.rlzlt.com/
йccc֤ƽ̨         http://www.rlzlt.com/
װerp              http://www.hanson.cn/
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
б

ֹ

²

̳¡ͼƬѷϴվԭתԻ,µİȨԭ
վַİȨ֪ͨǵĹԱ,Ա(Email:admin@websjy.com)ʱȡȨɾ
ܾκκʽڱ̳л񹲺͹ִ!

QQ| 42011102000510|Archiver|ֻ|Դ ( ICP14013341-1

GMT+8, 2017-9-21 22:13

Powered by Discuz! X3.2

ԴԴվ  ԴAPPӦ֮

ٻظ ض б