E
E
edu301512017-02-03 19:16:20
JavaScript
edu30151, 2017-02-03 19:16:20

How to find elements in an image grid?

Hello!
There is a grid of images to which the "flip" animation is randomly applied.
The prototype can be viewed here dev.bakin.ru
All elements (squares) are stored in the timeouts object as properties:

(function() {
  ...

  var timeouts = []
      id = "timeoutID" + cardID;
  ...
    timeouts[id] = setTimeout(function() {
      var c = card.classList,
          newTime = randomNum( timeMin, timeMax ) * 1000;
      c.contains("flipped") === true ? c.remove("flipped") : c.add("flipped");
      cardsTimeout( id, newTime, card );
    }, time);
})();

d9431212c801498c90ed605d93670285.png
The question is how to find 4 elements from the element indicated by the number "1" in the figure?
The element marked with the number "1" will also be determined randomly, so two areas are shown for clarity.
This is necessary so that later 4 pictures are replaced by one large picture that would occupy the area of ​​these 4 pictures.
Can you tell me if there is an algorithm or a solution for finding these elements, or maybe there is a plugin in general with which you can make such a grid.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question