• angular浏览器滚动条滚动到指定element 触发事件


    angular.module('app').directive('ScrollTrigger', () => {
        return {
          restrict: "A",
          link:function ($scope,$element,$attrs,$controller) {
            function debounce(fn, delay) {
              let timer = null;
              return function () {
                let context = this;
                let args = arguments;
                clearTimeout(timer);
                timer = setTimeout(function () {
                  fn.apply(context, args);
                }, delay);
              }
            }
            let trigger=debounce(() => {
              if ($element.is(":hidden")) {
                return;
              }
              if (($(window).scrollTop() + $(window).height()) > ($element.offset().top + 5)) {
                if (!$scope.$eval($attrs.zScrollTrigger)) {
                  $element.trigger("click");
                }
              }
            }, 100);
            $(window).scroll(trigger);
            $scope.$on("destroy",()=>{
              $(window).unbind("scroll",trigger);
            })
          }
        }
      })
  • 相关阅读:
    Javabean(MAX)
    电梯时间计算
    FT232R USB UART驱动安装
    java多态
    php文件上传代码
    $_FILES ERROR
    17
    php伪静态
    我的博客开通了!
    【省选划水记】我确实是在划水。
  • 原文地址:https://www.cnblogs.com/Zoes/p/6553798.html
Copyright © 2020-2023  润新知