Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. function initProductLogic() {
  2.  
  3. //Слайдер - товар
  4. var imagesSlider = new Swiper(".slider_box .gallery-top", {
  5.  
  6. nextButton: ".gallery-top .swiper-button-next",
  7. prevButton: ".gallery-top .swiper-button-prev",
  8. pagination: ".gallery-top .swiper-pagination",
  9. paginationClickable: true,
  10. loop: true,
  11. loopedSlides: 0,
  12. slidesPerView: 1,
  13. onInit : function () {
  14. $(".left_card_main .swiper-container img").each(function (index, element) {
  15.  
  16. var img = $(element),
  17. parent = img.parent();
  18.  
  19. parent
  20. .on("mouseenter", function () {
  21. parent.css({"height" : parent.outerHeight()});
  22. img.addClass("zoomed");
  23. })
  24. .mousemove(function (e) {
  25. var parentHeight = parent.outerHeight(),
  26. imgHeight = img.innerHeight(),
  27. i = (imgHeight - parentHeight) / parentHeight,
  28. y = e.clientY - parent.offset().top;
  29.  
  30. img.css({
  31. top: -(y * i)
  32. });
  33. })
  34. .on("mouseleave", function () {
  35. img.removeClass("zoomed");
  36. });
  37.  
  38. });
  39. },
  40. onSlideChangeStart: function (swiper) {
  41. $('.nav-link').removeClass('active');
  42. var currentIndex = swiper.realIndex;
  43. $('.nav-link:nth-child(' + (currentIndex + 1) + ')').addClass('active');
  44. }
  45. });
  46.  
  47. $(".nav-link").on('click', function () {
  48. imagesSlider.slideTo($(this).index() + 1);
  49. $(".nav-link").removeClass('active');
  50. $(this).addClass('active');
  51. return false
  52. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement