Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //EXECUTES ONLY ONCE
- function once(fn, context) {
- var result;
- return function() {
- if(fn) {
- result = fn.apply(context || this, arguments);
- fn = null;
- }
- return result;
- };
- }
- // Usage
- var split1 = once(function() {
- fadeInText(".split1");
- });
- var pl = once(function() {
- fadeInText(".pl");
- });
- var pl1 = once(function() {
- fadeInText(".pl1");
- });
- var smallp = once(function() {
- fadeInText(".smallp");
- });
- var smallp1 = once(function() {
- fadeInText(".smallp1");
- });
- var smallp2 = once(function() {
- fadeInText(".smallp2");
- });
- var smallp3 = once(function() {
- fadeInText(".smallp3");
- });
- var head0 = once(function() {
- fadeInText(".head0");
- });
- $(window).scroll(function() {
- if( $(this).scrollTop() + $(window).height() > $(".split1").offset().top) {
- split1();
- }
- if( $(this).scrollTop() + $(window).height() > $(".pl").offset().top) {
- pl();
- }
- if( $(this).scrollTop() + $(window).height() > $(".pl1").offset().top) {
- pl1();
- }
- if( $(this).scrollTop() + $(window).height() > $(".smallp").offset().top) {
- smallp();
- }
- if( $(this).scrollTop() + $(window).height() > $(".smallp1").offset().top) {
- smallp1();
- }
- if( $(this).scrollTop() + $(window).height() > $(".smallp2").offset().top) {
- smallp2();
- }
- if( $(this).scrollTop() + $(window).height() > $(".smallp3").offset().top) {
- smallp3();
- }
- if( $(this).scrollTop() + $(window).height() > $(".head0").offset().top) {
- head0();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement