jquery implements full screen scrolling_jquery
In many cases, we need full-screen scrolling of the page, especially on mobile. Today I will briefly introduce the knowledge of full-screen scrolling.
1. The principle of full-screen scrolling
1.js dynamically obtains the height of the screen.
Get the height of the screen and set the height of each screen.
2. Listen to mousewheel events.
Listen to the mousewheel event and determine the direction of the wheel to scroll up or down one screen.
2. Introduction to jQuery plug-in fullpages
fullPage.js is a plug-in based on jQuery. It can easily and conveniently create a full-screen website. The main functions are:
- Support mouse scrolling
- Supports forward, backward and keyboard control
- Multiple callback functions
- Support touch events on mobile phones and tablets
- Support CSS3 animation
- Support window scaling
- Automatically adjust when the window is zoomed
- Can set scroll width, background color, scroll speed, loop options, callbacks, text alignment, etc.
How to use
1. Import files
<link rel="stylesheet" href="css/jquery.fullPage.css"> <script src="js/jquery.min.js"></script> <script src="js/jquery.fullPage.js"></script>
2. HTML
<div id="dowebok"> <div class="section"> <h3>第一屏</h3> </div> <div class="section"> <h3>第二屏</h3> </div> <div class="section"> <h3>第三屏</h3> </div> <div class="section"> <h3>第四屏</h3> </div> </div>
Each section represents one screen, and the "first screen" is displayed by default. If you want to specify the "screen" displayed when loading the page, you can add class="active" to the corresponding section, such as:
<div class="section active">第三屏</div>
At the same time, you can add slide (swipe left and right) inside the section, such as:
<div id="fullpages"> <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>
3. JavaScript
$(function(){ $('#fullpages').fullpage(); });
Many configurations can be performed:
$(document).ready(function() { $('#fullpages').fullpage({ //Navigation menu: '#menu', lockAnchors: false, anchors:['firstPage', 'secondPage'], navigation: false, navigationPosition: 'right', navigationTooltips: ['firstSlide', 'secondSlide'], showActiveTooltip: false, slidesNavigation: true, slidesNavPosition: 'bottom', //Scrolling css3: true, scrollingSpeed: 700, autoScrolling: true, fitToSection: true, fitToSectionDelay: 1000, scrollBar: false, easing: 'easeInOutCubic', easingcss3: 'ease', loopBottom: false, loopTop: false, loopHorizontal: true, continuousVertical: false, normalScrollElements: '#element1, .element2', scrollOverflow: false, touchSensitivity: 15, normalScrollElementTouchThreshold: 5, //Accessibility keyboardScrolling: true, animateAnchor: true, recordHistory: true, //Design controlArrows: true, verticalCentered: true, resize : false, sectionsColor : ['#ccc', '#fff'], paddingTop: '3em', paddingBottom: '10px', fixedElements: '#header, .footer', responsiveWidth: 0, responsiveHeight: 0, //Custom selectors sectionSelector: '.section', slideSelector: '.slide', //events onLeave: function(index, nextIndex, direction){}, afterLoad: function(anchorLink, index){}, afterRender: function(){}, afterResize: function(){}, afterSlideLoad: function(anchorLink, index, slideAnchor, slideIndex){}, onSlideLeave: function(anchorLink, index, slideIndex, direction, nextSlideIndex){} }); });
3. Hand-written full-screen scrolling
Here we mainly introduce monitoring mousewheel events and scrolling.
Due to the compatibility of mousewheel events, the jquery-mousewheel plug-in is quoted to listen for wheel events.
The direction and speed of the mouse wheel can be obtained through the parameter delta (the old version needs to pass the delta parameter, the new version does not need to, use event to get it directly). If the value of delta is negative, then the scroll wheel scrolls down, and if the value of delta is positive, it scrolls up.
// using on $('#my_elem').on('mousewheel', function(event) { console.log(event.deltaX, event.deltaY, event.deltaFactor); }); // using the event helper $('#my_elem').mousewheel(function(event) { console.log(event.deltaX, event.deltaY, event.deltaFactor); });
You can use fullpages to achieve full-screen scrolling (up, down, left and right) according to your needs, or you can use jquery-mousewheel to customize full-screen scrolling at different heights.
The above is the entire content of this article, I hope it will be helpful to everyone’s study.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

When working and studying, ppt is often used for presentations. In order to further improve the look and feel, we usually need to make the ppt presentation full screen. So what is the one-click full screen shortcut key for ppt? How to show ppt in full screen? Let’s take a look at the specific tutorials. PPT shortcut keys are one of the most convenient full-screen operation methods. Just open the PPT file you want to display in full screen and press the "F5" key on the keyboard to display the slides in full screen. This one-click full-screen method is very simple. There is no need to waste time on menu options. It can be easily completed through simple keyboard operations. 2. In addition, you can also use other shortcut keys. For example, press the "Shift F5" key to start the show from the current slide; press &

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? 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

1. If it doesn't work, you can press the win+R shortcut key to pop up Run, or click Start in the lower left corner of the computer, find Run on the Start menu, and enter: regedit in Run. 2. After entering the registry editor, select HEKY_LOCAL_MACHINE——SYSTEM——ControlSet001——Control. 3. Then select GraphicsDrevers-configuration. 4. Right-click on the configuration and select Find. 5. Enter [scaling] and click [Find Next]. 6. Right-click scaling and select Modify. 7. Change the numerical data from 4 to 3.

Kuaishou can easily satisfy your own use, so that everyone can immerse themselves in it every day, relieve themselves of boredom, and solve every use, so that everyone can always immerse themselves in it and watch the content they are interested in. Many people like to immerse themselves in it. I don’t want the comment area below, the likes and reposts on the side, etc. I want to watch in full screen and enjoy the ultimate visual feast, which everyone likes very much and is very satisfied. Many people don’t know how to open it here. Watch in full screen, so the editor provides you with a method. Friends who need it can use it immediately, so that you can better enjoy various contents on this platform! 1. Open Kuaishou, log in to your account, click on the three horizontal bars in the upper left corner, 2. Click on the large screen mode in the lower left corner, this

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

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: <

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:
