OpenF2 / F2

Redefining web integration for the financial services community
Apache License 2.0
130 stars 62 forks source link

RESIZE event should replace _WIDTH_CHANGE event #87

Closed ilinkuo closed 3 years ago

ilinkuo commented 11 years ago

Not urgent.

Currently, F2.Constants.Events has four events -- APP_SYMBOL_CHANGE, APP_WIDTH_CHANGE, CONTAINER_SYMBOL_CHANGE, CONTAINER_WIDTH_CHANGE. I recommend that APP_WIDTH_CHANGE and CONTAINER_WIDTH_CHANGE be dropped in favor of APP_RESIZE, APP_RESIZED and CONTAINER_RESIZE. Where the _RESIZE event has a value of the form

 {
     instanceId: "ABCD1234", /* id of Container or App, depending on event type*/
     // I don't really like the instanceId in this location, but that's a topic for another day.
     before: {h: 300, w: 300}, 
     after: {h:400, w: 250}}.
 }

Reasons: Height and width changes should be handled together, not as two separate events. APP_RESIZE is a command event from the Container to the App telling it to resize itself, while APP_RESIZED is a notification from the App to the Container. The APP_RESIZED event can be in response to an APP_RESIZE command from the Container, or due to other factors not controlled by the Container. (An alternative to APP_RESIZED is to add an updateWidth() method to F2 in addition to the already existing updateHeight()).

brianbaker commented 11 years ago

We can put @deprecated on both CONTAINER_WIDTH_CHANGE and APP_WIDTH_CHANGE in favor of the _RESIZE variants. The CONTAINER_WIDTH_CHANGE is automatically fired when the browser is resized so for backwards compatibility both CONTAINER_WIDTH_CHANGE and CONTAINER_RESIZE will need to be fired. APP_WIDTH_CHANGE is to be fired by the container itself, so no change would be needed inside of F2 - the container would need to fire the new APP_RESIZE as well.

I need to give some more thought to the implications of _RESIZED and expanding the use of updateHeight() (currently this method only applies to secure apps to update the height of the containing iframe) and potentially adding updateWidth().

ilinkuo commented 11 years ago

It seems to me that the App should notify the Container of any dimension changes regardless of whether or not it's loaded securely? That would remove the need for ugly conditional code such as

if (appConfig.isSecure){
    updateHeight(200);
    // ...
} else { /* Do something else */}

I think there's also a decision to be made as to whether these communications should be made via events or direct function calls.