Skip to content

Instantly share code, notes, and snippets.

View sonnyp's full-sized avatar
🛠️

Sonny sonnyp

🛠️
View GitHub Profile
@sonnyp
sonnyp / hidescrollbars.js
Created September 17, 2012 16:32
hide scrollbars
var hideScrollbars = function(aElement) {
if (aElement.clientWidth === aElement.offsetWidth)
return;
aElement.style.overflow = 'hidden';
if ('onwheel' in scrollbox) {
scrollbox.addEventListener('wheel', function(e) {
this.scrollTop += e.deltaY;
this.scrollLeft += e.deltaX;
@sonnyp
sonnyp / ASAP.js
Last active October 10, 2015 04:47
Execute some DOM related operation when document is ready
var whenDocumentIsReady = function(callback) {
if (document.readyState !== 'loading')
callback.call(document);
else
document.addEventListener('DOMContentLoaded', callback);
};
@sonnyp
sonnyp / fileInputSupport.js
Created April 4, 2012 14:19
On Safari mobile file input are disabled, this function check whether it's supported or not.
function fileInputSupport() {
var input = document.createElement('input');
input.type = 'file';
return !input.disabled;
}