From 6681e218852bcae327e7553219aca3c22c4cf5d0 Mon Sep 17 00:00:00 2001 From: leastbad Date: Fri, 22 Jan 2021 17:14:41 -0500 Subject: [PATCH 1/2] scroll operation --- javascript/cable_ready.js | 7 +++++++ lib/cable_ready/channels.rb | 1 + 2 files changed, 8 insertions(+) diff --git a/javascript/cable_ready.js b/javascript/cable_ready.js index cd338bac..8802898b 100644 --- a/javascript/cable_ready.js +++ b/javascript/cable_ready.js @@ -297,6 +297,13 @@ const DOMOperations = { dispatch(document, 'cable-ready:after-remove-storage-item', operation) }, + scroll: operation => { + const { element } = operation + dispatch(element, 'cable-ready:before-scroll', operation) + if (!operation.cancel) element.scrollIntoView(operation) + dispatch(element, 'cable-ready:after-scroll', operation) + }, + setCookie: operation => { const { cookie } = operation dispatch(document, 'cable-ready:before-set-cookie', operation) diff --git a/lib/cable_ready/channels.rb b/lib/cable_ready/channels.rb index dba0a5e1..6b721e0e 100644 --- a/lib/cable_ready/channels.rb +++ b/lib/cable_ready/channels.rb @@ -33,6 +33,7 @@ def initialize remove_css_class remove_storage_item replace + scroll set_attribute set_cookie set_dataset_property From 47e4cc8f31f0c1bf49550df2b64effacf529d0bf Mon Sep 17 00:00:00 2001 From: leastbad Date: Sun, 24 Jan 2021 15:11:28 -0500 Subject: [PATCH 2/2] fix event names --- javascript/cable_ready.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/javascript/cable_ready.js b/javascript/cable_ready.js index e1ed84ed..a6ac4d86 100644 --- a/javascript/cable_ready.js +++ b/javascript/cable_ready.js @@ -299,9 +299,9 @@ const DOMOperations = { scrollIntoView: operation => { const { element } = operation - dispatch(element, 'cable-ready:before-scroll', operation) + dispatch(element, 'cable-ready:before-scroll-into-view', operation) if (!operation.cancel) element.scrollIntoView(operation) - dispatch(element, 'cable-ready:after-scroll', operation) + dispatch(element, 'cable-ready:after-scroll-into-view', operation) }, setCookie: operation => {