angular div 滚动条事件_Angularjs:滚动到达div中滚动条底部时如何触发事件?

本文介绍了一个AngularJS指令,用于当元素(或窗口)滚动到顶部、底部、左侧或右侧边缘时触发回调函数。该指令适用于Angular 1.3和1.4.8,已在IE10和Chrome 55上测试。示例代码展示了如何使用该指令并在滚动到div底部时调用控制器的函数。
摘要由CSDN通过智能技术生成

Petro Podrez..

6

我一直在寻找一个片段来帮助我做到这一点,但是找不到任何值得的东西,所以我想出了这个相当容易使用的指令来做到这一点

'use strict';

// Tested with Angular 1.3, 1.4.8

angular.module('scrollToEnd', [])

/**

* @ngdoc directive

* @name scrollToEnd:scrollToEnd

* @scope

* @restrict A

*

* @description

* Supply a handler to be called when this element is scrolled all the way to any extreme.

* The callback must have the following signature:

* void function (direction:'top'|'bottom'|'left'|'right')

* If the `bindToWindow` attribute is truthy, the callback will be issued for the window

* instead of the element that the directive is on.

*

* Example usage:

* `

`

* This will call the controller's `scrollToEn

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值