javascript - Loading jQuery script and getting TypeError: $.fn.appear.run is not a function -
i've loaded animation script css markup, i'm getting following error:
typeerror: $.fn.appear.run not function
anyone have ideas why , how can sort that?
/* * css3 animate * copyright (c) 2014 jack mccourt * https://github.com/kriegar/css3-animate-it * version: 0.1.0 * * utilise jquery.appear plugin within javascript file here link * https://github.com/morr/jquery.appear * * utilise jquery.dotimeout plugin data-sequence functionality here link them. * http://benalman.com/projects/jquery-dotimeout-plugin/ */ (function($) { var selectors = []; var check_binded = false; var check_lock = false; var defaults = { interval: 250, force_process: false } var $window = $(window); var $prior_appeared; function process() { check_lock = false; (var index = 0; index < selectors.length; index++) { var $appeared = $(selectors[index]).filter(function() { return $(this).is(':appeared'); }); $appeared.trigger('appear', [$appeared]); if ($prior_appeared) { var $disappeared = $prior_appeared.not($appeared); $disappeared.trigger('disappear', [$disappeared]); } $prior_appeared = $appeared; } } // "appeared" custom filter $.expr[':']['appeared'] = function(element) { var $element = $(element); if (!$element.is(':visible')) { return false; } var window_left = $window.scrollleft(); var window_top = $window.scrolltop(); var offset = $element.offset(); var left = offset.left; var top = offset.top; if (top + $element.height() >= window_top && top - ($element.data('appear-top-offset') || 0) <= window_top + $window.height() && left + $element.width() >= window_left && left - ($element.data('appear-left-offset') || 0) <= window_left + $window.width()) { return true; } else { return false; } } jquery.fn.extend({ // watching element's appearance in browser viewport appear: function(options) { var opts = $.extend({}, defaults, options || {}); var selector = this.selector || this; if (!check_binded) { var on_check = function() { if (check_lock) { return; } check_lock = true; settimeout(process, opts.interval); }; $(window).scroll(on_check).resize(on_check); check_binded = true; } if (opts.force_process) { settimeout(process, opts.interval); } selectors.push(selector); return $(selector); } }); $.extend({ // force elements's appearance check force_appear: function() { if (check_binded) { process(); return true; }; return false; } }); })(jquery); /*! * jquery dotimeout: settimeout, better! - v1.0 - 3/3/2010 * http://benalman.com/projects/jquery-dotimeout-plugin/ * * copyright (c) 2010 "cowboy" ben alman * dual licensed under mit , gpl licenses. * http://benalman.com/about/license/ */ // script: jquery dotimeout: settimeout, better! // // *version: 1.0, last updated: 3/3/2010* // // project home - http://benalman.com/projects/jquery-dotimeout-plugin/ // github - http://github.com/cowboy/jquery-dotimeout/ // source - http://github.com/cowboy/jquery-dotimeout/raw/master/jquery.ba-dotimeout.js // (minified) - http://github.com/cowboy/jquery-dotimeout/raw/master/jquery.ba-dotimeout.min.js (1.0kb) // // about: license // // copyright (c) 2010 "cowboy" ben alman, // dual licensed under mit , gpl licenses. // http://benalman.com/about/license/ // // about: examples // // these working examples, complete commented code, illustrate few // ways in plugin can used. // // debouncing - http://benalman.com/code/projects/jquery-dotimeout/examples/debouncing/ // delays, polling - http://benalman.com/code/projects/jquery-dotimeout/examples/delay-poll/ // hover intent - http://benalman.com/code/projects/jquery-dotimeout/examples/hoverintent/ // // about: support , testing // // information version or versions of jquery plugin has been // tested with, browsers has been tested in, , unit tests // reside (so can test yourself). // // jquery versions - 1.3.2, 1.4.2 // browsers tested - internet explorer 6-8, firefox 2-3.6, safari 3-4, chrome 4-5, opera 9.6-10.1. // unit tests - http://benalman.com/code/projects/jquery-dotimeout/unit/ // // about: release history // // 1.0 - (3/3/2010) callback can string, in case call // appropriate $.method or $.fn.method, depending on .dotimeout // called. callback must return `true` (not truthy value) // poll. // 0.4 - (7/15/2009) made "id" argument optional, other minor tweaks // 0.3 - (6/25/2009) initial release (function($){ '$:nomunge'; // used yui compressor. var cache = {}, // reused internal string. dotimeout = 'dotimeout', // convenient shortcut. aps = array.prototype.slice; // method: jquery.dotimeout // // initialize, cancel, or force execution of callback after delay. // // if delay , callback specified, dotimeout initialized. // callback execute, asynchronously, after delay. if id // specified, dotimeout override , cancel existing dotimeout // same id. additional arguments passed callback // when executed. // // if callback returns true, dotimeout loop execute again, after // delay, creating polling loop until callback returns non-true // value. // // note if id not passed first argument, dotimeout // not able manually canceled or forced. (for debouncing, sure // specify id). // // if id specified, delay , callback not, dotimeout // canceled without executing callback. if force_mode specified, // callback executed, synchronously, allowed // continue polling loop if force_mode true (provided callback // returns true, of course). if force_mode false, no polling loop // continue, if callback returns true. // // usage: // // > jquery.dotimeout( [ id, ] delay, callback [, arg ... ] ); // > jquery.dotimeout( id [, force_mode ] ); // // arguments: // // id - (string) optional unique identifier dotimeout. if id // not specified, dotimeout not able manually canceled or // forced. // delay - (number) zero-or-greater delay in milliseconds after // callback executed. // callback - (function) function executed after delay milliseconds. // callback - (string) jquery method executed after delay // milliseconds. method poll if explicitly returns // true. // force_mode - (boolean) if true, execute id's dotimeout callback // , synchronously, continuing callback return-true // polling loop. if false, execute callback , // synchronously not continue callback return-true polling loop. // if omitted, cancel id's dotimeout. // // returns: // // if force_mode true, false or undefined , there // yet-to-be-executed callback cancel, true returned, if no // callback remains executed, undefined returned. $[dotimeout] = function() { return p_dotimeout.apply( window, [ 0 ].concat( aps.call( arguments ) ) ); }; // method: jquery.fn.dotimeout // // initialize, cancel, or force execution of callback after delay. // operates <jquery.dotimeout>, passed callback executes in // context of jquery collection of elements, , id stored data // on first element in collection. // // if delay , callback specified, dotimeout initialized. // callback execute, asynchronously, after delay. if id // specified, dotimeout override , cancel existing dotimeout // same id. additional arguments passed callback // when executed. // // if callback returns true, dotimeout loop execute again, after // delay, creating polling loop until callback returns non-true // value. // // note if id not passed first argument, dotimeout // not able manually canceled or forced (for debouncing, sure // specify id). // // if id specified, delay , callback not, dotimeout // canceled without executing callback. if force_mode specified, // callback executed, synchronously, allowed // continue polling loop if force_mode true (provided callback // returns true, of course). if force_mode false, no polling loop // continue, if callback returns true. // // usage: // // > jquery('selector').dotimeout( [ id, ] delay, callback [, arg ... ] ); // > jquery('selector').dotimeout( id [, force_mode ] ); // // arguments: // // id - (string) optional unique identifier dotimeout, stored // jquery data on element. if id not specified, dotimeout // not able manually canceled or forced. // delay - (number) zero-or-greater delay in milliseconds after // callback executed. // callback - (function) function executed after delay milliseconds. // callback - (string) jquery.fn method executed after delay // milliseconds. method poll if explicitly returns // true (most jquery.fn methods return jquery object, , not `true`, // allows them chained , prevents polling). // force_mode - (boolean) if true, execute id's dotimeout callback // , synchronously, continuing callback return-true // polling loop. if false, execute callback , // synchronously not continue callback return-true polling loop. // if omitted, cancel id's dotimeout. // // returns: // // when creating <jquery.fn.dotimeout>, initial jquery collection of // elements returned. otherwise, if force_mode true, false or undefined // , there yet-to-be-executed callback cancel, true returned, // if no callback remains executed, undefined returned. $.fn[dotimeout] = function() { var args = aps.call( arguments ), result = p_dotimeout.apply( this, [ dotimeout + args[0] ].concat( args ) ); return typeof args[0] === 'number' || typeof args[1] === 'number' ? : result; }; function p_dotimeout( jquery_data_key ) { var = this, elem, data = {}, // allows plugin call string callback method. method_base = jquery_data_key ? $.fn : $, // additional arguments passed callback. args = arguments, slice_args = 4, id = args[1], delay = args[2], callback = args[3]; if ( typeof id !== 'string' ) { slice_args--; id = jquery_data_key = 0; delay = args[1]; callback = args[2]; } // if id passed, store data reference either .data on first // element in jquery collection, or in internal cache. if ( jquery_data_key ) { // note: key 'dotimeout' + id // id-object first element's data, otherwise initialize {}. elem = that.eq(0); elem.data( jquery_data_key, data = elem.data( jquery_data_key ) || {} ); } else if ( id ) { // id-object cache, otherwise initialize {}. data = cache[ id ] || ( cache[ id ] = {} ); } // clear existing timeout id. data.id && cleartimeout( data.id ); delete data.id; // clean when necessary. function cleanup() { if ( jquery_data_key ) { elem.removedata( jquery_data_key ); } else if ( id ) { delete cache[ id ]; } }; // yes, there settimeout call in here! function actually_settimeout() { data.id = settimeout( function(){ data.fn(); }, delay ); }; if ( callback ) { // callback (and delay) specified. store callback reference // possible later use, , settimeout. data.fn = function( no_polling_loop ) { // if callback value string, assumed name of // method on $ or $.fn depending on dotimeout executed. if ( typeof callback === 'string' ) { callback = method_base[ callback ]; } callback.apply( that, aps.call( args, slice_args ) ) === true && !no_polling_loop // since callback returned true, , we're not // canceling polling loop, again! ? actually_settimeout() // otherwise, clean , quit. : cleanup(); }; // set timeout! actually_settimeout(); } else if ( data.fn ) { // no callback passed. if force_mode (delay) true, execute data.fn // callback immediately, continuing callback return-true polling loop. // if force_mode false, execute data.fn callback // not continue callback return-true polling loop. if force_mode // undefined, clean up. since data.fn still defined, whatever // supposed happen hadn't yet, return true. delay === undefined ? cleanup() : data.fn( delay === false ); return true; } else { // since no callback passed, , data.fn isn't defined, looks // whatever supposed happen did. clean , quit! cleanup(); } }; })(jquery); //css3 animate-it $('.animatedparent').appear(); $('.animatedclick').click(function(){ var target = $(this).attr('data-target'); if($(this).attr('data-sequence') != undefined){ var firstid = $("."+target+":first").attr('data-id'); var lastid = $("."+target+":last").attr('data-id'); var number = firstid; //add or remove class if($("."+target+"[data-id="+ number +"]").hasclass('go')){ $("."+target+"[data-id="+ number +"]").addclass('goaway'); $("."+target+"[data-id="+ number +"]").removeclass('go'); }else{ $("."+target+"[data-id="+ number +"]").addclass('go'); $("."+target+"[data-id="+ number +"]").removeclass('goaway'); } number ++; delay = number($(this).attr('data-sequence')); $.dotimeout(delay, function(){ console.log(lastid); //add or remove class if($("."+target+"[data-id="+ number +"]").hasclass('go')){ $("."+target+"[data-id="+ number +"]").addclass('goaway'); $("."+target+"[data-id="+ number +"]").removeclass('go'); }else{ $("."+target+"[data-id="+ number +"]").addclass('go'); $("."+target+"[data-id="+ number +"]").removeclass('goaway'); } //increment ++number; //continute looping till reached last id if(number <= lastid){return true;} }); }else{ if($('.'+target).hasclass('go')){ $('.'+target).addclass('goaway'); $('.'+target).removeclass('go'); }else{ $('.'+target).addclass('go'); $('.'+target).removeclass('goaway'); } } }); $(document.body).on('appear', '.animatedparent', function(e, $affected){ var ele = $(this).find('.animated'); var parent = $(this); if(parent.attr('data-sequence') != undefined){ var firstid = $(this).find('.animated:first').attr('data-id'); var number = firstid; var lastid = $(this).find('.animated:last').attr('data-id'); $(parent).find(".animated[data-id="+ number +"]").addclass('go'); number ++; delay = number(parent.attr('data-sequence')); $.dotimeout(delay, function(){ $(parent).find(".animated[data-id="+ number +"]").addclass('go'); ++number; if(number <= lastid){return true;} }); }else{ ele.addclass('go'); } }); $(document.body).on('disappear', '.animatedparent', function(e, $affected) { if(!$(this).hasclass('animateonce')){ $(this).find('.animated').removeclass('go'); } }); $(window).load(function(){ $.force_appear(); });
are using "appear" jquery plugin? if how should this:
$('.animatedparent').appear(function(e, $affected){ var ele = $(this).find('.animated'); var parent = $(this); if(parent.attr('data-sequence') != undefined){ var firstid = $(this).find('.animated:first').attr('data-id'); var number = firstid; var lastid = $(this).find('.animated:last').attr('data-id'); $(parent).find(".animated[data-id="+ number +"]").addclass('go'); number ++; delay = number(parent.attr('data-sequence')); $.dotimeout(delay, function(){ $(parent).find(".animated[data-id="+ number +"]").addclass('go'); ++number; if(number <= lastid){return true;} }); }else{ ele.addclass('go'); } });
Comments
Post a Comment