Skip to content

Instantly share code, notes, and snippets.

View romidane's full-sized avatar

Steven Bapaga romidane

  • Swiftech Consulting Ltd
  • United Kingdom
View GitHub Profile
@romidane
romidane / element.properties.js
Created September 6, 2016 12:49
Get element properties
function getPropertyValue(element, property) {
return parseInt(window.getComputedStyle(element)[property].replace('px', ''))
}
function getOffsetRect(elem) {
var box = elem.getBoundingClientRect()
var body = document.body
var docElem = document.documentElement
@romidane
romidane / destructuring.js
Created December 1, 2015 22:40 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring.
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => {
return [1, 2, 3];
@romidane
romidane / cached-request.js
Last active September 19, 2015 21:56
Simple cached HTTP requests with Jquery Supports both GET and POST with data
function fetchData(url, options, cb){
if(!cb) throw new Error('Please suply a callback function!');
if(!fetchData._cache) fetchData._cache = {};
var settings = {
method: "GET",
url: url
}