23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

It’s important to understand that semantic zoom is intended to switch between two views of the<br />

same data and not to switch between completely different data sets (see Guidelines and checklist for the<br />

Semantic Zoom control). Also, the control does not support nesting (that is, zooming out multiple times<br />

to different levels). Yet this doesn’t mean you have to use the same kind of control for both views: the<br />

zoomed-in view might be a list, and the zoomed-out view could be a chart, a calendar, or any other<br />

visualization that makes sense. The zoomed-out view, in other words, is a great place to show summary<br />

data that would be otherwise difficult to derive from the zoomed-in view. For example, using the same<br />

changes we made to include the item count with the group data for Scenario 1 (see “Quickstart #2b”<br />

above), we can just add a little more to the zoomed-out item template (as done in the modified sample<br />

in this chapter’s companion content):<br />

The other thing you need to know is that the semantic zoom control does not work with arbitrary<br />

child elements. An exception about a missing zoomableView property will tell you this! Each child control<br />

must provide an implementation of the WinJS.UI.IZoomableView interface through a property called<br />

zoomableView. Of all built-in <strong>HTML</strong> and WinJS controls, only ListView does this, which is why you<br />

typically see semantic zoom in that context. However, you can certainly provide this interface on a<br />

custom control, where the object returned by the constructor should contain a zoomableView property,<br />

which is an object containing the methods of the interface. Among these methods are beginZoom and<br />

endZoom for obvious purposes, and getCurrentItem and setCurrentItem that enable the semantic zoom<br />

control to zoom in to the right group when it’s tapped in the zoomed-out view.<br />

For more details, check out the <strong>HTML</strong> SemanticZoom for custom controls sample, which also serves<br />

as another example of a custom control.<br />

FlipView Features and Styling<br />

For all the glory that ListView merits as the richest and most sophisticated control in all of WinJS, we<br />

don’t want to forget the humble FlipView! Thus before we delve wholly into ListView, let’s spend a few<br />

pages covering FlipView and its features through the other scenarios in the FlipView control sample. It’s<br />

worth mentioning too that although this sample demonstrates the control’s capabilities in a relatively<br />

small area, a FlipView can be any size, even occupying most of the screen. A common use for the<br />

control, in fact, is to let users flip through full-sized images in a photo gallery. Of course, the control can<br />

198

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!