Comments (4)
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:
- Pull the egg definition out of the functions you are tying to the modal actions.
- 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.
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.
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.
perfect, you really helped me out! thank you very much :)
from egg.js.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from egg.js.