Comparing version 4.0.0-rc3 to 4.0.0-rc4
@@ -1,1 +0,1 @@ | ||
module.exports=function(t){function e(n){if(o[n])return o[n].exports;var i=o[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e,o){"use strict";var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},i=o(4),r=0,s=o(5),a=o(7),u=o(2),c=o(6),l=a.PropTypes,h=2*Math.PI,p=o(1),f=a.createClass({displayName:"Ink",shouldComponentUpdate:function(t,e){for(var o in t)if(this.props[o]!==t[o])return!0;for(var n in e)if(this.state[n]!==e[n])return!0;return!1},propTypes:{background:l.bool,duration:l.number,opacity:l.number,radius:l.number,recenter:l.bool},getDefaultProps:function(){return{background:!0,duration:1500,opacity:.2,radius:150,recenter:!0}},getInitialState:function(){return{store:c(this.tick),touchEvents:this.touchEvents()}},touchEvents:function(){return i?{onTouchStart:this._onPress,onTouchEnd:this._onRelease,onTouchCancel:this._onRelease,onTouchLeave:this._onRelease}:{onMouseDown:this._onPress,onMouseUp:this._onRelease,onMouseLeave:this._onRelease}},tick:function(){var t=this.state.ctx,e=this.state.color,o=this.state.height,n=this.state.width,i=this.state.store,r=s(t);t.save(),t.scale(r,r),t.clearRect(0,0,n,o),t.fillStyle=e,t.globalAlpha=i.getTotalOpacity(),t.fillRect(0,0,n,o),i.map(this.makeBlot,this),t.restore()},makeBlot:function(t){var e=this.state.ctx,o=this.state.height,n=this.state.width,i=t.x,r=t.y,s=t.radius;if(e.save(),e.globalAlpha=p.getBlotOpacity(t),e.beginPath(),this.props.recenter){var a=Math.max(o,n);e.translate(p.getBlotShiftX(t,a,n),p.getBlotShiftY(t,a,o))}e.arc(i,r,s*p.getBlotScale(t),0,h),e.closePath(),e.fill(),e.restore()},componentWillUnmount:function(){this.state.store.stop()},pushBlot:function(t,e,o){var n=this,i=this.getDOMNode(),r=window.getComputedStyle(i),s=i.getBoundingClientRect(),a=s.top,u=s.bottom,c=s.left,l=s.right,h=u-a,p=l-c;this.setState({color:r.color,ctx:this.state.ctx||this.refs.canvas.getDOMNode().getContext("2d"),height:h,width:p},function(){n.state.store.add({duration:n.props.duration,opacity:n.props.opacity,mouseDown:t,mouseUp:0,radius:Math.min(Math.max(p,h),n.props.radius),x:e-c,y:o-a})})},popBlot:function(t){this.state.store.release(t)},render:function(){var t=this.state.height,e=this.state.width,o=this.state.touchEvents,i=window.devicePixelRatio||1;return a.createElement("canvas",n({ref:"canvas",className:"ink",style:n({},u,this.props.style),height:t*i,width:e*i,onDragOver:this._onRelease},o))},_onPress:function(t){var e=t.button,o=t.ctrlKey,n=t.clientX,i=t.clientY,s=t.changedTouches,a=Date.now();if(s)for(var u=0;u<s.length;u++){var c=s[u].clientX,l=s[u].clientY;this.pushBlot(a,c,l)}else e!==r||o||this.pushBlot(a,n,i)},_onRelease:function(){this.popBlot(Date.now())}});t.exports=f},function(t,e,o){"use strict";function n(t){return a(t.duration,Date.now()-t.mouseDown)}function i(t){return t.mouseUp>0?Date.now()-t.mouseUp:0}function r(t){var e=.85*s(n(t),0,t.radius,t.duration),o=.15*s(i(t),0,t.radius,t.duration);return e+o}var s=o(3),a=Math.min,u=Math.sqrt(2);t.exports={getBlotOpacity:function(t){return s(i(t),t.opacity,-t.opacity,t.duration)},getBlotOuterOpacity:function(t){return a(this.getBlotOpacity(t),s(n(t),0,.3,3*t.duration))},getBlotShiftX:function(t,e,o){return a(1,r(t)/e*2/u)*(o/2-t.x)},getBlotShiftY:function(t,e,o){return a(1,r(t)/e*2/u)*(o/2-t.y)},getBlotScale:function(t){return r(t)/t.radius}}},function(t){"use strict";t.exports={borderRadius:"inherit",height:"100%",left:0,position:"absolute",top:0,width:"100%"}},function(t){"use strict";t.exports=function(t,e,o,n){return o*((t=t/n-1)*t*t*t*t+1)+e}},function(t){"use strict";var e=!1;"undefined"!=typeof window&&(e="ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch),t.exports=e},function(t){"use strict";t.exports=function(t){var e=window.devicePixelRatio||1,o=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return e/o}},function(t,e,o){"use strict";var n=o(1);t.exports=function(t){var e=[],o=!1,i=void 0,r={map:function(t,o){return e.map(t,o)},play:function(){o||(o=!0,r.update())},stop:function(){o=!1,cancelAnimationFrame(i)},getTotalOpacity:function(){return e.reduce(function(t,e){return t+n.getBlotOuterOpacity(e)},0)},update:function(){r.prune(),t(i),e.length?i=requestAnimationFrame(r.update):r.stop()},shouldPrune:function(t){return n.getBlotOpacity(t)>.01},prune:function(){e=e.filter(this.shouldPrune)},add:function(t){e.push(t),r.play()},release:function(t){for(var o=e.length-1;o>=0;o--)if(!e[o].mouseUp)return e[o].mouseUp=t}};return r}},function(t){t.exports=require("react")}]); | ||
module.exports=function(t){function e(n){if(o[n])return o[n].exports;var i=o[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e,o){(function(e){"use strict";var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},i=o(4),r=0,s=o(5),a=o(7),u=o(2),c=o(6),l=a.PropTypes,h=2*Math.PI,p=o(1),f=a.createClass({displayName:"Ink",shouldComponentUpdate:function(t,e){for(var o in t)if(this.props[o]!==t[o])return!0;for(var n in e)if(this.state[n]!==e[n])return!0;return!1},propTypes:{background:l.bool,duration:l.number,opacity:l.number,radius:l.number,recenter:l.bool},getDefaultProps:function(){return{background:!0,duration:1500,opacity:.2,radius:150,recenter:!0}},getInitialState:function(){return{store:c(this.tick),touchEvents:this.touchEvents()}},touchEvents:function(){return i?{onTouchStart:this._onPress,onTouchEnd:this._onRelease,onTouchCancel:this._onRelease,onTouchLeave:this._onRelease}:{onMouseDown:this._onPress,onMouseUp:this._onRelease,onMouseLeave:this._onRelease}},tick:function(){var t=this.state.ctx,e=this.state.color,o=this.state.height,n=this.state.width,i=this.state.store,r=s(t);t.save(),t.scale(r,r),t.clearRect(0,0,n,o),t.fillStyle=e,t.globalAlpha=i.getTotalOpacity(),t.fillRect(0,0,n,o),i.map(this.makeBlot,this),t.restore()},makeBlot:function(t){var e=this.state.ctx,o=this.state.height,n=this.state.width,i=t.x,r=t.y,s=t.radius;if(e.save(),e.globalAlpha=p.getBlotOpacity(t),e.beginPath(),this.props.recenter){var a=Math.max(o,n);e.translate(p.getBlotShiftX(t,a,n),p.getBlotShiftY(t,a,o))}e.arc(i,r,s*p.getBlotScale(t),0,h),e.closePath(),e.fill(),e.restore()},componentWillUnmount:function(){this.state.store.stop()},pushBlot:function(t,e,o){var n=this,i=this.getDOMNode(),r=window.getComputedStyle(i),s=i.getBoundingClientRect(),a=s.top,u=s.bottom,c=s.left,l=s.right,h=u-a,p=l-c;this.setState({color:r.color,ctx:this.state.ctx||this.refs.canvas.getDOMNode().getContext("2d"),height:h,width:p},function(){n.state.store.add({duration:n.props.duration,opacity:n.props.opacity,mouseDown:t,mouseUp:0,radius:Math.min(Math.max(p,h),n.props.radius),x:e-c,y:o-a})})},popBlot:function(t){this.state.store.release(t)},render:function(){var t=this.state.height,o=this.state.width,i=this.state.touchEvents,r=e.devicePixelRatio||1;return a.createElement("canvas",n({ref:"canvas",className:"ink",style:n({},u,this.props.style),height:t*r,width:o*r,onDragOver:this._onRelease},i))},_onPress:function(t){var e=t.button,o=t.ctrlKey,n=t.clientX,i=t.clientY,s=t.changedTouches,a=Date.now();if(s)for(var u=0;u<s.length;u++){var c=s[u].clientX,l=s[u].clientY;this.pushBlot(a,c,l)}else e!==r||o||this.pushBlot(a,n,i)},_onRelease:function(){this.popBlot(Date.now())}});t.exports=f}).call(e,function(){return this}())},function(t,e,o){"use strict";function n(t){return a(t.duration,Date.now()-t.mouseDown)}function i(t){return t.mouseUp>0?Date.now()-t.mouseUp:0}function r(t){var e=.85*s(n(t),0,t.radius,t.duration),o=.15*s(i(t),0,t.radius,t.duration);return e+o}var s=o(3),a=Math.min,u=Math.sqrt(2);t.exports={getBlotOpacity:function(t){return s(i(t),t.opacity,-t.opacity,t.duration)},getBlotOuterOpacity:function(t){return a(this.getBlotOpacity(t),s(n(t),0,.3,3*t.duration))},getBlotShiftX:function(t,e,o){return a(1,r(t)/e*2/u)*(o/2-t.x)},getBlotShiftY:function(t,e,o){return a(1,r(t)/e*2/u)*(o/2-t.y)},getBlotScale:function(t){return r(t)/t.radius}}},function(t){"use strict";t.exports={borderRadius:"inherit",height:"100%",left:0,position:"absolute",top:0,width:"100%"}},function(t){"use strict";t.exports=function(t,e,o,n){return o*((t=t/n-1)*t*t*t*t+1)+e}},function(t){"use strict";var e=!1;"undefined"!=typeof window&&(e="ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch),t.exports=e},function(t){"use strict";t.exports=function(t){var e=window.devicePixelRatio||1,o=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return e/o}},function(t,e,o){"use strict";var n=o(1);t.exports=function(t){var e=[],o=!1,i=void 0,r={map:function(t,o){return e.map(t,o)},play:function(){o||(o=!0,r.update())},stop:function(){o=!1,cancelAnimationFrame(i)},getTotalOpacity:function(){return e.reduce(function(t,e){return t+n.getBlotOuterOpacity(e)},0)},update:function(){r.prune(),t(i),e.length?i=requestAnimationFrame(r.update):r.stop()},shouldPrune:function(t){return n.getBlotOpacity(t)>.01},prune:function(){e=e.filter(this.shouldPrune)},add:function(t){e.push(t),r.play()},release:function(t){for(var o=e.length-1;o>=0;o--)if(!e[o].mouseUp)return e[o].mouseUp=t}};return r}},function(t){t.exports=require("react")}]); |
{ | ||
"name": "react-ink", | ||
"version": "4.0.0-rc3", | ||
"version": "4.0.0-rc4", | ||
"description": "A React component for adding material design style ink.", | ||
@@ -5,0 +5,0 @@ "main": "dist/ink.js", |
@@ -154,3 +154,3 @@ /** | ||
let ratio = window.devicePixelRatio || 1 | ||
let ratio = global.devicePixelRatio || 1 | ||
@@ -157,0 +157,0 @@ return ( |
17165