Famou.us event capturing performance - events

Famo.us gives a more smooth user interface interaction than a gui coded with HTML elements directly, considering animations, scrolling etc.
Is Famo.us better at capturing the physical user input events like tapping, clicking?

Famo.us does not improve upon the event performance, but does have an EventHandler to allow for the sending of custom events along with core events in the DOM to elements created by Famo.us.
Here is some information about events in FAMO.US

Related

How does Qt animate the QProgressBar?

In some Qt 5 styles (such as Breeze), progress bars which are in indefinite state (minimum == maximum) show an animation.
I want to create my own progress widget which has less visual footprint for use in a status bar, so I looked at the source code of QProgressBar to understand how the animation is implemented.
To my surprise, I didn’t find any animation code in there. There are no timers. There is no event filter.
How is this animation implemented?
The magic dust is the QStyle::polish method. It is invoked on widgets, including the QProgressBar instances.
The breeze style sets up its own animation logic. The progress bars are handled by Breeze::BusyIndicatorEngine. It uses a QPropertyAnimation to advance its own internal value.
Its registerWidget method is invoked from the polish implementation of the Breeze style. This in turn saves the widget in an internal map.
When the internal value is updated by the animation, the map is iterated and update is invoked on all widgets which are currently being animated (using indirection via QMetaObject).

There are duplicate viewreset events when loading different path features in Leaflet with D3.js

I'm using D3js with leaflet (similar to the http://bost.ocks.org/mike/leaflet/).
But when I load different path feature into the svg, I got duplicate viewreset events after each time.
Like I first load the US states data, I got single viewreset event when I zoom in/out.
But after I load the US county data, I got two viewreset events when i zoom in/out.
And when I switch again, I even got more viewreset events.
Should it be one viewreset event, when I zoom in/out once?
Every time you call the code to attach a handler to the viewreset event, a new handler is attached. That is, you end up with several (identical) handlers that are all executed if you run the code every time you load new data.
The solution is to run the code that attaches the handler exactly once.

Windows Phone Visibility Behaviours in CPU

I'd like to ask how objects behave in our phone when we program our applications.
Assume that we have some ellipses, squares rotating around a point, that is, there is a graphic animations where all animation is supposed to be an object as XAML.
If we make this animation Visibility="Collapsed"; what will phone CPU do? Does it still work in CPU without displaying on the screen, or it throws into suspended state into harddrive or something, or in other words, any visibility collapsed object including button, webpage, animations etc. consume the CPU and hence, the battery just as it does while visibility="visible"?
Thanks for your enlightening me in advance.
There are two ways to hide objects on the screen
Visibility Property
When the Visibility property is set to Collapsed, XAML does not hold any visual data for the element in visual memory and does not do any processing related to the element.
Setting Visibility to Visible, will draw the contents of the visual tree and the element is completely.
Opacity
You can improve performance in your app by manipulating the Opacity property of elements when you are using bitmap caching. Bitmap caching allows visual elements to be stored as bitmaps after the first render pass. After the element is cached, the app bypasses the render phase for the cached visual element and displays the stored bitmap instead. When you set the Opacity for a cached element to 0, a bitmap representation of the element is saved in memory. It's recommanded to use BitmapCaching (set CacheMode property to BitmapCache) in scenarios where you are blending, transforming (translating, stretching, rotating).
WP supports a composition thread in addition to the UI thread. UI thread will parse and create objects from XAML, Draw all visuals the first time they are drawn and Process per-frame callbacks and execute other user code. Composition thread combines graphics textures and passes them to the GPU for drawing. There are also some optimisatins forstoryboard-driven animations.
Maintaining a lightweight UI thread is the key to writing a responsive app.

How to implement a timeline custom control with cocoa?

