Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. var swiper = new Swiper('.swiper-container', {
  2. direction: 'vertical',
  3. });
  4. var startScroll, touchStart, touchCurrent;
  5. swiper.slides.on('touchstart', function (e) {
  6. startScroll = this.scrollTop;
  7. touchStart = e.targetTouches[0].pageY;
  8. }, true);
  9. swiper.slides.on('touchmove', function (e) {
  10. touchCurrent = e.targetTouches[0].pageY;
  11. var touchesDiff = touchCurrent - touchStart;
  12. var slide = this;
  13. var onlyScrolling =
  14. ( slide.scrollHeight > slide.offsetHeight ) && //allow only when slide is scrollable
  15. (
  16. ( touchesDiff < 0 && startScroll === 0 ) || //start from top edge to scroll bottom
  17. ( touchesDiff > 0 && startScroll === ( slide.scrollHeight - slide.offsetHeight ) ) || //start from bottom edge to scroll top
  18. ( startScroll > 0 && startScroll < ( slide.scrollHeight - slide.offsetHeight ) ) //start from the middle
  19. );
  20. if (onlyScrolling) {
  21. e.stopPropagation();
  22. }
  23. }, true);
  24.  
  25. <style>
  26. .swiper-slide {
  27. overflow-y: auto;
  28. }
  29. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement