Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always fit within viewport, in secondary dimension? #60

Closed
henrik opened this issue Apr 13, 2015 · 8 comments
Closed

Always fit within viewport, in secondary dimension? #60

henrik opened this issue Apr 13, 2015 · 8 comments

Comments

@henrik
Copy link

henrik commented Apr 13, 2015

If a Drop.js is set to appear below an element, the constrainToWindow: true option will make it appear above the element instead if necessary to fit inside the viewport.

But if the horisontal center of the anchor point of the Drop is close to the left or right edge of the window, it may go outside the window horisontally as seen here:

Is there any built-in way to fix that issue? Ideally I think it would shift the content to fit the viewport width, but the arrow would stay put, becoming off-centered.

@NicBright
Copy link

You can improve the behaviour a little bit with these tetherOptions (if you give constraints in this way, constrainToWindow and constrainToScrollParent will be completely ignored, because the constraints they produce are overwritten)

    tetherOptions: {
        constraints: [{
            to: 'window',
            pin: true,
            attachment: 'together'
        }]
    }

The only downsides to this are:

  1. While pinned, you won't have an arrow pointing to your drop target
  2. While pinned to the right side of the viewport, an extra ugly horizontal scrollbar is added.

If you plan to open your drops permanently (e.g. via click) and not only while hovering them, you might consider having the pin option set to ['left', 'right'], to prevent the drop from being pinned vertically while scrolling down the page.

@henrik
Copy link
Author

henrik commented Apr 29, 2015

@NicBright Oh, excellent! Thank you so much.

@geekjuice
Copy link
Contributor

Seems like a solved issue 👍 If not, feel free to reopen the issue.

@henrik
Copy link
Author

henrik commented May 12, 2015

Yeah, you can probably consider it solved. Thanks! Would be nice if it had this behavior by default (you probably never want it to not fit within the viewport), but maybe that's tricky.

@geekjuice
Copy link
Contributor

@henrik Actually, there is a potential fix for this coming soon via shipshapecode/tether#81. Is this closer to the type of solution you were looking for where it stays in the viewport?

@henrik
Copy link
Author

henrik commented Jun 26, 2015

@geekjuice Yup, that looks like exactly what I was after!

@yairEO
Copy link

yairEO commented Aug 27, 2015

what fix? there's an "ugly horizontal scrollbar" as @NicBright described. it's a huge show-stopper

@geekjuice
Copy link
Contributor

I think the example in shipshapecode/tether#81 has scroll bars to demonstrate the attachment position adjusting to being close to the edges and repositioning to stay within the view port. In practice, you shouldn't see scroll bars as the entire point is keep the tethered content in the viewport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants