Skip to content

Using without Random Generation #51

Open
@sethgspivey

Description

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?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions