{"version":3,"file":"scroll_restore_controller-DC4WtF51.js","sources":["../../../app/javascript/entrypoints/controllers/scroll_restore_controller.js"],"sourcesContent":["import { Controller } from \"@hotwired/stimulus\";\nimport { useMutation } from \"stimulus-use\";\n\nexport default class extends Controller {\n static targets = [\"list\"];\n\n connect() {\n this.restore();\n useMutation(this, { attributes: true, childList: true, subtree: true });\n }\n\n disconnect() {\n console.log(\"I have disconnected\");\n }\n\n listTargetConnected() {\n console.log(\"list connected\");\n }\n\n mutate() {\n this.restore();\n }\n\n save() {\n sessionStorage.setItem(\"scrollPosition\", this.element.scrollTop);\n }\n\n restore() {\n const scrollPosition = sessionStorage.getItem(\"scrollPosition\") || null;\n\n if (scrollPosition) {\n this.element.scrollTop = scrollPosition;\n sessionStorage.removeItem(\"scrollPosition\");\n }\n }\n}\n"],"names":["scroll_restore_controller","Controller","useMutation","scrollPosition","__publicField"],"mappings":"2PAGe,MAAKA,UAASC,CAAW,CAGtC,SAAU,CACR,KAAK,QAAO,EACZC,EAAY,KAAM,CAAE,WAAY,GAAM,UAAW,GAAM,QAAS,EAAI,CAAE,CACvE,CAED,YAAa,CACX,QAAQ,IAAI,qBAAqB,CAClC,CAED,qBAAsB,CACpB,QAAQ,IAAI,gBAAgB,CAC7B,CAED,QAAS,CACP,KAAK,QAAO,CACb,CAED,MAAO,CACL,eAAe,QAAQ,iBAAkB,KAAK,QAAQ,SAAS,CAChE,CAED,SAAU,CACR,MAAMC,EAAiB,eAAe,QAAQ,gBAAgB,GAAK,KAE/DA,IACF,KAAK,QAAQ,UAAYA,EACzB,eAAe,WAAW,gBAAgB,EAE7C,CACH,CA/BEC,EADkBJ,EACX,UAAU,CAAC,MAAM"}