You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/05/20 15:59:49 UTC

[GitHub] [beam] nausharipov commented on a diff in pull request #17638: [BEAM-13229] [Website] bug side nav

nausharipov commented on code in PR #17638:
URL: https://github.com/apache/beam/pull/17638#discussion_r878304527


##########
website/www/site/assets/js/language-switch-v2.js:
##########
@@ -10,11 +10,26 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
+function getElPreviousPositionAndData(el) {
+    const clickedLangSwitchEl = el.target.closest(".language-switcher");
+    const elPreviousOffsetFromViewPort = clickedLangSwitchEl.getBoundingClientRect().top;
+    return {
+        elPreviousOffsetFromViewPort,
+        clickedLangSwitchEl,
+    }
+}
+
+function setScrollToNewPosition(clickedElData) {
+    const { elPreviousOffsetFromViewPort, clickedLangSwitchEl } = clickedElData;
+    const elCurrentHeight = window.pageYOffset + clickedLangSwitchEl.getBoundingClientRect().top;
+    $('html, body').scrollTop(elCurrentHeight - elPreviousOffsetFromViewPort);
+}
+
 $(document).ready(function() {
     function Switcher(conf) {
         var id = conf["class-prefix"],
-            def = conf["default"],
-            langs = [];
+          def = conf["default"],

Review Comment:
   please, format the file



##########
website/www/site/assets/js/language-switch-v2.js:
##########
@@ -10,11 +10,26 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
+function getElPreviousPositionAndData(el) {
+    const clickedLangSwitchEl = el.target.closest(".language-switcher");
+    const elPreviousOffsetFromViewPort = clickedLangSwitchEl.getBoundingClientRect().top;
+    return {
+        elPreviousOffsetFromViewPort,
+        clickedLangSwitchEl,
+    }
+}
+
+function setScrollToNewPosition(clickedElData) {
+    const { elPreviousOffsetFromViewPort, clickedLangSwitchEl } = clickedElData;
+    const elCurrentHeight = window.pageYOffset + clickedLangSwitchEl.getBoundingClientRect().top;
+    $('html, body').scrollTop(elCurrentHeight - elPreviousOffsetFromViewPort);
+}
+
 $(document).ready(function() {
     function Switcher(conf) {
         var id = conf["class-prefix"],
-            def = conf["default"],
-            langs = [];
+          def = conf["default"],

Review Comment:
   please, format files



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org