Giter VIP home page Giter VIP logo

Comments (4)

mikeflynn avatar mikeflynn commented on June 28, 2024

You could dip in to the eggs array in the Egg object to remove a function but you'd have to loop through and look for the one you want to remove.

In your specific case there are two things I would do:

  1. Pull the egg definition out of the functions you are tying to the modal actions.
  2. Use a boolean flag that reflects the modal's state and trigger the different action accordingly.

For example...

var modalOpen = false;

var egg = new Egg();
egg.addCode("left", function() {
  if modalOpen === true {
    switchBullTab("left");
  }
}, 'eggBullseyeLeft').listen();

$(document).on('closed', bullseye, function () {
  modalOpen = false
});

$(document).on('opened', bullseye, function () {
  modalOpen = true;
});

...there may be a way, depending on the modal implementation, to query the modal element directly and see if it's visible rather than set the modalOpen flag, but this works.

from egg.js.

tg247 avatar tg247 commented on June 28, 2024

Ok @mikeflynn, thanks for your suggestion.

"You could dip in to the eggs array in the Egg object to remove a function but you'd have to loop through and look for the one you want to remove."

How can I loop through the eggs? I have several Eggs, initialized after DOM-ready. When I want to list them

window.eggs

there are no eggs although the eggs are working.

Thank you very much for your effort.

from egg.js.

mikeflynn avatar mikeflynn commented on June 28, 2024

This depends on how you implemented the library. The eggs array is in the Egg object and if you are creating new Egg objects for each easter egg, then the eggs array will just have one egg each. However, if you are creating one Egg object and adding all of your eggs to that object, all of your eggs will be in the array.

Example:

// Create an egg object
var egg = new Egg();

// Add an easter egg
egg.addCode("left", function() {
  if modalOpen === true {
    switchBullTab("left");
  }
}, 'eggBullseyeLeft').listen();

// Add a second egg
egg.addCode("up,up,down,down,left,right,b,a", function() {
  alert("Boosh!");
}).listen();

// Loop through the eggs
for (var x in egg.eggs) {
  console.log(egg.eggs[x]);
}

from egg.js.

tg247 avatar tg247 commented on June 28, 2024

perfect, you really helped me out! thank you very much :)

from egg.js.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.