From 24b34d3deabc1250049a0d466a762f6bbf65f361 Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Thu, 19 Nov 2015 11:05:57 +1100 Subject: [PATCH 1/3] fix scroll-end events not triggered ... when dragging the scrollbar to the end with the mouse. --- src/js/plugin/update-scroll.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/plugin/update-scroll.js b/src/js/plugin/update-scroll.js index ff41ae4..3eab8e8 100644 --- a/src/js/plugin/update-scroll.js +++ b/src/js/plugin/update-scroll.js @@ -56,13 +56,13 @@ module.exports = function (element, axis, value) { var i = instances.get(element); - if (axis === 'top' && value > i.contentHeight - i.containerHeight) { + if (axis === 'top' && value >= i.contentHeight - i.containerHeight) { element.scrollTop = i.contentHeight - i.containerHeight; element.dispatchEvent(yEndEvent); return; // don't allow scroll past container } - if (axis === 'left' && value > i.contentWidth - i.containerWidth) { + if (axis === 'left' && value >= i.contentWidth - i.containerWidth) { element.scrollLeft = i.contentWidth - i.containerWidth; element.dispatchEvent(xEndEvent); return; // don't allow scroll past container From 7e04a2e72be6fe7baa10b881f2bcdde268c226cc Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Thu, 19 Nov 2015 11:26:28 +1100 Subject: [PATCH 2/3] 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', ''); From 9f9f15f83c352f4f8cd4c42aec323420edc7def2 Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Thu, 19 Nov 2015 11:50:31 +1100 Subject: [PATCH 3/3] fix lint error --- src/js/plugin/update.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/plugin/update.js b/src/js/plugin/update.js index 8bd0c74..3c539ac 100644 --- a/src/js/plugin/update.js +++ b/src/js/plugin/update.js @@ -30,7 +30,7 @@ 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);