GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — javaScript/jQuery-aniview/js/jquery.aniview.js at master · LYShu/javaScript

Expand file tree

/

jquery.aniview.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
83 lines (75 loc) · 3.6 KB
/

jquery.aniview.js

Copy path

File metadata and controls

83 lines (75 loc) · 3.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
(function() {
//custom scroll replacement to allow for interval-based 'polling'
//rathar than checking on every pixel
var uniqueCntr = 0;
$.fn.scrolled = function(waitTime, fn) {
if (typeof waitTime === 'function') {
fn = waitTime;
waitTime = 200;
}
var tag = 'scrollTimer' + uniqueCntr++;
this.scroll(function() {
var self = $(this);
var timer = self.data(tag);
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(function() {
self.removeData(tag);
fn.call(self[0]);
}, waitTime);
self.data(tag, timer);
});
};
$.fn.AniView = function(options) {
//some default settings. animateThreshold controls the trigger point
//for animation and is subtracted from the bottom of the viewport.
var settings = $.extend({
animateThreshold: 0,
scrollPollInterval: 20
}, options);
//keep the matched elements in a variable for easy reference
var collection = this;
//cycle through each matched element and wrap it in a block/div
//and then proceed to fade out the inner contents of each matched element
$(collection).each(function(index, element) {
$(element).wrap('<div class="av-container"></div>');
$(element).css('opacity', 0);
});
/**
* returns boolean representing whether element's top is coming into bottom of viewport
*
* @param HTMLDOMElement element the current element to check
*/
function EnteringViewport(element) {
var elementOffset = $(element).offset();
var elementTop = elementOffset.top + $(element).scrollTop();
var elementBottom = elementOffset.top + $(element).scrollTop() + $(element).height();
var viewportBottom = $(window).scrollTop() + $(window).height();
return (elementTop < (viewportBottom - settings.animateThreshold)) ? true : false;
}
//cycle through each matched element to make sure any which should be animated into view,
//are animated on page load rather than needing to wait for initial 'scrolled' event
$(collection).each(function(index, element) {
var elementParentContainer = $(element).parent('.av-container');
if ($(element).is('[av-animation]') && !$(elementParentContainer).hasClass('av-visible') && EnteringViewport(elementParentContainer)) {
$(element).css('opacity', 1);
$(elementParentContainer).addClass('av-visible');
$(element).addClass('animated ' + $(element).attr('av-animation'));
}
});
//enable the scrolled event timer to watch for elements coming into the viewport
//from the bottom. default polling time is 20 ms. This can be changed using
//'scrollPollInterval' from the user visible options
$(window).scrolled(settings.scrollPollInterval, function() {
$(collection).each(function(index, element) {
var elementParentContainer = $(element).parent('.av-container');
if ($(element).is('[av-animation]') && !$(elementParentContainer).hasClass('av-visible') && EnteringViewport(elementParentContainer)) {
$(element).css('opacity', 1);
$(elementParentContainer).addClass('av-visible');
$(element).addClass('animated ' + $(element).attr('av-animation'));
}
});
});
};
})();
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.