【问题标题】:jquery - expand google map when scroll downjquery - 向下滚动时展开谷歌地图
【发布时间】:2018-04-16 07:53:11
【问题描述】:

所以,我有分页:

一侧 - 带有文本和位置的部分

另一面 - 谷歌地图与参考部分的别针

我添加了向下滚动时扩展地图高度的脚本,但它不是那么直观。

有没有更好的代码可以在用户向下滚动时打开展开地图?

这是我当前的代码:

// change map size when scroll down
$(window).scroll(function() {    
    var scroll = $(window).scrollTop();

    if (scroll >= 450) {
        $("#map-warp").addClass("change-map-canvas");   // removed the . from class
        $("#map-warp").css("margin-top", "40px"); ;     // change margin from top for close infoWindow button
    } else {
        $("#map-warp").removeClass("change-map-canvas");  // removed the . from class
        $("#map-warp").css("margin-top", "10px"); ;
    }
});

【问题讨论】:

    标签: javascript jquery google-maps-api-3


    【解决方案1】:

    绑定窗口滚动,当滚动到结束时触发 if = true

    $(window).scroll(function() {    
                  //scroll in the end
                 if (document.documentElement.scrollHeight = document.documentElement.scrollTop + document.documentElement.offsetHeight)) {
                   //dosomething
                   }
    
            });
    

    【讨论】:

    • 为你的答案添加一些解释
    猜你喜欢
    • 2019-11-08
    • 2022-06-22
    • 1970-01-01
    • 2018-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-03
    相关资源
    最近更新 更多