Skip to content

Commit bf43131

Browse files
committed
- Fullpage v2.0. Now needed a container in the HTML structure. alvarotrigo#265, alvarotrigo#319
- Added compatibility for old version (<2.0)
1 parent 068574b commit bf43131

File tree

3 files changed

+66
-53
lines changed

3 files changed

+66
-53
lines changed

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ As you can see in the example files, you will need to include the JavaScript fil
4343
Each section will be defined with a `div` containing the `section` class.
4444
The active section by default will be the first section, which is taken as the home page.
4545
```html
46-
<div class="section">Some section</div>
47-
<div class="section">Some section</div>
48-
<div class="section">Some section</div>
49-
<div class="section">Some section</div>
46+
<div id="fullpage">
47+
<div class="section">Some section</div>
48+
<div class="section">Some section</div>
49+
<div class="section">Some section</div>
50+
<div class="section">Some section</div>
51+
</div>
5052
```
5153
If you want to define a different starting point rather than the first section or the first slide of a section, just add the class `active` to the section and slide you want to load first.
5254
```html
@@ -70,14 +72,14 @@ All you need to do is call the plugin inside a `$(document).ready` function:
7072

7173
```javascript
7274
$(document).ready(function() {
73-
$.fn.fullpage();
75+
$('#fullpage').fullpage();
7476
});
7577
```
7678

7779
A more complex initialization with all options set could look like this:
7880
```javascript
7981
$(document).ready(function() {
80-
$.fn.fullpage({
82+
$('#fullpage').fullpage({
8183
verticalCentered: true,
8284
resize : true,
8385
slidesColor : ['#ccc', '#fff'],
@@ -155,7 +157,7 @@ To create links between sections, you could use the `menu` option and make use o
155157
- `slidesColor`:(default `none`) Define the CSS `background-color` property for each section:
156158
Example:
157159
```javascript
158-
$.fn.fullpage({
160+
$('#fullpage').fullpage({
159161
slidesColor: ['#f2f2f2', '#4BBFC3', '#7BAABE', 'whitesmoke', '#000'],
160162
});
161163
```
@@ -203,7 +205,7 @@ In order to link the elements of the menu with the sections, an HTML 5 data-tag
203205
</ul>
204206
```
205207
```javascript
206-
$.fn.fullpage({
208+
$('#fullpage').fullpage({
207209
anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],
208210
menu: '#myMenu'
209211
});
@@ -302,7 +304,7 @@ In case of not having anchorLinks defined in the plugin the `index` parameter wo
302304
Example:
303305

304306
```javascript
305-
$.fn.fullpage({
307+
$('#fullpage').fullpage({
306308
anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],
307309

308310
afterLoad: function(anchorLink, index){
@@ -330,7 +332,7 @@ Parameters:
330332
Example:
331333

332334
```javascript
333-
$.fn.fullpage({
335+
$('#fullpage').fullpage({
334336
onLeave: function(index, direction){
335337
//after leaving section 2
336338
if(index == '2' && direction =='down'){
@@ -351,7 +353,7 @@ This callback is fired just after the structure of the page is generated. This i
351353
Example:
352354

353355
```javascript
354-
$.fn.fullpage({
356+
$('#fullpage').fullpage({
355357
afterRender: function(){
356358
alert("The resulting DOM stucture is ready");
357359
}
@@ -373,7 +375,7 @@ In case of not having anchorLinks defined for the slide or slides the `slideInde
373375
Example:
374376

375377
```javascript
376-
$.fn.fullpage({
378+
$('#fullpage').fullpage({
377379
anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],
378380

379381
afterSlideLoad: function( anchorLink, index, slideAnchor, slideIndex){
@@ -407,7 +409,7 @@ Parameters:
407409
Example:
408410

409411
```javascript
410-
$.fn.fullpage({
412+
$('#fullpage').fullpage({
411413
onSlideLeave: function( anchorLink, index, slideIndex, direction){
412414
//leaving the first slide of the 2nd Section to the right
413415
if(index == 2 && slideIndex == 0 && direction == 'right'){

jquery.fullPage.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* fullPage 1.8.5
2+
* fullPage 2.0
33
* https://github.com/alvarotrigo/fullPage.js
44
* MIT licensed
55
*
@@ -131,7 +131,7 @@
131131
var slideMoving = false;
132132

133133
var isTablet = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|Windows Phone)/);
134-
134+
var container = $(this).length? $(this): $('#superContainer'); // for compatibity reasons for fullpage < v2.0
135135
var windowsHeight = $(window).height();
136136
var isMoving = false;
137137
var isResizing = false;
@@ -145,7 +145,18 @@
145145
options.css3 = support3d();
146146
}
147147

148-
$('body').wrapInner('<div id="superContainer" />');
148+
if($(this).length){
149+
container.css({
150+
'height': '100%',
151+
'position': 'relative',
152+
'-ms-touch-action': 'none'
153+
});
154+
}
155+
156+
//for compatibity reasons for fullpage < v2.0
157+
else{
158+
$('body').wrapInner('<div id="superContainer" />');
159+
}
149160

150161
//creating the navigation dots
151162
if (options.navigation) {
@@ -633,7 +644,7 @@
633644

634645
if(options.autoScrolling){
635646
scrollOptions['top'] = -dtop;
636-
scrolledElement = '#superContainer';
647+
scrolledElement = container.selector;
637648
}else{
638649
scrollOptions['scrollTop'] = dtop;
639650
scrolledElement = 'html, body';
@@ -1204,9 +1215,9 @@
12041215
* Adds a css3 transform property to the container class with or without animation depending on the animated param.
12051216
*/
12061217
function transformContainer(translate3d, animated){
1207-
$('#superContainer').toggleClass('easing', animated);
1218+
container.toggleClass('easing', animated);
12081219

1209-
$('#superContainer').css(getTransforms(translate3d));
1220+
container.css(getTransforms(translate3d));
12101221
}
12111222

12121223

@@ -1428,7 +1439,7 @@
14281439
transformContainer(translate3d, false);
14291440
}
14301441
else {
1431-
$("#superContainer").css("top", -top);
1442+
container.css("top", -top);
14321443
}
14331444
}
14341445

0 commit comments

Comments
 (0)