BladeRunnerJS / modularapp

An example of a Modular HTML5 SPA built using BladeRunnerJS
http://bladerunnerjs.github.io/scaling-js-apps/
0 stars 3 forks source link

[QUESTION] Best practice for UI behaviours #1

Open leggetter opened 10 years ago

leggetter commented 10 years ago

Knockout is a MVVM solution where the VM should reflect the state of the UI. In the modularapp the Messages Blade shows the latest message at the bottom of an element. This results in it appearing out of view when a number of messages are in this element. What's the best practice for auto-scrolling that element so that the new message is in view?

There is also a need to detect if the user has chose to scroll away from the bottom of the element.

cc: @BladeRunnerJS/bladerunnerjs-core-team-admin

dchambers commented 10 years ago

Anything that's going to affect your view should be part of your view-model, since the view-model is nothing more than a model of your view.

So, given your requirements, it sounds like we are saying there is going to be a scollBottomOffset property within your view-model, that is incremented each time a new message is added (e.g. using an addMessage(message) method), unless it was 0 before the message was added, in which case it is kept at 0.