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
height/contentHeight accept function for dynamic value #3040
height/contentHeight accept function for dynamic value #3040
Conversation
this makes it a lot easier to size the control to its container. for example, implementations could do `return container_el.clientHeight`
This is basically what I'm doing to solve #3039 |
+1 |
i agree that #2704 should still be implemented, but this could be cool as well. I'd prefer to see it as the existing |
getContainerHeight
option
Philosophical question: how is this better than calling the height setter method? I'd rather keep the setter method as the only way to dynamically set an explicit pixel value, and then introduce a |
It's a more elegant way to handle a dynamically changing container. |
@aharpervc can you provide hypothetical code samples to show how it's more elegant the existing technique of using the setter methods? |
I'll give you my actual production code I'm running with this patch: this.timeline = $(container_el).fullCalendar(_.extend({
timezone: "utc",
editable: false,
aspectRatio: 1.8,
getContainerHeight: function() {
return container_el.clientHeight - 15;
},
// etc... There's no extra state to track and no extra events to hook up. Whenever calcSize is called internally, the current container client height is used. Now fullcalendar can vertically fill its container both on init and when the browser is resized. There's a Now, you could certainly re-implement this concept as a static property. However, you'd need to make assumptions on what is the appropriate container element (probably direct parent) and what is the appropriate margins (probably none). Those assumptions may or may not be true for all apps and isn't relevant to the fullcalendar itself. That's why it's more elegant to delegate the computation to the caller. |
ah ok, this is more clear to me now. how is the height-update initiated? are you manually calling the render method (which readjusts sizing) or are you merely waiting for the built-in window resize handler? |
I'm not explicitly calling render, but also I do have |
ok, this feature makes more sense to me now that i know you are leveraging window resize handling to adjust the height. thanks. |
@@ -667,6 +667,10 @@ function Calendar_constructor(element, overrides) { | |||
|
|||
|
|||
function _calcSize() { // assumes elementVisible | |||
if (typeof options.getContainerHeight === 'function') { | |||
suggestedViewHeight = options.getContainerHeight() - (headerElement ? headerElement.outerHeight(true) : 0); | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you leverage the else if
chain instead of doing a return?
would you be able to write tests for this feature? mandatory to ensure it doesn't break accidentally in the future. https://github.com/fullcalendar/fullcalendar/wiki/Automated-Tests please let me know if i can give you any help/advice. |
I may be able to revisit this at some point, but I don't currently have your test environment set up, or much capacity to investigate it at the moment. |
this makes it a lot easier to size the control to its container. for example, implementations could do
return container_el.clientHeight