调整浏览器fullpage js的大小时删除延迟

时间:2018-06-04 02:07:06

标签: javascript jquery fullpage.js

我对jquery或javascript没有任何线索我已经对我的能力进行了最好的修改,我想要完成的是当你在全屏缩小或打开浏览器时它的内容和高度有延迟缩小或完全浏览器大小我试图找出如何消除延迟

$(document).ready(function() {
  $('#fullpage').fullpage({
    sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE'],
    navigation: true,
    navigationPosition: 'right',
  });
});
html {
  text-rendering: optimizeLegibility;
  height: 100%;
}

body {
  height: 100%;
  padding: 0px;
  margin: 0px;
  overflow: hidden;
  background: #e6e6e6;
  font-family: roboto, sans-serif;
  font-weight: 400;
  color: #777777;
  line-height: 24px;
  font-size: 16px;
}

html.fp-enabled,
.fp-enabled body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  /*Avoid flicker on slides transitions for mobile phones #336 */
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.fp-section {
  position: relative;
  -webkit-box-sizing: border-box;
  /* Safari<=5 Android<=3 */
  -moz-box-sizing: border-box;
  /* <=28 */
  box-sizing: border-box;
}

.fp-section.fp-table {
  display: table;
  table-layout: fixed;
  width: 100%;
}

.fp-tableCell {
  display: table-cell;
  vertical-align: middle;
  width: 100%;
  height: 100vh;
}

.fp-scrollable {
  overflow: hidden;
  position: relative;
}

.fp-scroller {
  overflow: hidden;
}

.iScrollIndicator {
  border: 0 !important;
}

.fp-notransition {
  -webkit-transition: none !important;
  transition: none !important;
}

#fp-nav {
  position: fixed;
  z-index: 100;
  margin-top: -32px;
  top: 50%;
  opacity: 1;
  -webkit-transform: translate3d(0, 0, 0);
}

#fp-nav.right {
  right: 17px;
}

#fp-nav ul {
  margin: 0;
  padding: 0;
}

#fp-nav ul li {
  display: block;
  width: 14px;
  height: 13px;
  margin: 7px;
  position: relative;
}

#fp-nav ul li a {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  cursor: pointer;
  text-decoration: none;
}

#fp-nav ul li a.active span,
#fp-nav ul li:hover a.active span {
  height: 12px;
  width: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 100%;
}

#fp-nav ul li a span {
  border-radius: 50%;
  position: absolute;
  z-index: 1;
  height: 4px;
  width: 4px;
  border: 0;
  background: #333;
  left: 50%;
  top: 50%;
  margin: -2px 0 0 -2px;
  -webkit-transition: all 0.1s ease-in-out;
  -moz-transition: all 0.1s ease-in-out;
  -o-transition: all 0.1s ease-in-out;
  transition: all 0.1s ease-in-out;
}

#fp-nav ul li:hover a span {
  width: 10px;
  height: 10px;
  margin: -5px 0px 0px -5px;
}

#fp-nav ul li .fp-tooltip {
  position: absolute;
  top: -2px;
  color: #fff;
  font-size: 14px;
  font-family: arial, helvetica, sans-serif;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  display: block;
  opacity: 0;
  width: 0;
  cursor: pointer;
}

.fp-auto-height.fp-section,
.fp-auto-height .fp-tableCell {
  height: 100vh !important;
}

.fp-responsive .fp-auto-height-responsive.fp-section,
.fp-responsive .fp-auto-height-responsive .fp-tableCell {
  height: 100vh !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://alvarotrigo.com/fullPage/jquery.fullPage.min.js"></script>



<div id="fullpage">
  <div class="section " id="section1">
    <h1>Section 1</h1>
  </div>
  <div class="section" id="section2">
    <h1>Section 2</h1>
  </div>
  <div class="section" id="section3">
    <h1>Section 3</h1>
  </div>
</div>

2 个答案:

答案 0 :(得分:1)

请注意,删除延迟意味着fullpabe.js将在重新调整时每秒进行数百次操作,因为resize事件会被触发数百次。 这就是为什么延迟存在,所以它不会像疯了一样消耗机器资源这样的基本事情。

您可以减少数量,但我不鼓励您完全删除它。

修改fullPage.js版本2.9.7 line 2150更改350为50,例如:

resizeId = setTimeout(function(){
    reBuild(true);
}, 350);

将其更改为:

resizeId = setTimeout(function(){
    reBuild(true);
}, 50);

答案 1 :(得分:0)

您可以在doneResizing();

中初始化插件方法$(window).resize(function () {})