1/*! 2 * Revealer 2.0.0 3 * 4 * Copyright 2015, Pixel Union - http://pixelunion.net 5 * Released under the MIT license 6 */ 7(function($){ 8 // check for trend event (make sure jquery.trend is included) 9 if (typeof $.event.special.trend !== "object") { 10 console.warn("Please make sure jquery.trend is included! Otherwise revealer won't work."); 11 } 12 13 // Simple requestAnimationFrame polyfill 14 var raf = window.requestAnimationFrame || 15 window.mozRequestAnimationFrame || 16 window.webkitRequestAnimationFrame || 17 function(fn) { window.setTimeout(fn, 1000/60); } 18 19 20 // Public API 21 var methods = { 22 isVisible: function(el) { 23 return !!el.data("revealer-visible"); 24 }, 25 26 show: function(el, force) { 27 // Check state 28 if (methods.isVisible(el)) { 29 el.removeClass("animating animating-in"); 30 el.off("revealer-animating revealer-show"); 31 return; 32 } 33 34 // Remove previous event listeners 35 el.data("revealer-visible", true); 36 el.off("trend"); 37 38 if (force) { 39 el.addClass("visible"); 40 el.trigger("revealer-show"); 41 return; 42 } 43 44 raf(function(){ 45 // Start animation state transition 46 el.addClass("animating animating-in"); 47 el.trigger("revealer-animating"); 48 49 raf(function(){ 50 el.addClass("visible"); 51 52 el.one("trend", function(){ 53 el.removeClass("animating animating-in"); 54 el.trigger("revealer-show"); 55 }); 56 }); 57 }); 58 }, 59 60 hide: function(el, force) { 61 // Check state 62 if (!methods.isVisible(el)) { 63 el.removeClass("animating animating-out visible"); 64 el.off("revealer-animating revealer-hide"); 65 return; 66 } 67 68 // Remove previous event listeners 69 el.data("revealer-visible", false); 70 el.off("trend"); 71 72 if (force) { 73 el.removeClass("visible"); 74 el.trigger("revealer-hide"); 75 return; 76 } 77 78 raf(function(){ 79 el.addClass("animating animating-out"); 80 el.trigger("revealer-animating"); 81 82 raf(function(){ 83 el.removeClass("visible"); 84 85 el.one("trend", function(){ 86 el.removeClass("animating animating-in animating-out"); 87 el.trigger("revealer-hide"); 88 }); 89 }); 90 }); 91 }, 92 93 toggle: function(el, force) { 94 if (methods.isVisible(el)) { 95 methods.hide(el, force); 96 } else { 97 methods.show(el, force); 98 } 99 } 100 }; 101 102 // jQuery plugin 103 $.fn.revealer = function(method, force) { 104 // Get action 105 var action = methods[method || "toggle"]; 106 if (!action) return this; 107 108 // Run action 109 if (method === "isVisible") { 110 return action(this); 111 } 112 113 return this.each(function(){ 114 action($(this), force); 115 }); 116 }; 117})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.