PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.0
Forumax – AI Powered Advanced Community Forum Plugin v2.5.0
2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 All 30 releases
bbp-core / lib / bbpress / includes / admin / assets / js / badge.js

badge.js in Forumax – AI Powered Advanced Community Forum Plugin 2.5.0, at lib/bbpress/includes/admin/assets/js/badge.js

47 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function () {
2 window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
3
4 var field = document.getElementById( 'bbp-badge' ),
5 bee = document.getElementById( 'bbp-bee' ),
6
7 max_x = field.clientWidth - bee.offsetWidth,
8 max_y = field.clientHeight - bee.offsetHeight,
9 angle = 95,
10 offset = 95,
11
12 duration = 4,
13 canvas = 50,
14 start = null,
15 variance = 1;
16
17 function step( timestamp ) {
18 var progress, x, y;
19
20 if ( start === null ) {
21 start = timestamp;
22 variance = 1;
23 angle = 95;
24 }
25
26 progress = ( timestamp - start ) / duration / 1000;
27 angle = ( 360 * progress ) + offset;
28
29 x = variance * Math.sin( progress * 2 * Math.PI );
30 y = Math.cos( progress * 2 * Math.PI );
31
32 bee.style.left = max_x / 2 + ( canvas * x ) + 'px';
33 bee.style.bottom = max_y / 2 + ( canvas * y ) + 'px';
34 bee.style.transform = 'rotate(' + angle + 'deg)';
35 bee.style.webkitTransform = 'rotate(' + angle + 'deg)';
36
37 // Reset
38 if ( progress >= 1 ) {
39 start = null;
40 }
41
42 requestAnimationFrame( step );
43 }
44
45 requestAnimationFrame( step );
46 })();
47