Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Exception from Tracker afterFlush function: Failed to execute 'requestAnimationFrame' on 'Window': The callback provided as parameter 1 is not a function.
- TypeError: Failed to execute 'requestAnimationFrame' on 'Window': The callback provided as parameter 1 is not a function.
- function headerParallax(x, z, y) {
- $(window).scroll(function() {
- // Store scrollTop in variable
- var scrollPos = $(window).scrollTop();
- // var viewportHeight = $(window).height();
- //console.log(scrollPos + 'bgbottle1');
- var bouncePos = ((-1 * (scrollPos ) * 1.5) + scrollPos).toFixed(2);
- var bouncePos1 = ((-1 * (scrollPos - 150 ) * 1.5) + scrollPos).toFixed(2);
- var bouncePos2 = ((-1 * (scrollPos - 200) * 1.25) + scrollPos).toFixed(2);
- $(".bottle1").css({ 'background-position': x + bouncePos + 'px'});
- if (scrollPos > 150){
- $(".bottle2").css({ 'background-position': z + bouncePos1 + 'px'});
- }
- if (scrollPos > 350){
- $(".glass").css({ 'background-position': y + bouncePos2 + 'px'});
- }
- });
- } // end headerParallax
- (function() {
- var lastTime = 0;
- var vendors = ['ms', 'moz', 'webkit', 'o'];
- for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
- window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
- window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
- || window[vendors[x]+'CancelRequestAnimationFrame'];
- }
- if (!window.requestAnimationFrame)
- window.requestAnimationFrame = function(callback, element) {
- var currTime = new Date().getTime();
- var timeToCall = Math.max(0, 16 - (currTime - lastTime));
- var id = window.setTimeout(function() { callback(currTime + timeToCall); },
- timeToCall);
- lastTime = currTime + timeToCall;
- return id;
- };
- if (!window.cancelAnimationFrame)
- window.cancelAnimationFrame = function(id) {
- clearTimeout(id);
- };
- }());
- //Window resizing fucnsions
- $(window).resize(function(){
- if($(window).width() > 921 ){
- $(".bottle1").css({ 'background-position': "368px 0"});
- $(".bottle2").css({ 'background-position': "-425px 150px"});
- $(".glass").css({ 'background-position': "900px 132px"});
- window.requestAnimationFrame(headerParallax("368px ","-452px ", "900px "));
- }else if($(window).width() < 920){
- $(".bottle1").css({ 'background-position': "150px 0"});
- //$(".bottle2").css({ 'background-position': "-500px 0"});
- //$(".glass").css({ 'background-position': "600px 132px"});
- window.requestAnimationFrame(headerParallax("150px ","-500px ", "600px "));
- }
- }); //end windoResize
- if($(window).width() > 920 ){
- window.requestAnimationFrame(headerParallax("368px ", "-452px ", "900px "));
- }else if($(window).width() < 920 ){
- window.requestAnimationFrame(headerParallax("150px ","-500px ", "600px "));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement