2

I'm using this plugin https://github.com/peachananr/onepage-scroll for my portfolio. It works fine, the only problem I have is that the footer is not displaying with the height I want(height: 150px).

<div class="main">
<div class="section">1</div>
<div class="section">2</div>
<div class="section">3</div>
<footer>Text</footer>
</div>

If I add the class section to the footer it will work but it will make the footer height 100%.

I found another plugin http://alvarotrigo.com/fullPage/ which can solve this problem, but I don't want to change it because of one issue only.

If someone can help me solve this problem I will be very thankful.

Georgi Kirilov
  • 569
  • 2
  • 5
  • 12

3 Answers3

1

I didn't see any built-in way to do that. Are you willing to patch the plugin? If so, after line:

$.fn.transformPage = function(settings, pos, index) {

Add:

if (pos <= -(total - 1) * 100) {
    footer_height = sections.eq(-1).height();
    footer_percent = footer_height / $(this).height();
    pos = pos + 100 - (footer_percent * 100);
}

And on the CSS, supposing your footer is on .page3:

.onepage-wrapper .section.page3 {
    height: 150px;
}

See it working.

Ivan Chaer
  • 6,980
  • 1
  • 38
  • 48
  • You should use `sections.eq(-1).outerHeight();`. JQuerys `.height` function sometimes returns messed up results (https://stackoverflow.com/questions/12184133/jquery-wrong-values-when-trying-to-get-div-height) – Maxim Kopecki Jun 05 '19 at 08:39
0

You can try it in css with important like this:

footer {
 height: 150px !important;
} 
0

if function:

this.moveDown = function(e) {

after:

if (i.loop == true) {
    pos = 0;
    r = document.querySelector(i.sectionContainer + "[data-index='1']");
  }

add:

   /*VM Cusom code for footer */
      else if(i.footer) {
        const footer = document.querySelector(i.footer);
        const footerHeight = footer.offsetHeight;
        const footerStyle = window.getComputedStyle(footer);
        const footerOuterHeight = footerHeight + parseInt(footerStyle.marginTop)  + parseInt(footerStyle.marginBottom);
        const footerPercent = footerOuterHeight / e.offsetHeight;
        if(pos >= ((t-1) * -100)){
          pos = pos - (footerPercent * 100);
          r = document.querySelector(i.sectionContainer + "[data-index='" + (parseInt(t)) + "']");
        }
        else {
          return;
        }
      }
    /*VM Cusom code for footer */

AND in function:

  this.moveUp = function(e) {

after:

if (!r) {
      if (i.loop == true) {
        pos = (u - 1) * 100 * -1;
        r = document.querySelector(
          i.sectionContainer + "[data-index='" + u + "']"
        );
      }
      else {
        return;
      }
    }

add:

else if(t == u && (pos < ((t-1) * -100))) {
  pos = (r.dataset.index) * 100 * -1;
  r = document.querySelector(
    i.sectionContainer + "[data-index='" + u + "']"
  );
}

in initialization add selector to your footer

onePageScroll(".home", { 
    footer: "footer" 
});