Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using without Random Generation #51

Open
sethgspivey opened this issue Apr 20, 2017 · 0 comments
Open

Using without Random Generation #51

sethgspivey opened this issue Apr 20, 2017 · 0 comments

Comments

@sethgspivey
Copy link

I'm currently trying to update the code to just use the foldUp and accordion methods and rotate specifically between those two. I want the accordion to fold out at a specific angle instead of a randomly generated angle as well as have the method function switch between foldUp and accordion and not be randomly generated.

(function() {
document.addEventListener('DOMContentLoaded', function() {
var demos, methods;

demos = [
  new OriDomi('.paper-map', {
    vPanels: 8,
    ripple: true
  })
];
setTimeout(function() {
  demos[0].accordion(15);
}, 1000);
methods = ['accordion', 'foldUp'];
return document.getElementById('content').addEventListener('click', function(e) {
  var angle, el, method, n;
  if ((el = e.target).className !== 'button') {
    return;
  }
  n = el.getAttribute('data-n');
  method = methods[Math.abs(Math.floor(Math.random() * methods.length - Math.random()))];
  angle = ['15'];
  demos[n][method](method !== 'foldUp' ? angle : void 0);
  if (method === 'foldUp') {
    angle = '';
  }
  return el.parentNode.getElementsByClassName('label')[0].innerHTML = method + "(" + angle + ")";
}, false);

});

}).call(this);

There's the updated code. Every time I try to specifically define the angle, it throws this error "Cannot set property 'innerHTML' of undefined" - relating to the demos[n] function. Could you point me in the right direction for switching between the two specific methods with pre-set angles?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant