Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. Exception from Tracker afterFlush function: Failed to execute 'requestAnimationFrame' on 'Window': The callback provided as parameter 1 is not a function.
  2. TypeError: Failed to execute 'requestAnimationFrame' on 'Window': The callback provided as parameter 1 is not a function.
  3.  
  4. function headerParallax(x, z, y) {
  5.  
  6.  
  7.  
  8. $(window).scroll(function() {
  9. // Store scrollTop in variable
  10. var scrollPos = $(window).scrollTop();
  11. // var viewportHeight = $(window).height();
  12. //console.log(scrollPos + 'bgbottle1');
  13.  
  14. var bouncePos = ((-1 * (scrollPos ) * 1.5) + scrollPos).toFixed(2);
  15.  
  16. var bouncePos1 = ((-1 * (scrollPos - 150 ) * 1.5) + scrollPos).toFixed(2);
  17.  
  18. var bouncePos2 = ((-1 * (scrollPos - 200) * 1.25) + scrollPos).toFixed(2);
  19.  
  20.  
  21. $(".bottle1").css({ 'background-position': x + bouncePos + 'px'});
  22.  
  23. if (scrollPos > 150){
  24.  
  25. $(".bottle2").css({ 'background-position': z + bouncePos1 + 'px'});
  26.  
  27. }
  28.  
  29. if (scrollPos > 350){
  30.  
  31. $(".glass").css({ 'background-position': y + bouncePos2 + 'px'});
  32.  
  33. }
  34.  
  35. });
  36. } // end headerParallax
  37.  
  38.  
  39.  
  40. (function() {
  41. var lastTime = 0;
  42. var vendors = ['ms', 'moz', 'webkit', 'o'];
  43. for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
  44. window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
  45. window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
  46. || window[vendors[x]+'CancelRequestAnimationFrame'];
  47. }
  48.  
  49. if (!window.requestAnimationFrame)
  50. window.requestAnimationFrame = function(callback, element) {
  51. var currTime = new Date().getTime();
  52. var timeToCall = Math.max(0, 16 - (currTime - lastTime));
  53. var id = window.setTimeout(function() { callback(currTime + timeToCall); },
  54. timeToCall);
  55. lastTime = currTime + timeToCall;
  56. return id;
  57. };
  58.  
  59. if (!window.cancelAnimationFrame)
  60. window.cancelAnimationFrame = function(id) {
  61. clearTimeout(id);
  62. };
  63. }());
  64.  
  65.  
  66. //Window resizing fucnsions
  67.  
  68. $(window).resize(function(){
  69. if($(window).width() > 921 ){
  70. $(".bottle1").css({ 'background-position': "368px 0"});
  71. $(".bottle2").css({ 'background-position': "-425px 150px"});
  72. $(".glass").css({ 'background-position': "900px 132px"});
  73. window.requestAnimationFrame(headerParallax("368px ","-452px ", "900px "));
  74. }else if($(window).width() < 920){
  75. $(".bottle1").css({ 'background-position': "150px 0"});
  76. //$(".bottle2").css({ 'background-position': "-500px 0"});
  77. //$(".glass").css({ 'background-position': "600px 132px"});
  78. window.requestAnimationFrame(headerParallax("150px ","-500px ", "600px "));
  79. }
  80. }); //end windoResize
  81.  
  82. if($(window).width() > 920 ){
  83. window.requestAnimationFrame(headerParallax("368px ", "-452px ", "900px "));
  84. }else if($(window).width() < 920 ){
  85. window.requestAnimationFrame(headerParallax("150px ","-500px ", "600px "));
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement