Rebbbound

Developer
Size
6,636 Kb
Views
14,168

How do I make an rebbbound?

Fiddling with the basic demo code from Rebound.js. What is a rebbbound? How do you make a rebbbound? This script and codes were developed by Nobitagit on 05 December 2022, Monday.

Rebbbound Previews

Rebbbound - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Rebbbound</title> <meta charset="utf-8">
<link href='https://fonts.googleapis.com/css?family=Roboto+Slab:400,700' rel='stylesheet' type='text/css'>
<script>
(function(){var k={};var a=k.util={};var d=Array.prototype.concat;var m=Array.prototype.slice;a.bind=function s(u,t){args=m.call(arguments,2);return function(){u.apply(t,d.call(args,m.call(arguments)))}};a.extend=function o(v,u){for(var t in u){if(u.hasOwnProperty(t)){v[t]=u[t]}}};var e=k.SpringSystem=function e(t){this._springRegistry={};this._activeSprings=[];this.listeners=[];this._idleSpringIndices=[];this.looper=t||new g();this.looper.springSystem=this};a.extend(e.prototype,{_springRegistry:null,_isIdle:true,_lastTimeMillis:-1,_activeSprings:null,listeners:null,_idleSpringIndices:null,setLooper:function(t){this.looper=t;t.springSystem=this},createSpring:function(u,w){var t=new i(this);this.registerSpring(t);if(typeof u==="undefined"||typeof w==="undefined"){t.setSpringConfig(c.DEFAULT_ORIGAMI_SPRING_CONFIG)}else{var v=c.fromOrigamiTensionAndFriction(u,w);t.setSpringConfig(v)}return t},getIsIdle:function(){return this._isIdle},getSpringById:function(t){return this._springRegistry[t]},getAllSprings:function(){var t=[];for(var u in this._springRegistry){if(this._springRegistry.hasOwnProperty(u)){t.push(this._springRegistry[u])}}return t},registerSpring:function(t){this._springRegistry[t.getId()]=t},deregisterSpring:function(t){f(this._activeSprings,t);delete this._springRegistry[t.getId()]},advance:function(y,w){while(this._idleSpringIndices.length>0){this._idleSpringIndices.pop()}for(var x=0,u=this._activeSprings.length;x<u;x++){var v=this._activeSprings[x];if(v.systemShouldAdvance()){v.advance(y/1000,w/1000)}else{this._idleSpringIndices.push(this._activeSprings.indexOf(v))}}while(this._idleSpringIndices.length>0){var t=this._idleSpringIndices.pop();t>=0&&this._activeSprings.splice(t,1)}},loop:function(x){var w;if(this._lastTimeMillis===-1){this._lastTimeMillis=x-1}var u=x-this._lastTimeMillis;this._lastTimeMillis=x;var v=0,t=this.listeners.length;for(v=0;v<t;v++){var w=this.listeners[v];w.onBeforeIntegrate&&w.onBeforeIntegrate(this)}this.advance(x,u);if(this._activeSprings.length===0){this._isIdle=true;this._lastTimeMillis=-1}for(v=0;v<t;v++){var w=this.listeners[v];w.onAfterIntegrate&&w.onAfterIntegrate(this)}if(!this._isIdle){this.looper.run()}},activateSpring:function(u){var t=this._springRegistry[u];if(this._activeSprings.indexOf(t)==-1){this._activeSprings.push(t)}if(this.getIsIdle()){this._isIdle=false;this.looper.run()}},addListener:function(t){this.listeners.push(t)},removeListener:function(t){f(this.listeners,t)},removeAllListeners:function(){this.listeners=[]}});var i=k.Spring=function i(t){this._id="s"+i._ID++;this._springSystem=t;this.listeners=[];this._currentState=new p();this._previousState=new p();this._tempState=new p()};a.extend(i,{_ID:0,MAX_DELTA_TIME_SEC:0.064,SOLVER_TIMESTEP_SEC:0.001});a.extend(i.prototype,{_id:0,_springConfig:null,_overshootClampingEnabled:false,_currentState:null,_previousState:null,_tempState:null,_startValue:0,_endValue:0,_wasAtRest:true,_restSpeedThreshold:0.001,_displacementFromRestThreshold:0.001,listeners:null,_timeAccumulator:0,_springSystem:null,destroy:function(){this.listeners=[];this.frames=[];this._springSystem.deregisterSpring(this)},getId:function(){return this._id},setSpringConfig:function(t){this._springConfig=t;return this},getSpringConfig:function(){return this._springConfig},setCurrentValue:function(u,t){this._startValue=u;this._currentState.position=u;if(!t){this.setAtRest()}this.notifyPositionUpdated(false,false);return this},getStartValue:function(){return this._startValue},getCurrentValue:function(){return this._currentState.position},getCurrentDisplacementDistance:function(){return this.getDisplacementDistanceForState(this._currentState)},getDisplacementDistanceForState:function(t){return Math.abs(this._endValue-t.position)},setEndValue:function(u){if(this._endValue==u&&this.isAtRest()){return this}this._startValue=this.getCurrentValue();this._endValue=u;this._springSystem.activateSpring(this.getId());for(var v=0,t=this.listeners.length;v<t;v++){var w=this.listeners[v];w.onSpringEndStateChange&&w.onSpringEndStateChange(this)}return this},getEndValue:function(){return this._endValue},setVelocity:function(t){if(t===this._currentState.velocity){return this}this._currentState.velocity=t;this._springSystem.activateSpring(this.getId());return this},getVelocity:function(){return this._currentState.velocity},setRestSpeedThreshold:function(t){this._restSpeedThreshold=t;return this},getRestSpeedThreshold:function(){return this._restSpeedThreshold},setRestDisplacementThreshold:function(t){this._displacementFromRestThreshold=t},getRestDisplacementThreshold:function(){return this._displacementFromRestThreshold},setOvershootClampingEnabled:function(t){this._overshootClampingEnabled=t;return this},isOvershootClampingEnabled:function(){return this._overshootClampingEnabled},isOvershooting:function(){return this._springConfig.tension>0&&((this._startValue<this._endValue&&this.getCurrentValue()>this._endValue)||(this._startValue>this._endValue&&this.getCurrentValue()<this._endValue))},advance:function(z,B){var H=this.isAtRest();if(H&&this._wasAtRest){return}var x=B;if(B>i.MAX_DELTA_TIME_SEC){x=i.MAX_DELTA_TIME_SEC}this._timeAccumulator+=x;var D=this._springConfig.tension,y=this._springConfig.friction,N=this._currentState.position,E=this._currentState.velocity,K=this._tempState.position,I=this._tempState.velocity,u,L,G,O,t,w,F,A,M,J;while(this._timeAccumulator>=i.SOLVER_TIMESTEP_SEC){this._timeAccumulator-=i.SOLVER_TIMESTEP_SEC;if(this._timeAccumulator<i.SOLVER_TIMESTEP_SEC){this._previousState.position=N;this._previousState.velocity=E}u=E;L=(D*(this._endValue-K))-y*E;K=N+u*i.SOLVER_TIMESTEP_SEC*0.5;I=E+L*i.SOLVER_TIMESTEP_SEC*0.5;G=I;O=(D*(this._endValue-K))-y*I;K=N+G*i.SOLVER_TIMESTEP_SEC*0.5;I=E+O*i.SOLVER_TIMESTEP_SEC*0.5;t=I;w=(D*(this._endValue-K))-y*I;K=N+t*i.SOLVER_TIMESTEP_SEC*0.5;I=E+w*i.SOLVER_TIMESTEP_SEC*0.5;F=I;A=(D*(this._endValue-K))-y*I;M=1/6*(u+2*(G+t)+F);J=1/6*(L+2*(O+w)+A);N+=M*i.SOLVER_TIMESTEP_SEC;E+=J*i.SOLVER_TIMESTEP_SEC}this._tempState.position=K;this._tempState.velocity=I;this._currentState.position=N;this._currentState.velocity=E;if(this._timeAccumulator>0){this.interpolate(this._timeAccumulator/i.SOLVER_TIMESTEP_SEC)}if(this.isAtRest()||this._overshootClampingEnabled&&this.isOvershooting()){if(this._springConfig.tension>0){this._startValue=this._endValue;this._currentState.position=this._endValue}else{this._endValue=this._currentState.position;this._startValue=this._endValue}this.setVelocity(0);H=true}var v=false;if(this._wasAtRest){this._wasAtRest=false;v=true}var C=false;if(H){this._wasAtRest=true;C=true}this.notifyPositionUpdated(v,C)},notifyPositionUpdated:function(u,v){for(var w=0,t=this.listeners.length;w<t;w++){var x=this.listeners[w];if(u&&x.onSpringActivate){x.onSpringActivate(this)}if(x.onSpringUpdate){x.onSpringUpdate(this)}if(v&&x.onSpringAtRest){x.onSpringAtRest(this)}}},systemShouldAdvance:function(){return !this.isAtRest()||!this.wasAtRest()},wasAtRest:function(){return this._wasAtRest},isAtRest:function(){return Math.abs(this._currentState.velocity)<this._restSpeedThreshold&&(this.getDisplacementDistanceForState(this._currentState)<=this._displacementFromRestThreshold||this._springConfig.tension===0)},setAtRest:function(){this._endValue=this._currentState.position;this._tempState.position=this._currentState.position;this._currentState.velocity=0;return this},interpolate:function(t){this._currentState.position=this._currentState.position*t+this._previousState.position*(1-t);this._currentState.velocity=this._currentState.velocity*t+this._previousState.velocity*(1-t)},getListeners:function(){return this.listeners},addListener:function(t){this.listeners.push(t);return this},removeListener:function(t){f(this.listeners,t);return this},removeAllListeners:function(){this.listeners=[];return this},currentValueIsApproximately:function(t){return Math.abs(this.getCurrentValue()-t)<=this.getRestDisplacementThreshold()}});var p=function p(){};a.extend(p.prototype,{position:0,velocity:0});var c=k.SpringConfig=function c(t,u){this.tension=t;this.friction=u};var g=k.AnimationLooper=function g(){this.springSystem=null;var u=this;var t=function(){u.springSystem.loop(Date.now())};this.run=function(){a.onFrame(t)}};var j=k.SimulationLooper=function j(t){this.springSystem=null;var v=0;var u=false;t=t||16.667;this.run=function(){if(u){return}u=true;while(!this.springSystem.getIsIdle()){this.springSystem.loop(v+=t)}u=false}};var n=k.SteppingSimulationLooper=function(t){this.springSystem=null;var v=0;var u=false;this.run=function(){};this.step=function(w){this.springSystem.loop(v+=w)}};var r=k.OrigamiValueConverter={tensionFromOrigamiValue:function(t){return(t-30)*3.62+194},origamiValueFromTension:function(t){return(t-194)/3.62+30},frictionFromOrigamiValue:function(t){return(t-8)*3+25},origamiFromFriction:function(t){return(t-25)/3+8}};a.extend(c,{fromOrigamiTensionAndFriction:function(t,u){return new c(r.tensionFromOrigamiValue(t),r.frictionFromOrigamiValue(u))},coastingConfigWithOrigamiFriction:function(t){return new c(0,r.frictionFromOrigamiValue(t))}});c.DEFAULT_ORIGAMI_SPRING_CONFIG=c.fromOrigamiTensionAndFriction(40,7);a.extend(c.prototype,{friction:0,tension:0});var h={};a.hexToRGB=function(t){if(h[t]){return h[t]}t=t.replace("#","");if(t.length===3){t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]}var u=t.match(/.{2}/g);var t={r:parseInt(u[0],16),g:parseInt(u[1],16),b:parseInt(u[2],16)};h[t]=t;return t};a.rgbToHex=function(v,u,t){v=v.toString(16);u=u.toString(16);t=t.toString(16);v=v.length<2?"0"+v:v;u=u.length<2?"0"+u:u;t=t.length<2?"0"+t:t;return"#"+v+u+t};var q=k.MathUtil={mapValueInRange:function(z,v,A,y,x){var w=A-v;var t=x-y;var u=(z-v)/w;return y+(u*t)},interpolateColor:function(u,x,v,B,z,A){B=typeof B==="undefined"?0:B;z=typeof z==="undefined"?1:z;var x=a.hexToRGB(x);var v=a.hexToRGB(v);var t=Math.floor(a.mapValueInRange(u,B,z,x.r,v.r));var w=Math.floor(a.mapValueInRange(u,B,z,x.g,v.g));var y=Math.floor(a.mapValueInRange(u,B,z,x.b,v.b));if(A){return"rgb("+t+","+w+","+y+")"}else{return a.rgbToHex(t,w,y)}},degreesToRadians:function(t){return(t*Math.PI)/180},radiansToDegrees:function(t){return(t*180)/Math.PI}};a.extend(a,q);function f(v,u){var t=v.indexOf(u);t!=-1&&v.splice(t,1)}var l;if(typeof process!=="undefined"&&process.title==="node"){l=setImmediate}if(typeof l==="undefined"){l=window&&window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame}a.onFrame=function b(t){return l(t)};if(typeof exports!="undefined"){a.extend(exports,k)}else{if(typeof window!="undefined"){window.rebound=k}}})(); </script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ html { background: #262832; font-family: 'Roboto Slab', serif;
}
#dribbble { width: 200px; margin: 20px auto; cursor: -webkit-grab; cursor: -moz-grab; cursor: grab;
}
.tracker { color: #EA4C89; width: 100%; text-align: center; font-size: 40px; text-transform: uppercase;
}
footer { text-align: center;
}
.button { border-radius: 4px; padding: 4px 30px; background: #EA4C89; color: #A81E53; display: inline-block; position: relative; top: 30px; display: inline-block; box-shadow: 0 0 0 1px #C32361; cursor: pointer;
}
.button:hover { background: #e94383;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body>
<html>
<head> <title>Rebbbound</title>
</head>
<body> <div id="dribbble"> <img src="https://cdn.getinvited.to/eventlogos/1413818171-dribble-logo.png" alt=""> </div> <div class="tracker"> <span id="counter">0</span> rebounds </div> <footer> <span class="button" id="zero">reset</span> </footer>
</body>
</html> <script src="js/index.js"></script>
</body>
</html>

Rebbbound - Script Codes CSS Codes

html { background: #262832; font-family: 'Roboto Slab', serif;
}
#dribbble { width: 200px; margin: 20px auto; cursor: -webkit-grab; cursor: -moz-grab; cursor: grab;
}
.tracker { color: #EA4C89; width: 100%; text-align: center; font-size: 40px; text-transform: uppercase;
}
footer { text-align: center;
}
.button { border-radius: 4px; padding: 4px 30px; background: #EA4C89; color: #A81E53; display: inline-block; position: relative; top: 30px; display: inline-block; box-shadow: 0 0 0 1px #C32361; cursor: pointer;
}
.button:hover { background: #e94383;
}

