davidjbradshaw / iframe-resizer

Keep iFrames sized to their content.

Home Page:https://iframe-resizer.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Function scrollToIFrame

ulriklystbaek opened this issue · comments

I think a very nice feature could be scrollToIFrame, where the scroll in the parent is relative to the iframe, it may be more usefull than scrollTo, because scrolling the parent is often when you want to highlight something in the iframe.

I have added it manually to your latest min version, I wont post the sourcecode because it is so trivial, it is just the scrollTo function but adding the iframes offset top. I would make a change request, but I ran into an issue where you use width and height to transfer the scroll values, and they do not accept negative values by default (in case you want to scroll like 10px above the iframe it is -10), and I just fixed this pretty dirty by changed minHeight to 1/0, you would probably like a more correct solution.

Rather than change the current function, it would make more sense to create a new one called scrollToOffset. So people have the option of which one to use. Happy to take a pull request if you want to do that, but please also include a test.

Yes it was also my intent to create another version of the existing function. I will try to find some time to implement it.

Thanks. I also think that the min/max height checks acting on these values is a bug. That check should be disabled for scrollTo().

Just had a look at the code. I'm going to move these lines

ensureInRange('Height');
ensureInRange('Width');

So they are only called if we are resizing the iFrame.

Great it would make it really easy to implement.

OK fix released as v2.6.3

Added scrollToOffset() method in v.2.6.4.