Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function()
  2. 9{
  3. 10 $('.wall-conteiner').WallSlider();
  4. 11});
  5. 12
  6. 13jQuery.fn.WallSlider = function()
  7. 14{
  8. 15 return this.each(function()
  9. 16 {
  10. 17 var conteiner = this;
  11. 18 var element = $('li:first', conteiner);
  12. 19 var date_temp = '';
  13. 20 var isAnimate = false;
  14. 21 var li_margin = parseInt($('li:first', conteiner).css('margin-top'));
  15. 22 $('.slide-bottom', conteiner).click(function()
  16. 23 {
  17. 24 var date = $('.wall-item:last').find('input').val();
  18. 25 var top = parseInt($('ul', conteiner).css('top'));
  19. 26 var last_li_offset = $('li:last', conteiner).offset().top;
  20. 27 var last_li_height = $('li:last', conteiner).innerHeight();
  21. 28 if ( ($(conteiner).innerHeight() - last_li_offset + ( last_li_height / 2 )) > 0)
  22. 29 {
  23. 30 return false;
  24. 31 }
  25. 32 if(date != date_temp)
  26. 33 {
  27. 34 $.post(wall_url, { date : date}, function(responce)
  28. 35 {
  29. 36 $('.wall-slider').append(responce);
  30. 37 });
  31. 38 }
  32. 39 date_temp = date;
  33. 40
  34. 41 if(!isAnimate)
  35. 42 {
  36. 43 isAnimate = true;
  37. 44 $('.wall-slider').animate({ top : top - (element.innerHeight() + li_margin) +'px' } , 200, '', function(){
  38. 45
  39. 46 element = element.next();
  40. 47 isAnimate = false;
  41. 48 });
  42. 49 }
  43. 50 });
  44. 51
  45. 52 $('.slide-top', conteiner).click(function()
  46. 53 {
  47. 54 var top = parseInt($('ul', conteiner).css('top'));
  48. 55 var first_li_height_half = $('li:first', conteiner).innerHeight() / 2;
  49. 56 //alert(top+' '+ first_li_height_half)
  50. 57 if( top >= 0 || (-top) < first_li_height_half) return false;
  51. 58 if(!isAnimate)
  52. 59 {
  53. 60 isAnimate = true;
  54. 61 element = element.prev();
  55. 62 $('.wall-slider').animate({ top : top + (element.innerHeight() + li_margin) +'px' } , 200, '', function(){
  56. 63 isAnimate = false;
  57. 64
  58. 65 });
  59. 66 }
  60. 67 });
  61. 68
  62. 69 });
  63. 70}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement