Home Web Front-end JS Tutorial Implement full-screen scrolling effect based on jquery_javascript skills

Implement full-screen scrolling effect based on jquery_javascript skills

May 16, 2016 pm 03:29 PM
jquery full screen scroll

So today I will introduce this fullPage, which is different from fullPage.js. Fullpage has better compatibility and is downward compatible with IE6. It does not rely on any js library and can be used independently. Although it is not as powerful as fullPage.js in terms of functionality, it is sufficient for general use, especially its animation effects. You can freely set scaling and rotation to produce various animation effects. It also supports horizontal scrolling that fullPage.js does not have.

  • Compatible with desktop (ie5.5) and mobile version
  • You can use it to build your personal homepage or web application
  • This is a compact framework that does not use jQuery and is less than 9KB

Before introducing it, let’s take a look at the operation renderings:

Introduce the core library, pagefull depends on any JS library, so you only need to introduce it itself

1

<script src="js/fullPage.min.js"></script>

Copy after login

Write html

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

//请在head区加入以下代码,移动端使用

<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">

  

<!--[if lte IE 7]> 

<body scroll="no">

<![endif]-->

<!--[if gt IE 7]><!-->

<body>

<!--<![endif]-->

 <div id="pageContain">

    

  <div class="page page1 current">

   <div class="contain">

      

   </div>

  </div>

  

  <div class="page page2">

   <div class="contain">

      

   </div>

  </div>

  

  <div class="page page3" data-step="4">

   <div class="contain">

    <p class="demo-data-step">data-step可以让你在不切屏的情况下更换动画</p>

   </div>

  </div>

  

  <div class="page page4">

   <div class="contain">

      

   </div>

  </div>

  

  <div class="page page5">

   <div class="contain">

      

   </div>

  </div>

  

  <div class="page page6">

   <div class="contain">

      

   </div>

  </div>

 </div>

 <ul id="navBar">

  <li>0</li>

  <li>1</li>

  <li>2</li>

  <li>3</li>

  <li>4</li>

  <li>5</li>

 </ul>

</body>

Copy after login

Write CSS. Friends who are not familiar with CSS3, please go back and make up for it. I will not analyze it here. CSS can be freely defined according to the needs of the project.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

html {

-ms-touch-action: none; /* 阻止windows Phone 的默认触摸事件 */

}

body,

div,

p {

 margin: 0;

 padding: 0;

}

ul {

 list-style: none;

}

body {

 width: 100%;

 *cursor: default;

 overflow: hidden;

 font: 16px/1.5 "Microsoft YaHei",Helvetica,STHeiti STXihei,Microsoft JhengHei,Arial;

}

#pageContain {

 overflow: hidden;

}

.page {

 display: none;

 width: 100%;

 height: 100%;

 overflow: hidden;

 position: absolute;

 top: 0;

 left: 0;

}

.contain {

 width: 100%;

 height: 100%;

 display: none;

 position: relative;

 z-index: 0;

}

.current .contain,.slide .contain {

 display: block;

}

.current {

 display: block;

 z-index: 1;

}

.slide {

 display: block;

 z-index: 2;

}

.swipe {

 display: block;

 z-index: 3;

 transition-duration: 0ms !important;

 -webkit-transition-duration: 0ms !important;

}

.page1 {

 background: #37c1e3;

}

.page2 {

 background: #009922;

}

.page3 {

 background: #992211;

}

.page4 {

 background: #ff00ff;

}

.page5 {

 background: #00ff00;

}

.page6 {

 background: #22ffff;

}

#navBar {

 z-index: 3;

 position: absolute;

 top: 10%;

 right: 3%;

}

#navBar .active {

 background: #ccc;

}

#navBar li {

 cursor: pointer;

 margin-bottom: 10px;

 transition: all .7s ease;

 border-radius: 50%;

 line-height: 40px;

 text-align: center;

 width: 40px;

 height: 40px;

}

 

 

 

p {

 width: 200px;

 height: 100px;

 color:#fff;

 text-align: center;

 position: absolute;

 left: 50%;

 top: 50%;

 margin-left: -100px;

 margin-top: -50px;

 opacity: 1;

 transition: all .8s ease;

 transform-origin: 50% 50%;

}

.step1 p {

 transform: translate(0, -50px);

 -webkit-transform: translate(0, -50px);

}

.step2 p {

 opacity: 0;

 transform: scale(2);

 -webkit-transform: scale(2);

}

