mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* df-visible: Fourth argument Newer version of jquery-visible adds a fourth argument to the jQuery extended method. * df-visible: added fourth argument test
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
// https://github.com/customd/jquery-visible/blob/master/examples/demo-basic.html
|
|
$(function(){
|
|
|
|
// Add the spans to the container element.
|
|
$('#container dt').each(function(){ $(this).append('<span></span>'); });
|
|
|
|
// Trigger the
|
|
$('#detect').on('click',function(){
|
|
|
|
// Select the detection type.
|
|
var detectPartial = $('#detect_type').val() == 'partial';
|
|
|
|
// Loop over each container, and check if it's visible.
|
|
$('#container dt').each(function(){
|
|
|
|
// Is this element visible onscreen?
|
|
var visible = $(this).visible( detectPartial );
|
|
|
|
// Set the visible status into the span.
|
|
$(this).find('span').text( visible ? 'Onscreen' : 'Offscreen' ).toggleClass('visible',visible);
|
|
});
|
|
});
|
|
});
|
|
|
|
// https://www.customd.com/articles/13/checking-if-an-element-is-visible-on-screen-using-jquery
|
|
// Check both vertical, and horizontal at once
|
|
$('#element').visible(true, false, 'both');
|
|
|
|
// Check only horizontal
|
|
$('#element').visible(true, false, 'horizontal');
|
|
|
|
// Check only vertical
|
|
$('#element').visible(true, false, 'vertical');
|
|
|
|
// Check container
|
|
$('#element').visible(true, false, 'horizontal', $('body'))
|