Skip to content

Commit

Permalink
Release v0.0.1:metal:
Browse files Browse the repository at this point in the history
  • Loading branch information
vodkabears committed Mar 16, 2015
1 parent 809bc9a commit 6865966
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 80 deletions.
2 changes: 1 addition & 1 deletion dist/interdimensional.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Interdimensional - v0.0.1-alpha
* Interdimensional - v0.0.1
* Spatial scrolling for your web pages.
* http://vodkabears.github.io/interdimensional/
*
Expand Down
83 changes: 6 additions & 77 deletions dist/interdimensional.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Interdimensional - v0.0.1-alpha
* Interdimensional - v0.0.1
* Spatial scrolling for your web pages.
* http://vodkabears.github.io/interdimensional/
*
Expand Down Expand Up @@ -158,66 +158,6 @@
window.addEventListener('deviceorientation', deviceOrientationHandler, false);
}

/**
* Parses a string with options
* @private
* @param {String} str
* @returns {Object|String}
*/
function parseOptions(str) {
var obj = {};
var delimiterIndex;
var option;
var prop;
var val;
var arr;
var len;
var i;

// remove spaces around delimiters and split
arr = str.replace(/\s*:\s*/g, ':').replace(/\s*,\s*/g, ',').split(',');

// parse a string
for (i = 0, len = arr.length; i < len; i++) {
option = arr[i];

// Ignore urls and a string without colon delimiters
if (option.search(/^(http|https|ftp):\/\//) !== -1 ||
option.search(':') === -1) {

break;
}

delimiterIndex = option.indexOf(':');
prop = option.substring(0, delimiterIndex);
val = option.substring(delimiterIndex + 1);

// if val is an empty string, make it undefined
if (!val) {
val = undefined;
}

// convert a string value if it is like a boolean
if (typeof val === 'string') {
val = val === 'true' || (val === 'false' ? false : val);
}

// convert a string value if it is like a number
if (typeof val === 'string') {
val = !isNaN(val) ? +val : val;
}

obj[prop] = val;
}

// if nothing is parsed
if (prop == null && val == null) {
return str;
}

return obj;
}

/**
* Calculates a number of pixels to scroll
* @private
Expand Down Expand Up @@ -312,21 +252,6 @@
Interdimensional.kick();
}

/**
* Initializes declaratively
* @private
* @listens DOMContentLoaded
*/
function handleDOMContentLoadedEvent() {
var data = document.body.getAttribute('data-interdimensional');

if (data != null) {
Interdimensional.charge(parseOptions(data));
}
}

document.addEventListener('DOMContentLoaded', handleDOMContentLoadedEvent, false);

return {

/**
Expand All @@ -349,6 +274,10 @@
* Initializes
* @public
* @param {Object} options
* @param {Number} options.PPD Pixels per difference between tilts
* @param {Number} options.insensitivity Minimum difference between tilts
* @param {Boolean} options.useControl Use the control or not
* @param {HTMLElement|null} Interdimensional control, if null - the default control will be used
*/
charge: function(options) {
if (!isCharged && !isCharging) {
Expand Down Expand Up @@ -445,7 +374,7 @@
Interdimensional.kick();

isCharged = false;
settings.useControl && document.body.removeChild(control);
!settings.control && settings.useControl && document.body.removeChild(control);

// Remove event listeners
control.removeEventListener('touchstart', handleTouchStartEvent, false);
Expand Down
4 changes: 2 additions & 2 deletions dist/interdimensional.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6865966

Please sign in to comment.