mediengestalter.info
FAQ :: Mitgliederliste :: MGi Team

Willkommen auf dem Portal für Mediengestalter

Aktuelles Datum und Uhrzeit: Di 23.04.2024 21:31 Benutzername: Passwort: Auto-Login

Thema: Scrollen- Fly - In Effekt jQuery? vom 28.12.2012


Neues Thema eröffnen   Neue Antwort erstellen MGi Foren-Übersicht -> Programmierung -> Scrollen- Fly - In Effekt jQuery?
Autor Nachricht
JoeMelRamos
Threadersteller

Dabei seit: 11.02.2012
Ort: -
Alter: -
Geschlecht: Männlich
Verfasst Fr 28.12.2012 22:11
Titel

Scrollen- Fly - In Effekt jQuery?

Antworten mit Zitat Zum Seitenanfang

HILFE !
wollt nen Scroll Effekt mit jQuery erstellen, sitze wieder mal stunden dran trotz i-net, nichts gefunden.


Kann mir vielleicht einer sagen wie ich das einbinde? Diesen Effekt? Was brauche ich? Was mache ich falsch?

Wäre über jede Antwort dankbar. * Ich geb auf... * * Ich geb auf... * * Ich geb auf... * * Ich geb auf... *



Codes:

HTML

Code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sükrü Kulaber</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="../../js/jquery-1.8.2.min.js"></script>
<script src="../../js/jquery.scrollTo-1.4.3.1.min.js"></script>
<script type="text/javascript" src="scripts/jquery.parallax-1.1.js"></script>
<script src="../../js/jquery.easing.1.3.js"></script>
<script src="../../js/jquery.scrollorama.js"></script>
<script src="../../js/jquery.scrolldeck.js"></script>
<script src="../../js/jquery.lettering-0.6.1.min.js"></script>
<script src="../../js/jquery.scrollorama.js"></script>
<script type="text/javascript">
$(document).ready(function(){
   //$('#nav').localScroll(800);
   
   RepositionNav();
   
   $(window).resize(function(){
      RepositionNav();
   });   
   
   //.parallax(xPosition, adjuster, inertia, outerHeight) options:
   //xPosition - Horizontal position of the element
   //adjuster - y position to start from
   //inertia - speed to move relative to vertical scroll. Example: 0.1 is one tenth the speed of scrolling, 2 is twice the speed of scrolling
   //outerHeight (true/false) - Whether or not jQuery should use it's outerHeight option to determine when a section is in the viewport
   $('#intro').parallax("50%", 0, 0.1, true);
   $('#second').parallax("50%", 0, 0.1, true);
   $('.bg').parallax("50%", 2500, 0.4, true);
   $('#third').parallax("50%", 2750, 0.3, true);
   
   var deck = new $.scrolldeck({
      slides: '.slide',
      buttons: '#nav li a',
      easing: 'easeInOutExpo'
   });

})
</script>
</head>

<body>
   <ul id="nav">
      <li><a href="#intro" title="Next Section"></a></li>
       <li><a href="#second" title="Next Section"></a></li>
       <li><a href="#third" title="Next Section"></a></li>
       <li><a href="#fifth" title="Next Section"></a></li>
   </ul>
   
   <div id="intro" class="slide">
      <div class="story">
          <div class="float-left">
         <h2>HERZLICH | WILLKOMMEN</h2>
           <p>NEUGIER GEWECKT?<br>Entspannen Sie sich und genießen Sie.</p>
           </div>
       </div> <!--.story-->
   </div> <!--#intro-->
   
   <div id="second" class="slide">
      <div class="story"><div class="bg"></div>
          <div class="float-right">
               <h2>Überschrift 2</h2>
               <p>Hier können Sie sich ein erstes Bild machen, was meine Refenze betrifft.</p>
               <p>Von A wie Analyse bis Z wie Zielgruppe.</p>
           </div>
       </div> <!--.story-->
      
   </div> <!--#second-->
   
   <div id="third" class="slide">
   
    <div class="scrollblock" id="examples-transition">
      <h2>Transitions</h2>
      <h3 id="fade-in">Deine Mudderrrrr</h3>
      <h3 id="fly-in">DEINE Ommmmmaaa!</h3>
      
      
   </div>
      <div class="story">
     
          <div class="float-left">
              <h2>Damit Ihre potentielle Zielgruppen sich angesprochen fühlen...</h2>
     
               <p>Optimieren und platzieren wir Ihre Werbung an die bestmögliche Stelle.</p>
           </div>
                     
       </div> <!--.story-->
   </div> <!--#third-->
   
   <div id="fifth" class="slide">
      <div class="story">
            <h2>Kontaktieren Sie.</h2>
           <p>Und wir finden den gemeinsamen Nenner.</p>
         
         <p>Egal ob Telefon, E-Mail, Post oder Live.</p>
   
   
       </div> <!--.story-->
   </div> <!--#fifth-->

   <script type="text/javascript">

     var _gaq = _gaq || [];
     _gaq.push(['_setAccount', 'UA-2821890-9']);
     _gaq.push(['_trackPageview']);

     (function() {
       var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
       ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
       var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
     })();

   </script>
</body>
</html>


CSS

Code:
@charset "utf-8";
/* CSS Document */

