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

Allow adjusting the final position of .place() method via callback #10

Closed
niklasramo opened this issue Oct 20, 2016 · 2 comments
Closed
Milestone

Comments

@niklasramo
Copy link
Owner

  • Allow using a function for maximum extendibility.
  • Add new collision action: "flip".
  • Add new collision action: "elemX elemY targetX targetY". This would be a fallback position.
@niklasramo niklasramo added this to the v0.6.0 milestone Nov 7, 2016
@niklasramo
Copy link
Owner Author

niklasramo commented Nov 10, 2016

Actually thinking about this more it might be better to allow user to provide a function for the contain.onCollision option. I tried to replace popo.js in a project and it turned out to be a lot of work in the scenarios where popo's collision callback was used.

To provide more insight, this is the scenario I had:

popo($target[0], 'get', {
  base: $item[0],
  position: 'right top right bottom',
  container: window,
  collision: function (pos, overlap) {
    if(overlap.bottom < 0) {
      $target.addClass('reverse');
    }
  }
});

Replicating this with current version of Mezr requires a lot more work.

So, let's add the callback to Mezr also and make it behave similarly to that of popo's: https://github.com/niklasramo/popo.js#example-3.

The other collision actions are just a nice bonus after the callback function is implemented since you can pretty easily build any kind of collision handling behavior within the callback.

@niklasramo niklasramo changed the title Additional collision handler methods Allow adjusting the final position of .place() method via callback Nov 15, 2016
@niklasramo
Copy link
Owner Author

So after thinking about this more I think it's best to leave onCollision as it it and provide a new optional callback as an option, which is can be used to modify the return value of the method and which also receives all the available positioning data. This way user's can use the available collision methods and additionally modify the final result after collision correction.

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

No branches or pull requests

1 participant