scratch – Blame information for rev 117
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
117 | office | 1 | /*========================= |
2 | Parallax |
||
3 | ===========================*/ |
||
4 | function setParallaxTransform(el, progress) { |
||
5 | el = $(el); |
||
6 | var p, pX, pY; |
||
7 | var rtlFactor = s.rtl ? -1 : 1; |
||
8 | |||
9 | p = el.attr('data-swiper-parallax') || '0'; |
||
10 | pX = el.attr('data-swiper-parallax-x'); |
||
11 | pY = el.attr('data-swiper-parallax-y'); |
||
12 | if (pX || pY) { |
||
13 | pX = pX || '0'; |
||
14 | pY = pY || '0'; |
||
15 | } |
||
16 | else { |
||
17 | if (s.isHorizontal()) { |
||
18 | pX = p; |
||
19 | pY = '0'; |
||
20 | } |
||
21 | else { |
||
22 | pY = p; |
||
23 | pX = '0'; |
||
24 | } |
||
25 | } |
||
26 | |||
27 | if ((pX).indexOf('%') >= 0) { |
||
28 | pX = parseInt(pX, 10) * progress * rtlFactor + '%'; |
||
29 | } |
||
30 | else { |
||
31 | pX = pX * progress * rtlFactor + 'px' ; |
||
32 | } |
||
33 | if ((pY).indexOf('%') >= 0) { |
||
34 | pY = parseInt(pY, 10) * progress + '%'; |
||
35 | } |
||
36 | else { |
||
37 | pY = pY * progress + 'px' ; |
||
38 | } |
||
39 | |||
40 | el.transform('translate3d(' + pX + ', ' + pY + ',0px)'); |
||
41 | } |
||
42 | s.parallax = { |
||
43 | setTranslate: function () { |
||
44 | s.container.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function(){ |
||
45 | setParallaxTransform(this, s.progress); |
||
46 | |||
47 | }); |
||
48 | s.slides.each(function () { |
||
49 | var slide = $(this); |
||
50 | slide.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function () { |
||
51 | var progress = Math.min(Math.max(slide[0].progress, -1), 1); |
||
52 | setParallaxTransform(this, progress); |
||
53 | }); |
||
54 | }); |
||
55 | }, |
||
56 | setTransition: function (duration) { |
||
57 | if (typeof duration === 'undefined') duration = s.params.speed; |
||
58 | s.container.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function(){ |
||
59 | var el = $(this); |
||
60 | var parallaxDuration = parseInt(el.attr('data-swiper-parallax-duration'), 10) || duration; |
||
61 | if (duration === 0) parallaxDuration = 0; |
||
62 | el.transition(parallaxDuration); |
||
63 | }); |
||
64 | } |
||
65 | }; |