If you see this:
Yearly Archives: 2014
The order of the events triggered will be in the order they’re added. So when the order of two events makes a difference, and they’re in separate files, pay extra attention to which one gets load first. Especially when the page loads extra slow.
Order of On Events
Compatible Audio Playing Across All Platforms
It seems like:
- With HTML5 audio tag, if the audio is less than 500ms, the volume in Safari might fluctuate with all formats
- With HTML5 audio tag, the delay with Safari is obvious with all formats
- With flash audio player, the delay with Safari is obvious with
*.wav
, but it’s fine with*.mp3
- IE9 doesn’t support native audio tag
- Firefox’s audio sounds terrible when html5 audio tag is used with
mp3
/ogg
format, but is okay withwav
. - Firefox is fine with flash audio player
jQuery: keyup, keydown, keypress?
In normal cases, go for keyup
:
$(document).keyup(function(e){
console.log(e.which);
});
Reasons:
keydown
keeps firing when user holds the keys down, whilekeypress
andkeyup
fire only once.keypress
doesn’t detect special keys (e.g.SHIFT
),keydown
andkeyup
do.
IOS Video Control: Mission Impossible?
I spent 1.5 hours deleting code and comparing and found that JavaScript initiated events just can’t get the video going. One all-mighty Googling [1][2] revealed that, “embedded media cannot be played automatically in Safari on iOS – the user always initiates playback.” Damn.
It looks like a dead end. But wait. How did videojs-youtube managed it?
FullScreen with jQuery
The thing is, for security reasons, fullscreen could only be triggered by mouse and keyboard events. Trying it out in console alone would be vain.
Youtube Embedding
Where I stumbled:
- The JavaScript API is a completely different thing than the iframe API
- An outside script is actually needed for the iframe API
Understanding THREE.js
Q: What is a working THREE page composed of?
THREE things:
- Scene: a scene, a stage, to add stuff into
- Camera: somewhere to stand and peer
- Renderer: a 2D surface to cast the 3D calculation onto
window.innerWidth Vs. $(window).innerWidth()
What are the differences:
- window.innerWidth: with scrollbar
- $(window).innerWidth(): wrong usage
- $(window).width(): without scrollbar
- mediaquery: with scrollbar (at least the standard ones)