GithubHelp home page GithubHelp logo

Comments (5)

mcbmcb0 avatar mcbmcb0 commented on August 20, 2024 1

well that's easy:

var LiveForm = {
	options: { //existing 
		// vetical screen offset in px for element with error that receives focus after validation. Used when fixed navbar menu which may otherwise obscure the element in focus
		focusScreenOffset: 100, 
...
elem.focus(); //existing 
if(elem.getBoundingClientRect().top < LiveForm.options.focusScreenOffset){/
	window.scrollBy (0, elem.getBoundingClientRect().top - LiveForm.options.focusScreenOffset);
}

what do you think?

from live-form-validation.

Robyer avatar Robyer commented on August 20, 2024

Focusing the element (on master branch) is done here: https://github.com/Robyer/nette-live-form-validation/blob/master/live-form-validation.js#L705 So yes, you found same line in v1.8.1.

But I don't know how is this usually solved. Browser itself handles scrolling to that element, so you need to either override the browser's default behavior somehow (if that's possible) or scroll manually your +100px lower after the above mentioned line.

Is your scrollTo method working? Also, I think you should scoll only when the item isn't visible on the page already - so maybe remember scroll position, then call focus, then get new scroll position, and if it changed, then scroll down additional 100px?

I don't have time for this, so you let me know when you find reliable solution for this problem. Thanks.

from live-form-validation.

mcbmcb0 avatar mcbmcb0 commented on August 20, 2024

scrollto works fine for me (on FF), tho I'm not sure how cross browser compatible it is. good point about if the element is already in view - i'll look into it when i get some time

from live-form-validation.

mcbmcb0 avatar mcbmcb0 commented on August 20, 2024

this works:

elem.focus(); //existing
if(elem.getBoundingClientRect().top < 100){
	window.scrollBy (0, elem.getBoundingClientRect().top - 100);
}

reportedly ie8 and above. i just need to figure out how to pass a default offset value from Liveform optons:[ ]

from live-form-validation.

Robyer avatar Robyer commented on August 20, 2024

Slighly changed and commited, thanks ;-)

from live-form-validation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.