body{
   margin: 0;
   min-width: 980px;
   padding: 0;
}

p{
   margin: 0 0 20px 0;   
}

p, ul{
   font-family:"Proxima Nova Light", 'Helvetica Neue', Arial, Helvetica, sans-serif;
   font-size-adjust:0.488;
   font-weight:200;
   font-style:normal;
}

img{
   border: 0;
}

h1{
   font-family:"Museo 900", Verdana, serif;
   font-size-adjust:0.40;
   font-weight: bolder;
   font-style:normal;
}

h2{
   font-family:"Beau Sans Pro Book", Verdana, sans-serif;
   font-size-adjust:0.531;
   font-weight:500;
   font-style:normal;
}

#header h1{
   color: #48941A;
}

.float-left{
   float: left;   
   margin: 0 0 0 20px;
   font-weight:bolder;
}

.float-right{
   float: right;
   margin: 0 20px 0 0;
}

.center{
   font-size: 2.5em;
   padding: 80px 0 0 0;
   text-align: center;
}

#nav{
   list-style: none;
   position: fixed;
   right: 30px;
   z-index: 999;
}

#nav li{
   margin: 0 0 15px 0;   
}

#header, #intro, #second{
   width: 100%;
}

#intro{
   background:url(images/firstBG.jpg) 50% -75px no-repeat fixed;
   color: white;
   height: 800px;
   margin: 0 auto;
   padding: 160px 0 0 0;
}


#second{
   background: url(images/secondBG.jpg) 50% 0 no-repeat fixed;
   color: black;
   height: 1200px;
   margin: 0 auto;
   overflow: hidden;
   padding: 0;
}

#second .bg{
   background: url(images/trainers.png) 50% 0 no-repeat fixed;
   height: 1300px;
   margin: 0 auto;
   padding: 0;
   position: absolute;
   width:1000px;
   z-index: 200;
}

#third{
   background-color: #999;
   color: white;
   height: 750px;
   padding: 100px 0 0 0;   
}

#fifth{
   background: url(images/forthBG.jpg) 50% 0 no-repeat fixed;
   height: 400px;
   color:white;
   margin: 0 auto;
   padding: 40px 0 0 0;
}

.story{
   margin: 0 auto;
   min-width: 980px;
   overflow: auto;
   width: 980px;
}

.story .float-left, .story .float-right{
   padding: 100px 0 0 0;
   position: relative;
   width: 350px;   
}

.slide {
   width: 100%;
}

#nav li a {
   display: block;
   width: 15px;
   height: 15px;
   border-radius: 15px;
   background-color: white;
   border: solid 2px white;
   color:white;
}

#nav li a.current {
   background-color: black;
}

#examples-transition {
   overflow: hidden;
}



jQuery-Parallax


Code:

//function that places the navigation in the center of the window
function RepositionNav(){
   var windowHeight = $(window).height(); //get the height of the window
   var navHeight = $('#nav').height() / 2;
   var windowCenter = (windowHeight / 2);
   var newtop = windowCenter - navHeight;
   $('#nav').css({"top": newtop}); //set the new top position of the navigation list
}


(function( $ ){
   $.fn.parallax = function(xpos, adjuster, inertia, outerHeight) {
         
function inView(pos, element){
   
   element.each(function(){ //for each selector, determine whether it's inview and run the move() function
      
      var element = $(this);
      var top = element.offset().top;
      
      if(outerHeight == true){
         var height = element.outerHeight(true);
      }else{
         var height = element.height();
      }
      
      //above & in view
      if(top + height >= pos && top + height - windowHeight < pos){
         move(pos, height);
      }
            
      //full view
      if(top <= pos && (top + height) >= pos && (top - windowHeight) < pos && top + height - windowHeight > pos){
         move(pos, height);
      }
      
      //below & in view
      if(top + height > pos && top - windowHeight < pos && top > pos){
         move(pos, height);
      }
   });
}      
      
      var $window = $(window);
      var windowHeight = $(window).height();
      var pos = $window.scrollTop(); //position of the scrollbar
      var $this = $(this);
      
      //setup defaults if arguments aren't specified
      if(xpos == null){xpos = "50%"}
      if(adjuster == null){adjuster = 0}
      if(inertia == null){inertia = 0.1}
      if(outerHeight == null){outerHeight = true}
      
      height = $this.height();
      $this.css({'backgroundPosition': newPos(xpos, outerHeight, adjuster, inertia)});
      
      function newPos(xpos, windowHeight, pos, adjuster, inertia){
         return xpos + " " + Math.round((-((windowHeight + pos) - adjuster) * inertia)) + "px";
      }
      
      //function to be called whenever the window is scrolled or resized
      function move(pos, height){
            $this.css({'backgroundPosition': newPos(xpos, height, pos, adjuster, inertia)});
      }
      
      $window.bind('scroll', function(){ //when the user is scrolling...
         var pos = $window.scrollTop(); //position of the scrollbar
         inView(pos, $this);
         
         $('#pixels').html(pos);
      })
   }
   

})( jQuery );



JQuery easing

