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.

sS html_humDemo() {
  ret htitle("Hum demo")
    //+ loadJQuery()
    + loadJQuery2()
    + hjs_playHum()
    + hjs([[
      console.log("$: " + $);
      console.log("easing: " + $.easing);
      $.extend($.easing, {
        easeInExpo: function (x, t, b, c, d) {
          return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
        },
        easeOutExpo: function(x, t, b, c, d) {
          return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
        },
        easeInOutQuint: function (x, t, b, c, d) {
          if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
          return c/2*((t-=2)*t*t*t*t + 2) + b;
        }
      });
  
      function fadeIn() {
        hum(0);
        fadeTo(1);
      }
  
      function fadeOut() {
        fadeTo(0);
      }
  
      function fadeTo(vol) {
        $(humSound).animate({ // call animate on the object
          volume: vol // specify the t property of the object to be animated
        }, {
          duration: vol < humSound.volume ? 250 : 500,
          easing: vol < humSound.volume ? 'easeOutExpo' : 'easeInOutQuint'/*'easeInExpo'*/
          //step: function(value) { humSound.volume = value; }
        });
      }
    ]])
    + hbutton_onClick("Silent", "hum(0)")
    + hbutton_onClick("Low", "hum(0.25)")
    + hbutton_onClick("Med", "hum(0.5)")
    + hbutton_onClick("Full", "hum(1)")
    + hbutton_onClick("Fade in", "fadeIn()")
    + hbutton_onClick("Fade out", "fadeOut()");
}

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: 127 / 194
Version history: 7 change(s)
Referenced in: [show references]