Created
May 11, 2016 13:53
-
-
Save Tusko/655a5f3618cd22a303bb91f4df297b25 to your computer and use it in GitHub Desktop.
GAP Parallax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function exGAP(){ | |
| 'use strict'; | |
| $('.is__gap').each(function(){ | |
| var t = $(this), | |
| off = t.offset().top, | |
| step = t.data('step'), | |
| reverse = t.hasClass('__reverse') ? -1 : 1; | |
| if( screen() >= off - screen('height')) { | |
| t.css('background-position','50% '+ reverse * parseInt( ( screen() - off ) / (step || 4) , 10) + 'px'); | |
| } | |
| }); | |
| } | |
| $(window).scroll( exGAP ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php if($flex['photos']) { | |
| echo '<div class="gap__wrap">'; | |
| foreach($flex['photos'] as $img){ | |
| echo '<div class="is__gap __reverse __gap100 __gap_fix" data-aload style="background-image: url(' . $img['url'] . ')"></div>'; | |
| } | |
| echo '</div>'; | |
| } ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .is__gap { | |
| @include background-size(cover); | |
| background-repeat: no-repeat; | |
| background-position: 50% 0; | |
| position: relative; | |
| &.__gap100 { | |
| height: 100vh | |
| } | |
| &.__gap_fix { | |
| background-attachment: fixed | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment