Skip to content

Commit 9f4913f

Browse files
committed
simple option for offsetTop
1 parent 7f995d7 commit 9f4913f

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ $(document).ready(function() {
191191
responsiveWidth: 0,
192192
responsiveHeight: 0,
193193
responsiveSlides: false,
194+
offsetTop: 0,
194195

195196
//Custom selectors
196197
sectionSelector: '.section',
@@ -448,6 +449,8 @@ In order to prevent fullpage.js from creating the scrollbar in certain sections
448449

449450
- `responsiveSlides`: (default `false`) [Extension of fullpage.js](http://alvarotrigo.com/fullPage/extensions/). When set to `true` slides will be turned into vertical sections when responsive mode is fired. (by using the `responsiveWidth` or `responsiveHeight` options detailed above). Requires fullpage.js >= 2.8.5.
450451

452+
- `offsetTop`: (default `0`). When set to a numeric value, this defines a top offset for the container height. This is particularly useful if you have a fixed header navigation that follows your scroll and you do not want the header navigation to cut off content in your sections.
453+
451454
- `lazyLoading`: (default `true`) Lazy loading is active by default which means it will lazy load any media element containing the attribute `data-src` as detailed in the [Lazy Loading docs](https://github.com/alvarotrigo/fullPage.js#lazy-loading) . If you want to use any other lazy loading library you can disable this fullpage.js feature.
452455

453456
## Methods

jquery.fullPage.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* fullPage 2.8.8
2+
* fullPage 2.8.9
33
* https://github.com/alvarotrigo/fullPage.js
44
* @license MIT licensed
55
*
@@ -165,6 +165,7 @@
165165
responsiveWidth: 0,
166166
responsiveHeight: 0,
167167
responsiveSlides: false,
168+
offsetTop: 0,
168169

169170
//Custom selectors
170171
sectionSelector: SECTION_DEFAULT_SEL,
@@ -189,7 +190,7 @@
189190
var isTouchDevice = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/);
190191
var isTouch = (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0) || (navigator.maxTouchPoints));
191192
var container = $(this);
192-
var windowsHeight = $window.height();
193+
var windowsHeight = $window.height() - options.offsetTop;
193194
var isResizing = false;
194195
var isWindowFocused = true;
195196
var lastScrolledDestiny;
@@ -432,7 +433,7 @@
432433

433434
isResizing = true;
434435

435-
windowsHeight = $window.height(); //updating global var
436+
windowsHeight = $window.height() - options.offsetTop; //updating global var
436437

437438
$(SECTION_SEL).each(function(){
438439
var slidesWrap = $(this).find(SLIDES_WRAPPER_SEL);
@@ -551,6 +552,11 @@
551552
options.css3 = support3d();
552553
}
553554

555+
if (options.offsetTop) {
556+
container.css("top", options.offsetTop);
557+
container.height(container.height() - options.offsetTop);
558+
}
559+
554560
options.scrollBar = options.scrollBar || options.hybrid;
555561

556562
setOptionsFromDOM();
@@ -662,7 +668,7 @@
662668
$('html').addClass(ENABLED);
663669

664670
//due to https://github.com/alvarotrigo/fullPage.js/issues/1502
665-
windowsHeight = $window.height();
671+
windowsHeight = $window.height() - options.offsetTop;
666672

667673
container.removeClass(DESTROYED); //in case it was destroyed before initilizing it again
668674

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fullpage.js",
3-
"version": "2.8.8",
3+
"version": "2.8.9",
44
"description": "Create beautiful fullscreen scrolling websites",
55
"main": "dist/jquery.fullpage.js",
66
"scripts": {

0 commit comments

Comments
 (0)