Created
December 14, 2012 12:43
-
-
Save wojtha/4285234 to your computer and use it in GitHub Desktop.
Drupal - add floating left and right banner regions
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
| <div id="main"> | |
| <?php if (!empty($banner_left)) { print '<div id="banner-left" class="scrollable">' . render($banner_left) . '</div>'; } ?> | |
| <?php if (!empty($banner_right)) { print '<div id="banner-right" class="scrollable">' . render($banner_right) . '</div>'; } ?> | |
| <!-----8<-----SNIP-----------------------------------------------------------------> | |
| </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
| /* Banner scrolling */ | |
| (function($) { | |
| $(document).ready(function () { | |
| $('.scrollable').each( function(){ | |
| var $el = $(this); | |
| var base_y = $el.offset().top - parseFloat($el.css('marginTop').replace(/auto/, 0)); | |
| var base_top = $el.css('top'); | |
| $(window).scroll(function (event) { | |
| var window_y = $(document).scrollTop(); | |
| if (window_y >= base_y) { | |
| $el.css('top', window_y - base_y + 30); | |
| } | |
| else { | |
| $el.css('top', base_top); | |
| } | |
| }); | |
| }) | |
| }); | |
| })(jQuery); |
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
| #main { | |
| position: relative; | |
| } | |
| #banner-left,#banner-right{ | |
| width: 160px; | |
| height: 600px; | |
| position: absolute; | |
| top: 27px; | |
| z-index: 99; | |
| } | |
| #banner-left{ | |
| left: -165px; | |
| } | |
| #banner-right{ | |
| right: -165px; | |
| } |
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
| regions[banner_left] = Banner Left | |
| regions[banner_right] = Banner Right | |
| #-----8<-----SNIP------------------- | |
| stylesheets[all][] = style.css | |
| scripts[] = script.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment