jacekschae / learn-re-frame-course-files

:cinema: Learn re-frame course files for building Cheffy app
https://www.learnreframe.com/
57 stars 43 forks source link

Page always scrolls to bottom #3

Closed aldazosa closed 5 years ago

aldazosa commented 5 years ago

Expected Behavior

When viewing a recipe in a browser with a small viewport the page should show the top of the page (the author contact and the recipe image)

Actual Behavior

If the whole recipe doesn't fit in the viewport, the recipe shows the page bottom (recipe ingredients)

Steps to reproduce

  1. Open the browser and change the width to something narrow (below 768px) or simulate a mobile device
  2. Log in as mike@mailinator.com
  3. Go to the "Recipes" page
  4. Click on "Banana Waffles" recipe.

Specification

jacekschae commented 5 years ago

Hi @aldazosa,

I'm sorry for not responding to this before but somehow my notifications got buried with Gmail. There has been a lot of discussion in JS community about this.

Here is one way to fix this. You would have to update the app.router/path-for so that after every path change the window scrolls to the top.

(defn path-for
  [& route]
  (.scrollTo js/window 0 0)
  (apply bidi/path-for routes route))

Once again sorry for my late response. Let me know if that fixes the problem for you.

aldazosa commented 5 years ago

Hi @jacekschae,

The workaround works great! I don't do a lot of JS so when I googled a bit to find out what was happening I searched for problems with Smooth UI. I guess I was too specific. Thanks for taking the time to check this out.