Code:

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
   def: 'easeOutQuad',
   swing: function (x, t, b, c, d) {
      //alert(jQuery.easing.default);
      return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
   },
   easeInQuad: function (x, t, b, c, d) {
      return c*(t/=d)*t + b;
   },
   easeOutQuad: function (x, t, b, c, d) {
      return -c *(t/=d)*(t-2) + b;
   },
   easeInOutQuad: function (x, t, b, c, d) {
      if ((t/=d/2) < 1) return c/2*t*t + b;
      return -c/2 * ((--t)*(t-2) - 1) + b;
   },
   easeInCubic: function (x, t, b, c, d) {
      return c*(t/=d)*t*t + b;
   },
   easeOutCubic: function (x, t, b, c, d) {
      return c*((t=t/d-1)*t*t + 1) + b;
   },
   easeInOutCubic: function (x, t, b, c, d) {
      if ((t/=d/2) < 1) return c/2*t*t*t + b;
      return c/2*((t-=2)*t*t + 2) + b;
   },
   easeInQuart: function (x, t, b, c, d) {
      return c*(t/=d)*t*t*t + b;
   },
   easeOutQuart: function (x, t, b, c, d) {
      return -c * ((t=t/d-1)*t*t*t - 1) + b;
   },
   easeInOutQuart: function (x, t, b, c, d) {
      if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
      return -c/2 * ((t-=2)*t*t*t - 2) + b;
   },
   easeInQuint: function (x, t, b, c, d) {
      return c*(t/=d)*t*t*t*t + b;
   },
   easeOutQuint: function (x, t, b, c, d) {
      return c*((t=t/d-1)*t*t*t*t + 1) + b;
   },
   easeInOutQuint: function (x, t, b, c, d) {
      if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
      return c/2*((t-=2)*t*t*t*t + 2) + b;
   },
   easeInSine: function (x, t, b, c, d) {
      return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
   },
   easeOutSine: function (x, t, b, c, d) {
      return c * Math.sin(t/d * (Math.PI/2)) + b;
   },
   easeInOutSine: function (x, t, b, c, d) {
      return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
   },
   easeInExpo: function (x, t, b, c, d) {
      return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
   },
   easeOutExpo: function (x, t, b, c, d) {
      return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
   },
   easeInOutExpo: function (x, t, b, c, d) {
      if (t==0) return b;
      if (t==d) return b+c;
      if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
      return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
   },
   easeInCirc: function (x, t, b, c, d) {
      return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
   },
   easeOutCirc: function (x, t, b, c, d) {
      return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
   },
   easeInOutCirc: function (x, t, b, c, d) {
      if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
      return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
   },
   easeInElastic: function (x, t, b, c, d) {
      var s=1.70158;var p=0;var a=c;
      if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
      if (a < Math.abs(c)) { a=c; var s=p/4; }
      else var s = p/(2*Math.PI) * Math.asin (c/a);
      return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
   },
   easeOutElastic: function (x, t, b, c, d) {
      var s=1.70158;var p=0;var a=c;
      if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
      if (a < Math.abs(c)) { a=c; var s=p/4; }
      else var s = p/(2*Math.PI) * Math.asin (c/a);
      return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
   },
   easeInOutElastic: function (x, t, b, c, d) {
      var s=1.70158;var p=0;var a=c;
      if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
      if (a < Math.abs(c)) { a=c; var s=p/4; }
      else var s = p/(2*Math.PI) * Math.asin (c/a);
      if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
      return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
   },
   easeInBack: function (x, t, b, c, d, s) {
      if (s == undefined) s = 1.70158;
      return c*(t/=d)*t*((s+1)*t - s) + b;
   },
   easeOutBack: function (x, t, b, c, d, s) {
      if (s == undefined) s = 1.70158;
      return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
   },
   easeInOutBack: function (x, t, b, c, d, s) {
      if (s == undefined) s = 1.70158;
      if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
      return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
   },
   easeInBounce: function (x, t, b, c, d) {
      return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
   },
   easeOutBounce: function (x, t, b, c, d) {
      if ((t/=d) < (1/2.75)) {
         return c*(7.5625*t*t) + b;
      } else if (t < (2/2.75)) {
         return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
      } else if (t < (2.5/2.75)) {
         return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
      } else {
         return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
      }
   },
   easeInOutBounce: function (x, t, b, c, d) {
      if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
      return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
   }
});

/



JQuery Scrollorama

Code:

