S
S
siroper2021-11-11 04:50:39
JavaScript
siroper, 2021-11-11 04:50:39

How to postpone the execution of the function when boundschange yandex maps api?

Hello.

The site has a function that is called when the map changes (moves or zooms) - boundschange.

myMap.events.add('boundschange', function (event) {
  getPoints(event.originalEvent.newBounds);
});


The problem is that if you quickly zoom (with the mouse wheel for example) several times, then the function will be called several times in a row.

How to make the function be called, for example, after a second, and if there has not been another change in boundschange during this second.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2021-11-11
@freeExec

если время последнего старта функции ближе чем секунда назад, то не выполнять функцию 
иначе выполнить и сохранить время выполнения

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question