Today I released a JavaScript module/jQuery plugin I’ve been working on over the last few days. Most Visible is used to reduce a set of elements to the one which is most visible within the viewport. The simplest way to use it is as a jQuery plugin like so:
$(function() {
$('.elements').mostVisible().addClass('active');
});
Package Managers
It’s available for installation via yarn or NPM:
yarn add most-visible
npm install most-visible --save
CDN
If you’re not a package manager type of person (you should be) you can include the file directly into your page courtesy of unpkg.com:
<script src="https://unpkg.com/most-visible@latest/dist/most-visible.js"></script>
<script src="https://unpkg.com/most-visible@latest/dist/most-visible.min.js"></script>
Direct Download
If you’re really old fashioned and don’t want to use a package manager or a CDN there are also direct download links:
most-visible.js (3.8KB, 1.4KB gzipped)
most-visible.min.js (1.4KB, 663B gzipped)
For docs, demos and information on the different ways you can use the module check out the project’s GitHub page.