(function($) {
    $.scrollorama = function(options) {
      var scrollorama = this,
         blocks = [],
         browserPrefix = '',
         onBlockChange = function() {},
         latestKnownScrollY = 0,
            ticking = false,
            requestAnimFrame =   window.requestAnimationFrame ||
                        window.webkitRequestAnimationFrame ||
                        window.mozRequestAnimationFrame    ||
                        window.oRequestAnimationFrame      ||
                        window.msRequestAnimationFrame     ||
                        function( callback ){
                           window.setTimeout(callback, 1000 / 60);
                        },
         defaults = {offset:0, enablePin: true};
      
      scrollorama.settings = $.extend({}, defaults, options);
      scrollorama.blockIndex = 0;
      
      if (options.blocks === undefined) { alert('ERROR: Must assign blocks class selector to scrollorama plugin'); }
      
      // PRIVATE FUNCTIONS
      function init() {
         var i, block, didScroll = false;
         if (typeof scrollorama.settings.blocks === 'string') { scrollorama.settings.blocks = $(scrollorama.settings.blocks); }
         
         // set browser prefix
         if ($.browser.mozilla) { browserPrefix = '-moz-'; }
         if ($.browser.webkit) { browserPrefix = '-webkit-'; }
         if ($.browser.opera) { browserPrefix = '-o-'; }
         if ($.browser.msie) { browserPrefix = '-ms-'; }
         
         // create blocks array to contain animation props
         $('body').css('position','relative');
         for (i=0; i<scrollorama.settings.blocks.length; i++) {
            block = scrollorama.settings.blocks.eq(i);
            blocks.push({
               block: block,
               top: block.offset().top - parseInt(block.css('margin-top'), 10),
               pin: 0,
               animations:[]
            });
         }
         
         // convert block elements to absolute position
         if (scrollorama.settings.enablePin.toString() === 'true') {
            for (i=0; i<blocks.length; i++) {
               blocks[i].block
                  .css('position', 'absolute')
                  .css('top', blocks[i].top);
            }
         }
         
         $('body').prepend('<div id="scroll-wrap"></div>');
         
         latestKnownScrollY = 0;
            ticking = false;
            $(window).scroll( onScroll );
      }

      function onScroll() {
            latestKnownScrollY = window.scrollY;
            requestTick();
        }
       
        function requestTick() {
            if(!ticking) {
                requestAnimFrame(function(){
                    onScrollorama();
                    update();
                });
            }
            ticking = true;
        }
       
        function update() {
            // reset the tick so we can
            // capture the next onScroll
            ticking = false;
        }
      
      function onScrollorama() {
         var scrollTop = $(window).scrollTop(),
         currBlockIndex = getCurrBlockIndex(scrollTop),
         i, j, anim, startAnimPos, endAnimPos, animPercent, animVal;
         
         // update all animations
         for (i=0; i<blocks.length; i++) {
            
            // go through the animations for each block
            if (blocks[i].animations.length) {
               for (j=0; j<blocks[i].animations.length; j++) {
                  anim = blocks[i].animations[j];
                  
                  // if above current block, settings should be at start value
                  if (i > currBlockIndex) {
                     if (currBlockIndex !== i-1 && anim.baseline !== 'bottom') {
                        setProperty(anim.element, anim.property, anim.startVal);
                     }
                     if (blocks[i].pin) {
                        blocks[i].block
                        .css('position', 'absolute')
                        .css('top', blocks[i].top);
                     }
                  }
                  
                  // if below current block, settings should be at end value
                  // unless on an element that gets animated when it hits the bottom of the viewport
                  else if (i < currBlockIndex) {
                     setProperty(anim.element, anim.property, anim.endVal);
                     if (blocks[i].pin) {
                        blocks[i].block
                                    .css('position', 'absolute')
                                    .css('top', (blocks[i].top + blocks[i].pin));
                     }
                  }
                  
                  // otherwise, set values per scroll position
                  if (i === currBlockIndex || (currBlockIndex === i-1 && anim.baseline === 'bottom')) {
                     // if block gets pinned, set position fixed
                     if (blocks[i].pin && currBlockIndex === i) {
                        blocks[i].block
                                    .css('position', 'fixed')
                                    .css('top', 0);
                     }
                     
                     // set start and end animation positions
                     startAnimPos = blocks[i].top + anim.delay;
                     if (anim.baseline === 'bottom') { startAnimPos -= $(window).height(); }
                     endAnimPos = startAnimPos + anim.duration;
                     
                     // if scroll is before start of animation, set to start value
                     if (scrollTop < startAnimPos) {
                        setProperty(anim.element, anim.property, anim.startVal);
                     }
                     
                     // if scroll is after end of animation, set to end value
                     else if (scrollTop > endAnimPos) {
                        setProperty(anim.element, anim.property, anim.endVal);
                        if (blocks[i].pin) {
                           blocks[i].block
                                        .css('position', 'absolute')
                                        .css('top', (blocks[i].top + blocks[i].pin));
                        }
                     }
                     
                     // otherwise, set value based on scroll
                     else {
                        // calculate percent to animate
                        animPercent = (scrollTop - startAnimPos) / anim.duration;
                        // account for easing if there is any
                        if ( anim.easing && $.isFunction( $.easing[anim.easing] ) ) {
                           animPercent = $.easing[anim.easing]( animPercent, animPercent*1000, 0, 1, 1000 );
                        }
                        // then multiply the percent by the value range and calculate the new value
                        animVal = anim.startVal + (animPercent * (anim.endVal - anim.startVal));
                        setProperty(anim.element, anim.property, animVal);
                     }
                  }
               }
            }
         }
         
         // update blockIndex and trigger event if changed
         if (scrollorama.blockIndex !== currBlockIndex) {
            scrollorama.blockIndex = currBlockIndex;
            onBlockChange();
         }
      }
      
      function getCurrBlockIndex(scrollTop) {
         var currBlockIndex = 0, i;
         for (i=0; i<blocks.length; i++) {
            // check if block is in view
            if (blocks[i].top <= scrollTop - scrollorama.settings.offset) { currBlockIndex = i; }
         }
         return currBlockIndex;
      }
      
      function setProperty(target, prop, val) {
         var scaleCSS, currentPosition;
         if (prop === 'rotate' || prop === 'zoom' || prop === 'scale') {
            if (prop === 'rotate') {
               target.css(browserPrefix+'transform', 'rotate('+val+'deg)');
            } else if (prop === 'zoom' || prop === 'scale') {
               scaleCSS = 'scale('+val+')';
               if (browserPrefix !== '-ms-') {
                  target.css(browserPrefix+'transform', scaleCSS);
               } else {
                  target.css('zoom', scaleCSS);
               }
            }
         }
         else if(prop === 'background-position-x' || prop === 'background-position-y' ) {
            currentPosition = target.css('background-position').split(' ');
            if(prop === 'background-position-x') {
               target.css('background-position',val+'px '+currentPosition[1]);
            }
            if(prop === 'background-position-y') {
               target.css('background-position', currentPosition[0]+' '+val+'px');
            }
         }
         else if(prop === 'text-shadow' ) {
            target.css(prop,'0px 0px '+val+'px #ffffff');
         } else {
            target.css(prop, val);
         }
      }
      
      
      // PUBLIC FUNCTIONS
      scrollorama.animate = function(target) {
         var targetIndex,
            targetBlock,
            anim,
            offset,
            i, j;
         /*
            target      = animation target
            arguments   = array of animation parameters
            anim      = object that contains all animation params (created from arguments)
            offset      = positioning helper for pinning
            
            animation parameters:
            delay      = amount of scrolling (in pixels) before animation starts
            duration   = amount of scrolling (in pixels) over which the animation occurs
            property   = css property being animated
            start      = start value of the property
            end         = end value of the property
            pin         = pin block during animation duration (applies to all animations within block)
            baseline   = top (default, when block reaches top of viewport) or bottom (when block first comies into view)
            easing      = just like jquery's easing functions
         */
         
         // if string, convert to DOM object
         if (typeof target === 'string') { target = $(target); }
         
         // find block of target
         for (i=0; i<blocks.length; i++) {
            if (blocks[i].block.has(target).length) {
               targetBlock = blocks[i];
               targetIndex = i;
            }
         }
         
         // add each animation to the blocks animations array from function arguments
         for (i=1; i<arguments.length; i++) {
            
            anim = arguments[i];
            
            // for top/left/right/bottom, set relative positioning if static
            if (anim.property === 'top' || anim.property === 'left' || anim.property === 'bottom' || anim.property === 'right' ) {
               if (target.css('position') === 'static') { target.css('position','relative'); }
               // set anim.start, anim.end defaults
               cssValue = parseInt(target.css(anim.property),10);
               if (anim.start === undefined) {
                  anim.start = isNaN(cssValue) ? 0 : cssValue;
               } else if (anim.end === undefined) {
                  anim.end = isNaN(cssValue) ? 0 : cssValue;
               }
            }
            
            // set anim.start/anim.end defaults for rotate, zoom/scale, letter-spacing
            if (anim.property === 'rotate') {
               if (anim.start === undefined) { anim.start = 0; }
               if (anim.end === undefined) { anim.end = 0; }
            } else if (anim.property === 'zoom' || anim.property === 'scale' ) {
               if (anim.start === undefined) { anim.start = 1; }
               if (anim.end === undefined) { anim.end = 1; }
            } else if (anim.property === 'letter-spacing' && target.css(anim.property)) {
               if (anim.start === undefined) { anim.start = 1; }
               if (anim.end === undefined) { anim.end = 1; }
            }
            
            if (anim.baseline === undefined) {
               if (anim.pin || targetBlock.pin || targetIndex === 0) {
                  anim.baseline = 'top';
               } else {
                  anim.baseline = 'bottom';
               }
            }
            
            if (anim.delay === undefined) { anim.delay = 0; }
            
            targetBlock.animations.push({
               element: target,
               delay: anim.delay,
               duration: anim.duration,
               property: anim.property,
               startVal: anim.start !== undefined ? anim.start : parseInt(target.css(anim.property),10),   // if undefined, use current css value
               endVal: anim.end !== undefined ? anim.end : parseInt(target.css(anim.property),10),         // if undefined, use current css value
               baseline: anim.baseline !== undefined ? anim.baseline : 'bottom',
               easing: anim.easing
            });
            
            if (anim.pin) {
               if (targetBlock.pin < anim.duration + anim.delay) {
                  offset = anim.duration + anim.delay - targetBlock.pin;
                  targetBlock.pin += offset;
                  
                  // adjust positions of blocks below target block
                  for (j=targetIndex+1; j<blocks.length; j++) {
                     blocks[j].top += offset;
                     blocks[j].block.css('top', blocks[j].top);
                  }
               }
            }
         }
         
         onScrollorama();
      };
      
      // function for passing blockChange event callback
      scrollorama.onBlockChange = function(f) {
         onBlockChange = f;
      };
      
      // function for getting an array of scrollpoints
      // (top of each animation block and animation element scroll start point)
      scrollorama.getScrollpoints = function() {
         var scrollpoints = [],i,j,anim;
         for (i=0; i<blocks.length; i++) {
            scrollpoints.push(blocks[i].top);
            // go through the animations for each block
            if (blocks[i].animations.length && blocks[i].pin > 0) {
               for (j=0; j<blocks[i].animations.length; j++) {
                  anim = blocks[i].animations[j];
                  scrollpoints.push(blocks[i].top + anim.delay + anim.duration);
               }
            }
         }
         // make sure scrollpoints are in numeric order
         scrollpoints.sort(function(a,b) {return a - b;});
         return scrollpoints;
      };
      
      
      // INIT
      init();
      
      return scrollorama;
    };

   //
   //      Easing functions from jQuery UI
   //
   $.extend($.easing, {
      def: 'easeOutQuad',
      swing: function (x, t, b, c, d) {
         //alert($.easing.default);
         return $.easing[$.easing.def](x, t, b, c, d);
      },
      easeInQuad: function (x, t, b, c, d) {
         return c*(t/=d)*t + b;
      },
      easeOutQuad: function (x, t, b, c, d) {
         return -c *(t/=d)*(t-2) + b;
      },
      easeInOutQuad: function (x, t, b, c, d) {
         if ((t/=d/2) < 1) { return c/2*t*t + b; }
         return -c/2 * ((--t)*(t-2) - 1) + b;
      },
      easeInCubic: function (x, t, b, c, d) {
         return c*(t/=d)*t*t + b;
      },
      easeOutCubic: function (x, t, b, c, d) {
         return c*((t=t/d-1)*t*t + 1) + b;
      },
      easeInOutCubic: function (x, t, b, c, d) {
         if ((t/=d/2) < 1) { return c/2*t*t*t + b; }
         return c/2*((t-=2)*t*t + 2) + b;
      },
      easeInQuart: function (x, t, b, c, d) {
         return c*(t/=d)*t*t*t + b;
      },
      easeOutQuart: function (x, t, b, c, d) {
         return -c * ((t=t/d-1)*t*t*t - 1) + b;
      },
      easeInOutQuart: function (x, t, b, c, d) {
         if ((t/=d/2) < 1) { return c/2*t*t*t*t + b; }
         return -c/2 * ((t-=2)*t*t*t - 2) + b;
      },
      easeInQuint: function (x, t, b, c, d) {
         return c*(t/=d)*t*t*t*t + b;
      },
      easeOutQuint: function (x, t, b, c, d) {
         return c*((t=t/d-1)*t*t*t*t + 1) + b;
      },
      easeInOutQuint: function (x, t, b, c, d) {
         if ((t/=d/2) < 1) { return c/2*t*t*t*t*t + b; }
         return c/2*((t-=2)*t*t*t*t + 2) + b;
      },
      easeInSine: function (x, t, b, c, d) {
         return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
      },
      easeOutSine: function (x, t, b, c, d) {
         return c * Math.sin(t/d * (Math.PI/2)) + b;
      },
      easeInOutSine: function (x, t, b, c, d) {
         return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
      },
      easeInExpo: function (x, t, b, c, d) {
         return (t===0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
      },
      easeOutExpo: function (x, t, b, c, d) {
         return (t===d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
      },
      easeInOutExpo: function (x, t, b, c, d) {
         if (t===0) { return b; }
         if (t===d) { return b+c; }
         if ((t/=d/2) < 1) { return c/2 * Math.pow(2, 10 * (t - 1)) + b; }
         return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
      },
      easeInCirc: function (x, t, b, c, d) {
         return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
      },
      easeOutCirc: function (x, t, b, c, d) {
         return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
      },
      easeInOutCirc: function (x, t, b, c, d) {
         if ((t/=d/2) < 1) { return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; }
         return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
      },
      easeInElastic: function (x, t, b, c, d) {
         var s=1.70158,p=0,a=c;
         if (t===0) { return b; }
         if ((t/=d)===1) { return b+c; }
         if (!p) { p=d*0.3; }
         if (a < Math.abs(c)) { a=c; s=p/4; }
         else{ s = p/(2*Math.PI) * Math.asin (c/a); }
         return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
      },
      easeOutElastic: function (x, t, b, c, d) {
         var s=1.70158,p=0,a=c;
         if (t===0) { return b; }
         if ((t/=d)===1) { return b+c; }
         if (!p) { p=d*0.3; }
         if (a < Math.abs(c)) { a=c; s=p/4; }
         else { s = p/(2*Math.PI) * Math.asin (c/a); }
         return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
      },
      easeInOutElastic: function (x, t, b, c, d) {
         var s=1.70158,p=0,a=c;
         if (t===0) { return b; }
         if ((t/=d/2)===2) { return b+c; }
         if (!p) { p=d*(0.3*1.5); }
         if (a < Math.abs(c)) { a=c; s=p/4; }
         else { s = p/(2*Math.PI) * Math.asin (c/a); }
         if (t < 1) { return -0.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; }
         return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*0.5 + c + b;
      },
      easeInBack: function (x, t, b, c, d, s) {
         if (s === undefined) { s = 1.70158; }
         return c*(t/=d)*t*((s+1)*t - s) + b;
      },
      easeOutBack: function (x, t, b, c, d, s) {
         if (s === undefined) { s = 1.70158; }
         return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
      },
      easeInOutBack: function (x, t, b, c, d, s) {
         if (s === undefined) { s = 1.70158; }
         if ((t/=d/2) < 1) { return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; }
         return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
      },
      easeInBounce: function (x, t, b, c, d) {
         return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
      },
      easeOutBounce: function (x, t, b, c, d) {
         if ((t/=d) < (1/2.75)) {
            return c*(7.5625*t*t) + b;
         } else if (t < (2/2.75)) {
            return c*(7.5625*(t-=(1.5/2.75))*t + 0.75) + b;
         } else if (t < (2.5/2.75)) {
            return c*(7.5625*(t-=(2.25/2.75))*t + 0.9375) + b;
         } else {
            return c*(7.5625*(t-=(2.625/2.75))*t + 0.984375) + b;
         }
      },
      easeInOutBounce: function (x, t, b, c, d) {
         if (t < d/2) { return $.easing.easeInBounce (x, t*2, 0, c, d) * 0.5 + b; }
         return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * 0.5 + c*0.5 + b;
      }
   });
     
})(jQuery);



JQuery Scrolldeck

Code:


(function($) {
    $.scrolldeck = function(options) {
      
      
      // VARS
      
      var currIndex = 0,
         buttons,
         slides,
         scrollpoints = [],
         sections = [],
         windowHeight = $(window).height(),
         i;
      
      var defaults = {
         buttons: '.nav-button',
         slides: '.slide',
         duration: 600,
         easing: 'easeInOutExpo',
         offset: 0
      };
      
      
      // INIT
      
      var scrolldeck = this;
      scrolldeck.settings = {};
         
      var init = function() {
         
         scrolldeck.settings = $.extend({}, defaults, options);
         
         buttons = $(scrolldeck.settings.buttons);
         slides = $(scrolldeck.settings.slides);
         scrolldeck.controller = $.scrollorama({blocks:slides, offset:scrolldeck.settings.offset});
         
         // add animations with scrollorama
         var anim;
         // ANIMATE INS
         for (i=0; i<$('.animate-in').length; i++) {
            anim = $('.animate-in').eq(i);
            switch (anim.attr('data-animation')) {
               case 'fly-in-left':
                  anim
                     .parent().css('overflow','hidden');
                  scrolldeck.controller.animate(anim, { delay: windowHeight/2, duration: windowHeight/2, property:'left', start:-1200 });
                  break;
               case 'fly-in-right':
                  anim
                     .parent().css('overflow','hidden');
                  scrolldeck.controller.animate(anim, { delay: windowHeight/2, duration: windowHeight/2, property:'right', start:-1200 });
                  break;
               case 'space-in':
                  scrolldeck.controller.animate(anim, { delay: windowHeight*0.8, duration: windowHeight*0.2, property:'letter-spacing', start:40 });
                  scrolldeck.controller.animate(anim, { delay: windowHeight*0.8, duration: windowHeight*0.2, property:'opacity', start:0 });
                  break;
               case 'fade-in':
                  scrolldeck.controller.animate(anim, { delay: windowHeight/2, duration: windowHeight/2, property:'opacity', start:0 });
                  break;
               default:
                  scrolldeck.controller.animate(anim, { delay: windowHeight/2, duration: windowHeight/2, property:'opacity', start:0 });
            }
         }
         
         // ANIMATE BUILDS
         for (i=0; i<$('.animate-build').length; i++) {
            anim = $('.animate-build').eq(i);
            switch (anim.attr('data-animation')) {
               case 'fly-in-left':
                  anim.parent().css('overflow','hidden');
                  scrolldeck.controller.animate(anim, { delay: (anim.attr('data-build')-1)*400, duration: 400, property:'left', start:-1200, pin:true });
                  break;
               case 'fly-in-right':
                  anim.parent().css('overflow','hidden');
                  scrolldeck.controller.animate(anim, { delay: (anim.attr('data-build')-1)*400, duration: 400, property:'right', start:-1200, pin:true });
                  break;
               case 'space-in':
                  scrolldeck.controller.animate(anim, { delay: (anim.attr('data-build')-1)*400, duration: 400, property:'letter-spacing', start:40, pin:true });
                  scrolldeck.controller.animate(anim, { delay: (anim.attr('data-build')-1)*400, duration: 400, property:'opacity', start:0, pin:true });
                  break;
               case 'fade-in':
                  scrolldeck.controller.animate(anim, { delay: (anim.attr('data-build')-1)*400, duration: 400, property:'opacity', start:0, pin:true });
                  break;
               default:
                  scrolldeck.controller.animate(anim, { delay: (anim.attr('data-build')-1)*400, duration: 400, property:'opacity', start:0, pin:true });
            }
         }
         
         // set slide and animation scrollpoints
         scrollpoints = scrolldeck.controller.getScrollpoints();
         
         // if nav buttons, create array of section header slide indexes
         for (i=0; i<buttons.length;i++)
            sections.push(slides.index($($(buttons[i]).attr('href'))));
         
         // event handler for updating current slide index and current nav button
         scrolldeck.controller.onBlockChange(function() {
            // get slide index
            currIndex = scrolldeck.controller.blockIndex;
            
            // then update nav
            updateNav();
         });
         
         // Nav button click event
         buttons.on('click', function(e) {
            e.preventDefault();
            var slide = $($(this).attr('href'));
            currIndex = slide.index();
            scrollToSlide(slide);
         });
         
         // Keyboard events
         $(document).on('keydown', function(e){
            // up/left arrow = scroll up
            if ((e.keyCode == 37 || e.keyCode == 38) && currIndex !== 0) {
               scrollToSlide(getPrevScrollpoint());
            }
            // down/right arrow, space = scroll down
            else if ((e.keyCode == 39 || e.keyCode == 32 || e.keyCode == 40) && currIndex != slides.length-1) {
               scrollToSlide(getNextScrollpoint());
            }
         });
         
         // if slides are images, assign height to auto for proportional scaling
         for (i=0; i<slides.length; i++) {
            var el = slides.eq(i);
            if (el.prop('tagName').toUpperCase() === 'IMG') {
               el.css('height','auto');
            }
         }
         
         // if last slide is shorter than height of window, increase height
         var lastSlide = slides.eq(slides.length-1);
         if (lastSlide.outerHeight() < $(window).height()) {
            lastSlide.height(lastSlide.height()+$(window).height()-lastSlide.outerHeight());
         }
         
         updateNav();
      };
      
      
      
      // PRIVATE FUNCTIONS
      
      function updateNav() {
         if (buttons) {
            buttons.removeClass('current');
            var currSection = -1;
            for (i=0; i<sections.length;i++) {
               if (currIndex >= sections[i]) {
                  currSection = i;
               }
            }
            if (currSection != -1) {
               buttons.eq(currSection).addClass('current');
            }
         }
      }
      
      function scrollToSlide(slide) {
         $(window)._scrollable().stop();
         $(window).scrollTo(slide, {
            duration: scrolldeck.settings.duration,
            easing: scrolldeck.settings.easing,
            offset: scrolldeck.settings.offset
         });
      }
      
      function getNextScrollpoint() {
         return getScrollpoint(2);
      }
      
      function getPrevScrollpoint() {
         return getScrollpoint(-1);
      }
      
      function getScrollpoint(n) {
         var scrollTop = $(window).scrollTop();
         // make temp dup scrollpoints array
         var points = scrollpoints.slice(0);
         // add current scroll position to new temp array
         points.push(scrollTop);
         // do sort to find nearest scrollpoint
         points.sort(function(a,b){return a - b;});
         return points[points.indexOf(scrollTop)+n];
      }
      
      
      // INIT
      init();
    };
     
})(jQuery);




HILFFEEEEEEEEEE !!!!! * Ich geb auf... * * Ich geb auf... * * Ich geb auf... * * Ich geb auf... * * Ich geb auf... * * Ich geb auf... * * Ich geb auf... * * Ich geb auf... * * Ich geb auf... * * Ich geb auf... * * Ich geb auf... * * Ich geb auf... *
UND DANKE
  View user's profile Private Nachricht senden Website dieses Benutzers besuchen
ChrisKam

Dabei seit: 01.07.2009
Ort: Hattingen
Alter: 38
Geschlecht: Männlich
Verfasst Fr 28.12.2012 23:15
Titel

Antworten mit Zitat Zum Seitenanfang

Was heißt "Scrolleffekt"? Was funktioniert nicht? Was hast Du schon versuchst?
  View user's profile Private Nachricht senden Website dieses Benutzers besuchen
Anzeige
Anzeige
Karlarsch

Dabei seit: 05.02.2007
Ort: -
Alter: 58
Geschlecht: Männlich
Verfasst Sa 29.12.2012 07:52
Titel

Antworten mit Zitat Zum Seitenanfang

Durch den Code wird sich niemand durchquälen wollen, stelle eine Demo-Seite online.

Btw. Was sagt die JS-Konsole?

Gruß
Karl
  View user's profile Private Nachricht senden
DaMiGGe

Dabei seit: 30.09.2008
Ort: Schwerin
Alter: 35
Geschlecht: Männlich
Verfasst Mi 02.01.2013 13:38
Titel

Antworten mit Zitat Zum Seitenanfang

Zitat:
Durch den Code wird sich niemand durchquälen wollen, stelle eine Demo-Seite online.


*Thumbs up!*

Wenn es lediglich ein einfaches "to-top" scrollen im Fußbereich sein soll, empfehle ich das hier:

Code:
$('a.top').click(function(){
      $('body,html').animate({
                  scrollTop: 0
               }, 800);
               return false;
});


irgendwo am Fußende steht dann der a-Tag mit der Klasse "top"

---

Ansonsten kannst du das ja auch für deine Zwecke benutzen, oder?
jQuery setze ich jetzt mal voraus?
  View user's profile Private Nachricht senden Website dieses Benutzers besuchen
 
Ähnliche Themen Div bei Scrollen oben fixieren (jquery) Problem
iOS: Scrollen zu Ankern nur mit CSS, ohne JQuery/Javascript?
Fade-Out Effekt beim Scrollen - aber wie... ?
jQuery Fade Effekt
Sliding-Effekt mit jQuery - Wie umgesetzt?
jQuery Effekt "Bounce" Verschiebt divs
Neues Thema eröffnen   Neue Antwort erstellen
MGi Foren-Übersicht -> Programmierung


Du kannst keine Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst an Umfragen in diesem Forum nicht mitmachen.