Advertisement
bongzilla

Untitled

Mar 9th, 2021
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. <script>
  2. (function(){
  3. ymaps.ready(function(){ return false })
  4. })();
  5.  
  6. let yMapsIsShown = false;
  7.  
  8. let myMap;
  9. function init(){
  10. console.log("map init")
  11. myMap = new ymaps.Map ("map", {
  12. center: [55.76, 37.64],
  13. zoom: 7
  14. });
  15. }
  16.  
  17. $(window).scroll(function() {
  18. if(!yMapsIsShown) {
  19. if ($(window).height() + $(window).scrollTop() > $(".b-map").offset().top) {
  20. yMapsIsShown = true;
  21. ymaps.ready(init);
  22. }
  23. }
  24. });
  25. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement