Parallex and vibrate background image with scroll
I need background image parallax and vibrate little bit when scrolling with mouse.
Background position is working with jQuery's `css()` function but not vibrating.
When ii firebug it result is
- <div data-speed="10" data-type="background" style="height: 1000px;
- background-position: 50% 0px; animation: 0s ease 0s normal none 1 NaNpx;"
- class="parallax-container" id="intro">
**I am using jQuery's code for this, and testing in `Mozilla`.**
- /*parallex backgound*/
- $glob('div[data-type="background"]').each( function() {
- var $bgobj = $glob(this); // assigning the object
- $glob(window).scroll( function() {
- var yPos = -($window.scrollTop() / 10);
- var coords = '50% '+ (yPos) + 'px';
- $bgobj.css({'background-position': coords}).animate({
- '-webkit-animation': 'vibrateAnim 1s ease', /* Safari 4+ */
- '-moz-animation': 'vibrateAnim 1s ease', /* Fx 5+ */
- '-o-animation': 'vibrateAnim 1s ease', /* Opera 12+ */
- 'animation': 'vibrateAnim 1s ease' /* IE 10+ */
- },500);
- });
- });
**HTML:**
- <div id="intro" class="parallax-container" style='height:1000px;' data-type="background" data-speed="10">
- <div id="mainTitleText" class="top-content">
- <img class="logo" src="images/logo.png">
- </div><!-- mainTitleText -->
- </div><!--home-->
**CSS:**
- @-moz-keyframes vibrateAnim {
- 0% { top: -10px; }
- 10% { top: 10px; }
- 20% { top: -10px; }
- 30% { top: 10px; }
- 40% { top: -10px; }
- 50% { top: 10px; }
- 60% { top: -10px; }
- 70% { top: 10px; }
- 80% { top: -10px; }
- 90% { top: 10px; }
- 100% { top: -10px; }
- }