My Cocoa application collects events (instances of NSManagedObject) that need to be displayed in a timeline. My initial approach was to use an existing Javascript based widget (I tried using Simile Timeline and Timeglider) and display the timeline using a WebView control. This works in principle, however unfortunately both these widgets do not handle BC dates very well, which is an important requirement for my app.
The events in my app have date ranges from 500.000BC up to recent dates. Event dates are only expressed with a year. Their day, month and time attributes are irrelevant.
After discarding the Javascript approach, I remain with the option to display the timeline using a custom Cocoa control. As I found none suitable, I will have to develop that myself.
This would be my first custom Cocoa control and after thinking about this for a while I've come up with the following rough design:
I need a custom control to render the actual time line. This control is probably based on an NSView. This control should calculate its size based on the number of tick marks on the time line multiplied by the width (pixels) between each mark. For example the timeline is made up of centuries, each century 100 pixels wide. A time line of events between 10.000BC and 5.000BC would then be 5000 pixels wide (10000 - 5000 = 5000 years, equals 50 centuries).
I need a ScrollView to wrap the timeline to allow it to support scrolling behaviour. There's only need for scrolling horizontally.
I need something to represent an actual event. I'm thinking of using existing controls for this, probably the standard round button and a label wrapped together as a single control.
I need a custom control to render a tick mark on the time line.
Taking this as the basic design for my time line component in Cocoa, would that work or am I completely missing the point?
The basic approach sounds fine.
Apple has a good example of creating a custom NSView called "TreeView". It's a good sample to understand.
https://developer.apple.com/library/mac/#samplecode/TreeView/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010131
“TreeView” presents an example of a creating an entirely new custom
view from scratch (by directly subclassing NSView). Its implementation
illustrates many of the considerations involved in creating a custom
view, including issues of content layout, drawing, handling user
interaction, and providing Accessibility support.
Another thing you may want to consider is zoom in and out. If you have a long timeline, I imagine you may want to zoom out and then zoom in on a cluster of activity. If you have one event in 10k BC and then a cluster of events much later, the user could scroll through tons of empty space trying to find events. Another approach would be to have a mini timeline above that's fit to/static size which is sort of like an index with lines showing activity points - then clicking on that would auto scroll to that point. That may be a nice to have depending on your data.
Some thoughts:
For something this custom drawn, you'll want to override drawRect to draw your lines and layout your subControls.
If you're drawing your background or any part of the views, ensure you enable layer backed views:
[self setWantsLayer:YES];
If you can, as you noted, try leverage existing controls that you add and layout. In my custom controls, I maintained data structures independent of the views/controls that represented the state of all the objects. The in drawRect, I detected the view changing and I called my layoutSubviews function. My layoutSubViews function would do the math from my data structures and create or move the frame of existing controls. That worked well for resize and zooming. If you zoom, your labels ad markers will need to react well to being zoomed really small - perhaps text drops out at some point etc...
if ([self dataSource] &&
!NSEqualRects(_prevRect, [self bounds]))
{
// layoutViews is my custom function that worked over the data structures
// and moved the frame
[self layoutViews];
}
_prevRect = [self bounds];
Hope that helps.

Can you preload images in a dojo animation

I have a dojo animation object of about 15 images. I'm also using dojo.fx.chain to link them all together.
Right before I create all my dojo.fadeIn's and dojo.fadeOut's I added in some basic javascript to preload each image.
My question is: Am I doing this the hard way or is there some function/attr I can set in the animation object to do this?
I do not think there is a predefined method in dojo to preload these images for your animation.
I guess you are listening image.onload and image.onerror events to preload images, it is a common method. If you feel it is too difficult and hard to control, you can try a simple clean css way that is to put an invisible div into your page and set background images with these animation images. When the page load, the images are automatically loaded.
dojo Animations are not specifically geared around images, they work on an abstract level and may operate on DOM nodes. So, there's no built-in support for IMG nodes specifically.
There is dojox.image.preload (http://api.dojotoolkit.org/jsdoc/HEAD/dojox.image.preload) which will do the work virsir suggested of loading images into an offscreen div, but it does not (currently) arrange an onLoad event hook for you to detect when they're loaded and thus play your animation.
I imagine you could use preload()'s return value and use it to hook into onLoad, but that's an exercise for the reader. Have a look at the source code, dojox/image/_base.js.

Resources