I'm scrolling the page if the current Customer Community User is not a 'Guest User', but the page movement is abrupt. Is there an attribute I can set on scrollTo() for more elegant page scrolling in lightning components (similar to behavior on window.scroll)?

My Current Code

scrollTo('custom', 600, 200);

scrollTo(target, top, left) isn't a valid set of parameters for scrollTo, so presumably you're using a custom function. The way you'd do this using just standard JavaScript/Lightning would look like this:

var target = component.find("target");
var element = target.getElement();
var rect = element.getBoundingClientRect();
scrollTo({top: rect.top, behavior: "smooth"});
  • I actually wasn't able to find proper params for scrollTo(), wasn't aware that the they are contained in an object. I was able to use behavior parameter for my purposes - thank you. – Nicholas Zozaya Aug 13 '18 at 0:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.