In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "jQuery how to achieve full-screen scrolling effect similar to the fullpage plug-in", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "jQuery how to achieve a full-screen scrolling effect similar to the fullpage plug-in" bar!
Combined with the ideas on the Internet, coupled with the code I made before, the code has these functions:
1. The contents of the head and tail can be scrolled without scrolling, as long as they are scrolled in the middle.
two。 Support the animation trigger of the previous screen and the next screen
3. Support the next page and previous page navigation jump
4. Support mini navigation display and jump to a page
HTML Code:
Header
Page1
Page2
Page3
Page4
next page
Footer
When setting CSS, you need to note that there are two parent class elements, and the outermost one should be set beyond the height of hiding.
.doc {height:640px;position:relative;overflow:hidden}
.main {position:relative}
.doc .page {position:absolute;height:100%;width:100%;top:100%}
.doc.done .page {position:static;top:0}
JS code, note that the scrolling compatible code uses the jQuery plug-in jquery-mousewheel. Don't miss this plug-in.
JS:
$(function () {)
Var onScroll = false
CurIndex = 0
Len = $(".doc .page") .length
Var winHeight = $(window) .height ()
/ / var boxHeight = winHeight- 60 > 640? WinHeight-60: 640; / / when you need to display all the content, you need to give the outer layer a fixed height to ensure that all the content can be seen.
Var boxHeight = winHeight-60
Var toPage = function (curIndex) {
OnScroll = true
Var now =-curIndex * boxHeight
$(".page") .eq (curIndex) .addClass ("current") .siblings (".page") .removeClass ("current")
$(".page-nav I") .eq (curIndex) .addClass ("current") .siblings ("I") .removeClass ("current")
(".main") .animate ({
Top: now + "px"
}, 1000 times function () {
OnScroll = false
});
}
$(".doc") .css ("height", boxHeight)
$(".main") .css ("height", boxHeight * len)
(".page") .css ("height", boxHeight)
$(".doc") .addClass ("done")
Var pageNext = function () {
If (curIndex = = len-1) return
CurIndex++
ToPage (curIndex)
}
Var pagePrev = function () {
If (curIndex = = 0) return
CurIndex--
ToPage (curIndex)
}
(".doc") .on ("mousewheel", function (e, I) {
If (onScroll) return
If (I <-.2) {
/ / Scroll down
PageNext ()
} else {
/ / scroll up
PagePrev ()
}
});
$('.nextPage') .on ('click',function () {
If (onScroll) return
PageNext ()
});
$('.page-nav i') .on (' click',function () {
If (onScroll) return
Var index = $(this) .index ()
ToPage (index)
})
});
Thank you for reading, the above is the content of "jQuery how to achieve full-screen scrolling effect similar to fullpage plug-in". After the study of this article, I believe you have a deeper understanding of how jQuery achieves full-screen scrolling effect similar to fullpage plug-in, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.