Home > Web Front-end > JS Tutorial > body text

Detailed explanation of jquery plug-in jquery.viewport.js

小云云
Release: 2017-12-29 09:57:44
Original
1977 people have browsed it

This article mainly introduces the detailed explanation of how to learn and use the jquery plug-in jquery.viewport.js. It has certain reference value. If you are interested, you can learn more

Introduction

Viewport is a simple jQuery plugin that adds custom pseudo-selectors and handlers to elements for simple element detection inside and outside the viewport.

Usage method


<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.viewport.js" type="text/javascript"></script>
Copy after login

Method


$( ":in-viewport" );
$( ":above-the-viewport" );
$( ":below-the-viewport" );
$( ":left-of-viewport" );
$( ":right-of-viewport" );
$( ":partly-above-the-viewport" );
$( ":partly-below-the-viewport" );
$( ":partly-left-of-viewport" );
$( ":partly-right-of-viewport" );
$( ":have-scroll" );
Copy after login

Example

The return button is displayed after the yellow part leaves the screen


##

  var wodBackButton = function () {
    //元素在屏幕左侧显示返回按钮
    $("#wodsHome:left-of-screen").each(function () {
      $(&#39;#wodBackButton&#39;).removeClass(&#39;hide&#39;);
      return;
    });
    //元素在屏幕显示区域隐藏返回按钮
    $("#wodsHome:in-viewport").each(function () {
      $(&#39;#wodBackButton&#39;).addClass(&#39;hide&#39;);
      return;
    });
  }

  $(&#39;#mediaContainer&#39;).bind("scroll", function (event) {
    wodBackButton();
  });

  wodBackButton();
Copy after login

Summary

By using this plug-in, you can easily and conveniently obtain the area of ​​the screen and the area outside the screen area for development.

Related recommendations:


Viewport for screen adaptation in html5 development

Share viewport attributes to solve vertical screen switching on mobile terminals Example of the problem of horizontal screen font being reset

Introduction to the parameters of Viewport in HTML5 and how to use it

The above is the detailed content of Detailed explanation of jquery plug-in jquery.viewport.js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!