Rebbbound - Script Codes JS Codes

/** * Fiddling with the basic demo code from Rebound.js * It's actually funny to use a debounce function in a bounce animation.. * **/
var el = document.getElementById('dribbble'), counter = document.getElementById('counter'), zero = document.getElementById('zero'), count = 0, _rebound;
var springSystem = new rebound.SpringSystem();
var spring = springSystem.createSpring(75, 3);
spring.addListener({ onSpringUpdate: function(spring) { var val = spring.getCurrentValue();val = rebound.MathUtil.mapValueInRange(val, 0, 1, 1, 0.1); scale(el, val); if ( val > 1.06){ _rebound(); } }
});
el.addEventListener('mousedown', function() { spring.setEndValue(1);
});
el.addEventListener('mouseout', function() { spring.setEndValue(0);
});
el.addEventListener('mouseup', function() { spring.setEndValue(0);
});
zero.addEventListener('mousedown', function() { count = 0; counter.innerHTML = count;
});
function scale(el, val) { el.style.mozTransform = el.style.msTransform = el.style.webkitTransform = el.style.transform = 'scale3d(' + val + ', ' + val + ', 1)';
}
var _rebound = debounce(function(){ count++; counter.innerHTML = count;
}, 100);
function debounce(func, wait, immediate) {	var timeout;	return function() {	var context = this, args = arguments;	var later = function() {	timeout = null;	if (!immediate) func.apply(context, args);	};	var callNow = immediate && !timeout;	clearTimeout(timeout);	timeout = setTimeout(later, wait);	if (callNow) func.apply(context, args);	};
};
Rebbbound - Script Codes
Rebbbound - Script Codes
Home Page Home
Developer Nobitagit
Username nobitagit
Uploaded December 05, 2022
Rating 3
Size 6,636 Kb
Views 14,168
Do you need developer help for Rebbbound?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Nobitagit (nobitagit) Script Codes
Create amazing SEO content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!