.step3 p {

 transform: scale(1);

 -webkit-transform: scale(1)

 opacity: 1;

}

.step4 p {

 -webkit-transform: rotate(360deg) translate(0,-200px) scale(.3);

 transform: rotate(360deg) translate(0,-200px) scale(.3);

 opacity: 0;

}

Copy after login

Write JS to achieve the effect

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

var runPage;

  

runPage = new FullPage({

  

 id : 'pageContain',       // 容器id

 slideTime : 800,        // 每页切换时间,单位为毫秒

 continuous : false,       // 是否循环(即能从最后页跳到第一页面)

 effect : {          // 滚动效果

   transform : {

    translate : 'Y',     // 'X'|'Y'|'XY'|'none' X轴|Y轴|XY轴|无

    scale : [.1, 1],    // [scalefrom, scaleto] [起始缩放比例, 结束时缩放比例]

    rotate : [0, 0]      // [rotatefrom, rotateto] [起始旋转角度, 结束时旋转角度]

   },

   opacity : [0, 1]      // [opacityfrom, opacityto][起始透明度, 结束时透明度]

  },      

 mode : 'wheel,touch,nav:navBar',    // 转换模式 'wheel,touch,nav:navBar' 表示 '滚轮,触摸,导航条:导航条id'

 easing : 'ease'        // easing('ease','ease-in','ease-in-out' 或使用贝塞尔曲线 [.33, 1.81, 1, 1];

 // ,onSwipeStart : function(index, thisPage) { // 触摸开始时的回调函数

 // return 'stop';

 // }

 // ,beforeChange : function(index, thisPage) { // 滑动开始时的回调函数

 // return 'stop';

 // }

 // ,callback : function(index, thisPage) {  // 滑动结束后的回调函数

 // alert(index);

 // };

});

Copy after login

Detailed parameter settings

id String – outer package id

slideTime Integer (default:800) – page switching time (milliseconds)

effect Object (default:{}) – Effect parameters

mode String (default:'') - Conversion mode 'wheel,touch,nav:navBar' means 'wheel, touch, navbar:navbarid'

callback Function – callback function after sliding ends

Interface

Fullpage also provides some excuses for developers using this plugin to call:

prev() Slide directly to the previous page

next() Slide directly to the next page

thisPage() Returns the current page number

go(num) Slide directly to page num

The above is about achieving a full-screen scrolling effect similar to NetEase mailbox. I hope you can create a full-screen scrolling effect suitable for your own website.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of jQuery reference methods: Quick start guide Detailed explanation of jQuery reference methods: Quick start guide Feb 27, 2024 pm 06:45 PM

Detailed explanation of jQuery reference method: Quick start guide jQuery is a popular JavaScript library that is widely used in website development. It simplifies JavaScript programming and provides developers with rich functions and features. This article will introduce jQuery's reference method in detail and provide specific code examples to help readers get started quickly. Introducing jQuery First, we need to introduce the jQuery library into the HTML file. It can be introduced through a CDN link or downloaded

How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

In-depth analysis: jQuery's advantages and disadvantages In-depth analysis: jQuery's advantages and disadvantages Feb 27, 2024 pm 05:18 PM

jQuery is a fast, small, feature-rich JavaScript library widely used in front-end development. Since its release in 2006, jQuery has become one of the tools of choice for many developers, but in practical applications, it also has some advantages and disadvantages. This article will deeply analyze the advantages and disadvantages of jQuery and illustrate it with specific code examples. Advantages: 1. Concise syntax jQuery's syntax design is concise and clear, which can greatly improve the readability and writing efficiency of the code. for example,

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: &lt

How to remove the height attribute of an element with jQuery? How to remove the height attribute of an element with jQuery? Feb 28, 2024 am 08:39 AM

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on ​​the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

Understand the role and application scenarios of eq in jQuery Understand the role and application scenarios of eq in jQuery Feb 28, 2024 pm 01:15 PM

jQuery is a popular JavaScript library that is widely used to handle DOM manipulation and event handling in web pages. In jQuery, the eq() method is used to select elements at a specified index position. The specific usage and application scenarios are as follows. In jQuery, the eq() method selects the element at a specified index position. Index positions start counting from 0, i.e. the index of the first element is 0, the index of the second element is 1, and so on. The syntax of the eq() method is as follows: $("s

How to tell if a jQuery element has a specific attribute? How to tell if a jQuery element has a specific attribute? Feb 29, 2024 am 09:03 AM

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute

See all articles