Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

47
LINES

< > BotCompany Repo | #1028691 // html_humDemo

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (3228L) is out of date.

1  
sS html_humDemo() {
2  
  ret htitle("Hum demo")
3  
    //+ loadJQuery()
4  
    + loadJQuery2()
5  
    + hjs_playHum()
6  
    + hjs([[
7  
      console.log("$: " + $);
8  
      console.log("easing: " + $.easing);
9  
      $.extend($.easing, {
10  
        easeInExpo: function (x, t, b, c, d) {
11  
          return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
12  
        },
13  
        easeOutExpo: function(x, t, b, c, d) {
14  
          return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
15  
        },
16  
        easeInOutQuint: function (x, t, b, c, d) {
17  
          if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
18  
          return c/2*((t-=2)*t*t*t*t + 2) + b;
19  
        }
20  
      });
21  
  
22  
      function fadeIn() {
23  
        hum(0);
24  
        fadeTo(1);
25  
      }
26  
  
27  
      function fadeOut() {
28  
        fadeTo(0);
29  
      }
30  
  
31  
      function fadeTo(vol) {
32  
        $(humSound).animate({ // call animate on the object
33  
          volume: vol // specify the t property of the object to be animated
34  
        }, {
35  
          duration: vol < humSound.volume ? 250 : 500,
36  
          easing: vol < humSound.volume ? 'easeOutExpo' : 'easeInOutQuint'/*'easeInExpo'*/
37  
          //step: function(value) { humSound.volume = value; }
38  
        });
39  
      }
40  
    ]])
41  
    + hbutton_onClick("Silent", "hum(0)")
42  
    + hbutton_onClick("Low", "hum(0.25)")
43  
    + hbutton_onClick("Med", "hum(0.5)")
44  
    + hbutton_onClick("Full", "hum(1)")
45  
    + hbutton_onClick("Fade in", "fadeIn()")
46  
    + hbutton_onClick("Fade out", "fadeOut()");
47  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028691
Snippet name: html_humDemo
Eternal ID of this version: #1028691/8
Text MD5: d978cc858bcee170c72bce1f509853f6
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-05 17:18:59
Source code size: 1497 bytes / 47 lines
Pitched / IR pitched: No / No
Views / Downloads: 193 / 283
Version history: 7 change(s)
Referenced in: [show references]