fullPage learning


learning target:

  • You can say the basic idea of ​​using plug-fullpage
  • Shopping cases to write the screen scrolling effect and make the sidebar
  • Be able to write the first screen layout and animation
  • To write the second screen layout and animation
  • To write the third screen layout and animation
  • To write the fourth, fifth, sixth, seventh screen layout and animation
  • You could write an eighth-screen layout and animation
  • Adding a keyboard to write the scroll and re-start the animation

    typora-copy-images-to: media



Shopping propaganda page

Case purposes:

  1. Review --- review earlier learned HTML5 + CSS3
  2. Comprehensive --- complete integrated use jquery Case
  3. --- can expand advertise or biographical page

fullpage full-screen plug-in

Full screen scrolling effect, native is also very good js achieve, mainly with mousewheel scrolling the mouse wheel event to determine the scroll or scroll, scroll after each set height to the height of the screen. However, although the effect is simple, but very poor compatibility, compatible treatment and do a lot of it is too much trouble! (Look, interested students can look)

fullPage.js is a jQuery-based plug-in that can help you easily, very easily create a full-screen website.

github official website https://github.com/alvarotrigo/fullPage.js

Chinese Demo http://www.dowebok.com/demo/2014/77/

The main features are:

Support for mouse scroll

Forward and back support and keyboard control

Many callbacks

Support for mobile phones, flat-panel touch event

Support for CSS3 animations

Support Window Scaling

Automatically adjust the zoom window

Scroll width can be set, the background color, the scroll speed, cycle option, callback, text alignment, etc.

reference materials

<link rel="stylesheet" href="css/jquery.fullPage.css">
<script src="js/jquery.min.js"></script>
 <!-- jquery.easings.min.js 是必须的,用于 easing 参数,也可以使用完整的 jQuery UI 代替 -->
<script src="js/jquery.easings.min.js"></script>
 <script src="js/jquery.fullPage.js"></script>

HTML structure

<div id="fullpage">
    <div class="section">第一屏</div>
    <div class="section">第二屏</div>
    <div class="section">
        <div class="slide">第三屏的第一屏</div>
        <div class="slide">第三屏的第二屏</div>
        <div class="slide">第三屏的第三屏</div>
        <div class="slide">第三屏的第四屏</div>
    </div>
    <div class="section">第四屏</div>
</div>

JavaScript entry function

$(function(){
    $('#fullpage').fullpage();
});

fullpage detailed parameters

Options Types of Defaults Explanation
verticalCentered String true Whether the content is centered vertically
resize Boolean value false With window scaling font is scaled
sectionColor function no Set the background color
anchors Array no Defined anchor link
scrollingSpeed Integer 700 Scrolling speed in milliseconds
easing String easeInQuart Scroll animation
menu Boolean value false After the anchors corresponding to the value associated with the binding properties of the menu, setting, you can control the scrolling menu
navigation Boolean value false Whether to display the navigation project
navigationPosition String right Location of the project navigation, optional left or right
navigationTooltips Array air Project Navigator's tip
slidesNavigation Boolean value false Whether to display the slider left and right navigation project
slidesNavPosition String bottom Project Navigator slider left and right positions, optional top or bottom
controlArrowColor String #fff The background color of the left and right arrow slider
loopBottom Boolean value false Whether go back to the top of the scroll to the bottom
loopTop Boolean value false Whether rolling bottom to the very top of the scroll
loopHorizontal Boolean value true Whether circulating around the slider slides
autoscrolling Boolean value true Whether to use a plug-in scroll mode, if you select false, the browser that comes with a scroll bar will appear
scrollOverflow Boolean value false Whether the content is displayed for more than full screen scroll bar
css3 Boolean value false Whether to use CSS3 transforms scroll
paddingTop String 0 And the distance from the top of
paddingBottom String 0 And from the bottom
fixedElements String no
normalScrollElements no
keyboardScrolling Boolean value true Whether to use the keyboard arrow keys to navigate
touchSensitivity Integer 5
continuousVertical Boolean value false Whether rolling cycle, is not compatible with loopTop and loopBottom
animateAnchor Boolean value true
normalScrollElementTouchThreshold Integer 5

fullPage.js method

You need to add a note to use when:

For example, $ .fn.fullpage

$.fn.fullpage.moveTo(1);
name Explanation
moveSectionUp () Scroll up
moveSectionDown () Scroll down
moveTo(section, slide) Scroll to the
moveSlideRight() slide scroll right
moveSlideLeft() Scroll Left slide
setAutoScrolling() 设置页面滚动方式,设置为 true 时自动滚动
setAllowScrolling() 添加或删除鼠标滚轮/触控板控制
setKeyboardScrolling() 添加或删除键盘方向键控制
setScrollingSpeed() 定义以毫秒为单位的滚动速度

回调函数

名称 说明
afterLoad 滚动到某一屏后的回调函数,接收 anchorLink 和 index 两个参数,anchorLink 是锚链接的名称,index 是序号,从1开始计算
onLeave 滚动前的回调函数,接收 index、nextIndex 和 direction 3个参数:index 是离开的“页面”的序号,从1开始计算;nextIndex 是滚动到的“页面”的序号,从1开始计算;direction 判断往上滚动还是往下滚动,值是 up 或 down。
afterRender 页面结构生成后的回调函数,或者说页面初始化完成后的回调函数
afterSlideLoad 滚动到某一水平滑块后的回调函数,与 afterLoad 类似,接收 anchorLink、index、slideIndex、direction 4个参数
onSlideLeave 某一水平滑块滚动前的回调函数,与 onLeave 类似,接收 anchorLink、index、slideIndex、direction 4个参数

