/** * https://github.com/kowsar89/jquery.ripples */ !function(){"use strict";var e,t=jQuery,r=t(window);function i(e){return"%"==e[e.length-1]}function o(t,r,i){function o(t,r){var i=e.createShader(t);if(e.shaderSource(i,r),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS))throw new Error("compile error: "+e.getShaderInfoLog(i));return i}var n={};if(n.id=e.createProgram(),e.attachShader(n.id,o(e.VERTEX_SHADER,t)),e.attachShader(n.id,o(e.FRAGMENT_SHADER,r)),e.linkProgram(n.id),!e.getProgramParameter(n.id,e.LINK_STATUS))throw new Error("link error: "+e.getProgramInfoLog(n.id));n.uniforms={},n.locations={},e.useProgram(n.id),e.enableVertexAttribArray(0);for(var a,s,u=/uniform (\w+) (\w+)/g,h=t+r;null!=(a=u.exec(h));)s=a[2],n.locations[s]=e.getUniformLocation(n.id,s);return n}function n(t,r){e.activeTexture(e.TEXTURE0+(r||0)),e.bindTexture(e.TEXTURE_2D,t)}function a(e){var t=/url\(["']?([^"']*)["']?\)/.exec(e);return null==t?null:t[1]}var s=function(){var t=document.createElement("canvas");if(!(e=t.getContext("webgl")||t.getContext("experimental-webgl")))return null;var r={};if(["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear"].forEach(function(t){var i=e.getExtension(t);i&&(r[t]=i)}),!r.OES_texture_float)return null;var i=[];function o(e,t,i){var o="OES_texture_"+e,n=o+"_linear",a=n in r,s=[o];return a&&s.push(n),{type:t,arrayType:i,linearSupport:a,extensions:s}}i.push(o("float",e.FLOAT,Float32Array)),r.OES_texture_half_float&&i.push(o("half_float",r.OES_texture_half_float.HALF_FLOAT_OES,null));var n=e.createTexture(),a=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,a),e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);for(var s=null,u=0;u.jquery-ripples { position: relative; z-index: 0; }");var h=function(r,i){var o=this;this.$el=t(r),this.interactive=i.interactive,this.resolution=i.resolution,this.textureDelta=new Float32Array([1/this.resolution,1/this.resolution]),this.perturbance=i.perturbance,this.dropRadius=i.dropRadius,this.crossOrigin=i.crossOrigin,this.imageUrl=i.imageUrl;var n=document.createElement("canvas");n.width=this.$el.innerWidth(),n.height=this.$el.innerHeight(),this.canvas=n,this.$canvas=t(n),this.$canvas.css({position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1}),this.$el.addClass("jquery-ripples").append(n),this.context=e=n.getContext("webgl")||n.getContext("experimental-webgl"),s.extensions.forEach(function(t){e.getExtension(t)}),t(window).on("resize",function(){o.updateSize()}),this.textures=[],this.framebuffers=[],this.bufferWriteIndex=0,this.bufferReadIndex=1;for(var a=s.arrayType,u=a?new a(this.resolution*this.resolution*4):null,h=0;h<2;h++){var c=e.createTexture(),d=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,d),e.bindTexture(e.TEXTURE_2D,c),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,s.linearSupport?e.LINEAR:e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,s.linearSupport?e.LINEAR:e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.resolution,this.resolution,0,e.RGBA,s.type,u),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,c,0),this.textures.push(c),this.framebuffers.push(d)}this.quad=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.quad),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),e.STATIC_DRAW),this.initShaders(),this.initTexture(),this.setTransparentTexture(),this.loadImage(),e.clearColor(0,0,0,0),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),this.visible=!0,this.running=!0,this.inited=!0,this.destroyed=!1,this.setupPointerEvents(),requestAnimationFrame(function e(){o.destroyed||(o.step(),requestAnimationFrame(e))})};h.DEFAULTS={imageUrl:null,resolution:256,dropRadius:20,perturbance:.03,interactive:!0,crossOrigin:""},h.prototype={setupPointerEvents:function(){var e=this;function t(t,r){e.visible&&e.running&&e.interactive&&e.dropAtPointer(t,e.dropRadius*(r?1.5:1),r?.14:.01)}this.$el.on("mousemove.ripples",function(e){t(e)}).on("touchmove.ripples, touchstart.ripples",function(e){for(var r=e.originalEvent.changedTouches,i=0;i1?Array.prototype.slice.call(arguments,1):void 0;return this.each(function(){var i=t(this),o=i.data("ripples"),n=t.extend({},h.DEFAULTS,i.data(),"object"==typeof e&&e);(o||"string"!=typeof e)&&(o?"string"==typeof e&&h.prototype[e].apply(o,r):i.data("ripples",o=new h(this,n)))})},t.fn.ripples.Constructor=h,t.fn.ripples.noConflict=function(){return t.fn.ripples=c,this}}();