Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unclear. Uncommitted changes from last I worked on this
- Loading branch information
1 parent
794b91d
commit 1f608ba
Showing
10 changed files
with
212 additions
and
165 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,123 @@ | ||
define([], function () { | ||
'use strict'; | ||
function events(app) { | ||
|
||
return function (app) { | ||
return { | ||
onResize: function () { | ||
}, | ||
/* function demoSwitch() { | ||
var self = this; | ||
getViewportSize: function () { | ||
app.viewportSize = { | ||
width: document.documentElement.clientWidth, | ||
height: document.documentElement.clientHeight | ||
}; | ||
}, | ||
app.sel.demoButtons.addEventListener('click', function (e) { | ||
if (e.target.tagName === 'BUTTON') { | ||
demoSwitch: function () { | ||
var self = this; | ||
var currentDemo = e.target.getAttribute('data-demo'); | ||
app.demoButtons.addEventListener('click', function (e) { | ||
if (e.target.tagName === 'BUTTON') { | ||
app.priorAnimation = app.currentAnimation; | ||
app.currentAnimation = currentDemo; | ||
var currentDemo = e.target.getAttribute('data-demo'); | ||
self.loadDemo(currentDemo); | ||
app.priorAnimation = app.currentAnimation; | ||
app.currentAnimation = currentDemo; | ||
ga('send', 'event', 'category', 'switchDemo', currentDemo); | ||
self.resetDemo(); | ||
document.getElementsByTagName('body')[0].className = currentDemo; | ||
ga('send', 'event', 'category', 'switchDemo', currentDemo); | ||
} | ||
}); | ||
}*/ | ||
|
||
document.getElementsByTagName('body')[0].className = currentDemo; | ||
/* function loadDemo(demo) { | ||
var module; | ||
if (module === 'loading') { | ||
return; | ||
} | ||
} | ||
if (module === undefined) { | ||
module = 'loading'; | ||
require(['demos/demo' + demo], function (ModuleObject) { | ||
console.log('loading a new module', 'demos/demo'+demo); | ||
module = new ModuleObject(); | ||
}); | ||
}, | ||
resetDemo: function () { | ||
if (app.animations[app.priorAnimation].hasOwnProperty('reset')) { | ||
app.animations[app.priorAnimation].reset(); | ||
} else { | ||
app.animations.demo.reset(); | ||
} | ||
} else { | ||
module.init(); | ||
} | ||
} | ||
app.animations[app.currentAnimation].init(); | ||
|
||
ga('send', 'event', 'category', 'resetDemo', app.currentAnimation); | ||
}, | ||
|
||
saveDemo: function () { | ||
app.modal.show('save-image'); | ||
var content = btoa(app.container.innerHTML), | ||
innerModal = document.getElementsByClassName('modalForeground')[0], | ||
image = innerModal.getElementsByTagName('img')[0]; | ||
|
||
image.setAttribute('src', 'data:image/svg+xml;base64,' + content); | ||
ga('send', 'event', 'category', 'saveDemo', currentDemo); | ||
|
||
}, | ||
|
||
showControls: function () { | ||
app.modal.show('more-controls'); | ||
}, | ||
|
||
controls: function () { | ||
var self = this; | ||
app.controlButtons.addEventListener('click', function (e) { | ||
if (e.target.tagName === 'BUTTON') { | ||
var action = e.target.getAttribute('data-action'); | ||
|
||
switch (action) { | ||
case 'controls': | ||
console.log('will show controls at some point'); | ||
self.showControls(); | ||
break; | ||
case 'save': | ||
console.log('saving demo'); | ||
self.saveDemo(); | ||
break; | ||
default: | ||
self.resetDemo(); | ||
} | ||
} | ||
}); | ||
}, | ||
|
||
moreInfo: function () { | ||
var infoButton = document.getElementsByClassName('moreInfo')[0]; | ||
infoButton.addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
app.modal.show('more-info'); | ||
}, true); | ||
}, | ||
|
||
init : function () { | ||
this.getViewportSize(); | ||
this.demoSwitch(); | ||
this.controls(); | ||
this.moreInfo(); | ||
function resetDemo() { | ||
if (app.animations[app.priorAnimation].hasOwnProperty('reset')) { | ||
app.animations[app.priorAnimation].reset(); | ||
} else { | ||
app.animations.demo.reset(); | ||
} | ||
}; | ||
}; | ||
app.animations[app.currentAnimation].init(); | ||
ga('send', 'event', 'category', 'resetDemo', app.currentAnimation); | ||
}*/ | ||
|
||
function saveDemo() { | ||
app.modal.show('save-image'); | ||
var content = btoa(app.container.innerHTML), | ||
innerModal = document.getElementsByClassName('modalForeground')[0], | ||
image = innerModal.getElementsByTagName('img')[0]; | ||
|
||
image.setAttribute('src', 'data:image/svg+xml;base64,' + content); | ||
ga('send', 'event', 'category', 'saveDemo', currentDemo); | ||
|
||
} | ||
|
||
function showControls() { | ||
app.modal.show('more-controls'); | ||
} | ||
|
||
function controls() { | ||
var self = this; | ||
app.sel.controlButtons.addEventListener('click', function (e) { | ||
if (e.target.tagName === 'BUTTON') { | ||
var action = e.target.getAttribute('data-action'); | ||
|
||
switch (action) { | ||
case 'controls': | ||
console.log('will show controls at some point'); | ||
self.showControls(); | ||
break; | ||
case 'save': | ||
console.log('saving demo'); | ||
self.saveDemo(); | ||
break; | ||
default: | ||
self.resetDemo(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
/* function moreInfo() { | ||
var infoButton = document.getElementsByClassName('moreInfo')[0]; | ||
infoButton.addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
app.modal.show('more-info'); | ||
}, true); | ||
}*/ | ||
|
||
function bindEvents() { | ||
console.log('wasd'); | ||
window.addEventListener('resize', function(event){ | ||
console.log('wasd'); | ||
}); | ||
} | ||
|
||
function init () { | ||
// this.getViewportSize(); | ||
// this.demoSwitch(); | ||
// this.controls(); | ||
// this.moreInfo(); | ||
this.bindEvents(); | ||
// this.loadDemo(app.defaultAnimation) | ||
} | ||
|
||
return { | ||
init: init | ||
} | ||
} | ||
|
||
return events; | ||
}); |
Oops, something went wrong.