Provides Core event handlers for other widgets to use.
Scroll and Resize events are rate limited: handlers listening to those emitted events will not be triggered every time the browser triggers the corresponding event. This is to provide optimised handlers that don't run too frequently.
- Copyright:
- Copyright (C) 2005-2020 Alfresco Software Limited
- License:
- GNU Lesser General Public License, see: Open Source Licensing
- Source:
Examples
constructor: function() {
this.publishScrollEvents(this.domNode);
this.alfSubscribe(this.eventsScrollTopic, lang.hitch(this, this.onScroll));
}
<p>If your handler needs EVERY browser event, then you're best off subscribing to those
events directly</p>
on(window, "scroll", lang.hitch(this, this.onScroll));
Mixes In
Methods
-
debouncedPublish(topic, payload, global, parentScope, args) → {Object}
-
Debounce a simple topic publish
Parameters:
Name Type Argument Description topic
String The topic to be published payload
object <optional>
The payload to publish on the supplied topic global
boolean <optional>
Indicates that the pub/sub scope should not be applied parentScope
boolean <optional>
Indicates that the pub/sub scope inherited from the parent should be applied args
Object <optional>
Can take any of the optional arguments from the functionUtils debounce method - Source:
Returns:
An object containing a remove() function which will clear any outstanding publish- Type
- Object
-
publishResizeEvents(nodeToMonitor) → {Object}
-
When a resize event happens on the window, then publish to the resize topic.
Parameters:
Name Type Argument Default Description nodeToMonitor
Object <optional>
window The node to monitor for resizes - Source:
Returns:
The resize-listener, which contains a remove() function which can be called to release the listener- Type
- Object
-
publishScrollEvents(scrollNode) → {Object}
-
When a scroll event happens on the specified node (defaults to window), then publish to the scroll topic.
Parameters:
Name Type Argument Default Description scrollNode
Object <optional>
window The scroll node - Source:
Returns:
The scroll-listener, which contains a remove() function which can be called to release the listener- Type
- Object
-
throttledPublish(topic, payload, global, parentScope, args) → {Object}
-
Throttle a simple topic publish
Parameters:
Name Type Argument Description topic
String The topic to be published payload
object <optional>
The payload to publish on the supplied topic global
boolean <optional>
Indicates that the pub/sub scope should not be applied parentScope
boolean <optional>
Indicates that the pub/sub scope inherited from the parent should be applied args
Object <optional>
Can take any of the optional arguments from the functionUtils throttle method - Source:
Returns:
An object containing a remove() function which will clear any outstanding publish- Type
- Object