PageSourceSearch

https://colmundoradio.com.co/wp-content/themes/betheme/js/parallax/translate3d.js?ver=27.3.5

js colmundoradio.com.co collected 2026-10-03 21:28:53 UTC 4,049 bytes, 236 lines download raw bytes

1/**
2 * Parallax
3 *
4 * Translate3d
5 * 1.0 | Muffin Group
6 */
7
8var mfnSetup = {
9  translate: null
10};
11
12(function($) {
13
14  /* globals jQuery */
15
16  "use strict";
17
18  /**
19   * mfnSetup
20   */
21
22  // has3d
23
24  var has3d = function() {
25
26    if (!window.getComputedStyle) {
27      return false;
28    }
29
30    var el = document.createElement('div'),
31      has3d;
32
33    document.body.insertBefore(el, null);
34
35    if (el.style.transform !== undefined) {
36      el.style.transform = "translate3d(1px,1px,1px)";
37      has3d = window.getComputedStyle(el).getPropertyValue('transform');
38    }
39
40    document.body.removeChild(el);
41
42    return (has3d !== undefined && has3d !== null && has3d.length > 0 && has3d !== "none");
43  };
44
45  // __construct
46
47  var __construct = function() {
48
49    if (has3d()) {
50
51      mfnSetup.translate = function(el, x, y) {
52        el.css('transform', 'translate3d(' + x + ', ' + y + ', 0)');
53      };
54
55    } else {
56
57      mfnSetup.translate = function(el, x, y) {
58        el.css({
59          "left": x,
60          "top": y
61        });
62      };
63
64    }
65  };
66
67  __construct();
68
69})(jQuery);
70
71(function($) {
72
73  "use strict";
74
75  /**
76   * $.fn.mfnParallax
77   */
78
79  $.fn.mfnParallax = function() {
80
81    var el = $(this),
82      parent = el.parent(),
83      speed = 500,
84      element, parentPos, windowH;
85
86    // imageSize
87
88    var imageSize = function(img) {
89
90      var w, h, l, t; // width, height, left, top
91
92      var imageW = img.get(0).naturalWidth;
93      var imageH = img.get(0).naturalHeight;
94
95      var parentW = img.parent().outerWidth();
96      var parentH = img.parent().outerHeight();
97
98      var windowH = $(window).height();
99
100      // fix for small sections
101      if (windowH > parentH) {
102        parentH = windowH;
103      }
104
105      var diff = imageW / parentW;
106
107      if ((imageH / diff) < parentH) {
108
109        w = imageW / (imageH / parentH);
110        h = parentH;
111
112        if (w > imageW) {
113
114          w = imageW;
115          h = imageH;
116
117        }
118
119      } else {
120
121        w = parentW;
122        h = imageH / diff;
123
124      }
125
126      l = (parentW - w) / 2;
127      t = (parentH - h) / 2;
128
129      return [w, h, l, t];
130    };
131
132    // parallax
133
134    var parallax = function() {
135
136      var scrollTop = $(window).scrollTop(),
137        scrollDiff, ratio, translateTop;
138
139      if (parentPos !== undefined) {
140
141        if (scrollTop >= parentPos.min && scrollTop <= parentPos.max) {
142
143          scrollDiff = scrollTop - parentPos.min;
144          ratio = scrollDiff / parentPos.height;
145
146          translateTop = windowH + (ratio * speed) - scrollDiff - (speed * (windowH / parentPos.height));
147
148          mfnSetup.translate(el, element.left + "px", -Math.round(translateTop) + "px");
149        }
150
151      }
152    };
153
154    // init
155
156    var init = function() {
157
158      windowH = $(window).height();
159
160      var initElement = function() {
161
162        var size = imageSize(el);
163
164        el.removeAttr('style').css({
165          'width': size[0],
166          'height': size[1]
167        });
168
169        mfnSetup.translate(el, size[2] + "px", size[3] + "px");
170
171        return {
172          'width': size[0],
173          'height': size[1],
174          'left': size[2],
175          'top': size[3]
176        };
177      };
178
179      element = initElement();
180
181      var initParent = function() {
182
183        var min = parent.offset().top - $(window).height();
184        var max = parent.offset().top + $(parent).outerHeight();
185
186        return {
187          'min': min,
188          'max': max,
189          'height': max - min
190        };
191      };
192
193      parentPos = initParent();
194
195      // hide section background image
196      parent.css('background-image','unset');
197    };
198
199    // reload
200
201    var reload = function() {
202
203      setTimeout(function() {
204        init();
205        parallax();
206      }, 50);
207
208    };
209
210    reload();
211
212    /**
213     * $(window).scroll
214     */
215
216    $(window).on('scroll', parallax);
217
218  };
219
220  /**
221   * $(window).load
222   */
223
224  $(window).on('load resize', function(){
225
226    if ($(".mfn-parallax").length) {
227
228      $(".mfn-parallax").each(function() {
229        $(this).mfnParallax();
230      });
231
232    }
233
234  });
235
236})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.