jQuery Easing.js 插件

介绍:easing是jquery的一个插件,使用它可以创建更加绚丽的动画效果。

环境:因为easing是jQuery的插件,所以必须是在引入jquery之后再引入它

如果只想要简单的写法就用

$(".car").animate({"left": "150%"},  4000, "easeInElastic", function() {});
easing:格式为json,{duration:持续时间,easing:过渡效果,complete:成功后的回调函数}
$(element).animate({ 
    height:500, 
    width:600 
    },{ 
    easing: 'easeInOutQuad', 
    duration: 500, 
    complete: function(){} 
}); 
  1. linear
  2. swing
  3. easeInQuad
  4. easeOutQuad
  5. easeInOutQuad
  6. easeInCubic
  7. easeOutCubic
  8. easeInOutCubic
  9. easeInQuart
  10. easeOutQuart
  11. easeInOutQuart
  12. easeInQuint
  13. easeOutQuint
  14. easeInOutQuint
  15. easeInExpo
  16. easeOutExpo
  17. easeInOutExpo
  18. easeInSine
  19. easeOutSine
  20. easeInOutSine
  21. easeInCirc
  22. easeOutCirc
  23. easeInOutCirc
  24. easeInElastic
  25. easeOutElastic
  26. easeInOutElastic
  27. easeInBack
  28. easeOutBack
  29. easeInOutBack
  30. easeInBounce
  31. easeOutBounce
  32. easeInOutBounce

https://matthewlein.com/experiments/easing.html

动画复习

视差滚动插件

视差滚动(Parallax Scrolling)指网页滚动过程中,多层次的元素进行不同程度的移动,视觉上形成立体运动效果的网页展示技术

主要核心就是前景和背景以不同的速度移动,从而创造出3D效果。 这种效果可以给网站一个很好的补充。

特性

视差滚动效果酷炫,适合于个性展示的场合。

视差滚动徐徐展开,适合于娓娓道来,讲故事的场合。

视差滚动容易迷航,需要具备较强的导航功能。

原理

传统的网页的文字、图片、背景都是一起按照相同方向相同速度滚动的,而视差滚动则是在滚动的时候,内容和多层次的背景实现或不同速度,或不同方向的运动。

有的时候也可以加上一些透明度、大小的动画来优化显示。

利用background-attachment属性实现。

background-attachment: fixed || scroll || local

Stellar.js是什么?

stellar.js 是一个 jQuery插件,能很容易地给网站添加视差滚动效果。 尽管已经停止了维护,但它非常稳定,与最新版本的jQuery兼容,很多开发者也在使用它。 这个插件在jQuery插件库里很流行。

http://markdalgleish.com/projects/stellar.js/ 官网

引用 js包

<script src="path/to/jquery/jquery.min.js"></script>
<script src="path/to/jquery.stellar.min.js"></script>

引用html

<div class="content" id="content1">
    <p>TEXT HERE</p>
</div>
<div class="content" id="content2">
    <p>TEXT HERE</p>
</div>
<div class="content" id="content3" data-stellar-background-ratio="0.5">
    <p>TEXT HERE</p>
</div>
<div class="content" id="content4" data-stellar-background-ratio="0.5">
    <p>TEXT HERE</p>
</div>
<div class="content" id="content5" data-stellar-background-ratio="0.5">
    <p>TEXT HERE</p>
</div>
<div class="content" id="content6" data-stellar-background-ratio="0.5">
    <p>TEXT HERE</p>
</div> 

引入CSS

body {
    font-size: 20px;
    color: white;
    text-shadow: 0 1px 0 black, 0 0 5px black;
}
p {
    padding: 0 0.5em;
    margin: 0;
}
.content {
    background-attachment: fixed;
    height: 400px;
}
#content1 {
    background-image: url("xxx.jpg");
}
#content2 {
    background-image: url("xxx.jpg");
}
#content3 {
    background-image: url("xxx.jpg");
}
#content4 {
   background-image: url("xxx.jpg");
}
#content5 {
   background-image: url("xxx.jpg");");
}
#content6 {
    background-image: url("xxx.jpg");
}

js调用函数

$.stellar({
    horizontalScrolling: false,
    responsive: true
});

详细参数

名称 说明
horizontalScrolling 和 verticalScrolling 该配置项用来设置视差效果的方向。horizontalScrolling设置水平方向,verticalScro设置垂直方向, 为布尔值,默认为true
responsive 该配置项用来制定load或者resize时间触发时是否刷新页面,其值为布尔值,默认为false
hideDistantElements 该配置项用来设置移出视线的元素是否隐藏,其值为布尔值,若不想隐藏则设置为false`
data-stellar-ratio="2" 定义了此元素针对页面滚动的速度比率,比如,0.5为页面滚动的50%,2为页面滚动的200%,所以数值越大,你可以看到页面元素滚动速度越快。
data-stellar-background-ratio 该配置项用在单个元素中,其值为一个正数,用来改变被设置元素的影响速度。 例如 值为0.3时,则表示背景的滚动速度为正常滚动速度的0.3倍。如果值为小数时最好在样式表中设置

QQ TIM 案例

Guess you like

Origin www.cnblogs.com/article-record/p/11546328.html