From 7e04a2e72be6fe7baa10b881f2bcdde268c226cc Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Thu, 19 Nov 2015 11:26:28 +1100 Subject: [PATCH] trigger events on update Dispatch the custom events on `Ps.update`: ``` container.scrollTop = 50; Ps.update(container); ``` This is useful for controlling the scroll position via left/right arrows and enabling/disabling these arrows on scroll or when the start/end is reached. This also allows for the events to be dispatched on page load by calling `Ps.update` right after `Ps.initialise`. --- src/js/plugin/update.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/js/plugin/update.js b/src/js/plugin/update.js index 6d0edfd..8bd0c74 100644 --- a/src/js/plugin/update.js +++ b/src/js/plugin/update.js @@ -6,7 +6,8 @@ var d = require('../lib/dom') , h = require('../lib/helper') , instances = require('./instances') - , updateGeometry = require('./update-geometry'); + , updateGeometry = require('./update-geometry') + , updateScroll = require('./update-scroll'); module.exports = function (element) { var i = instances.get(element); @@ -29,6 +30,10 @@ module.exports = function (element) { d.css(i.scrollbarYRail, 'display', 'none'); updateGeometry(element); + + // Update top/left scroll to trigger events + updateScroll(element, 'top', element.scrollTop); + updateScroll(element, 'left', element.scrollLeft); d.css(i.scrollbarXRail, 'display', ''); d.css(i.scrollbarYRail, 'display', '');