@@ -19,23 +19,26 @@ import Ubuntu.Components 0.1
1919import "../Components"
2020import Dash 0.1
2121
22−// A VerticalJournal. Based on defined column width,
23−// delegates are layouted in columns following
24−// a top-left most position rule.
25−//
26−// Example:
27−//
28−// +-----+ +-----+ +-----+
29−// | | | 2 | | |
30−// | | | | | |
31−// | 1 | +-----+ | 3 |
32−// | | +-----+ | |
33−// | | | | +-----+
34−// +-----+ | 4 | +-----+
35−// +-----+ | | | 5 |
36−// | 6 | +-----+ | |
37−// | | +-----+
38−// +-----+
22+/*!
23+ \brief A responsive wrapper around VerticalJournal.
24+
25+ Based on defined column width, delegates are laid out in columns following
26+ a top-left most position rule.
27+
28+ Example:
29+
30+ +-----+ +-----+ +-----+
31+ | | | 2 | | |
32+ | | | | | |
33+ | 1 | +-----+ | 3 |
34+ | | +-----+ | |
35+ | | | | +-----+
36+ +-----+ | 4 | +-----+
37+ +-----+ | | | 5 |
38+ | 6 | +-----+ | |
39+ | | +-----+
40+ +-----+
41+*/
3942Item {
4043 property int minimumColumnSpacing: units.gu(1)
4144
@@ -63,18 +66,10 @@ Item {
6366 return Math.floor(pixels / units.gu(1))
6467 }
6568
66− function columnsForSpacing(spacing) {
67− // parent.width = columns * columnWidth +
68− // (columns-1) * spacing + spacing(margins)
69− return Math.max(1, Math.floor(parent.width / (columnWidth + spacing)))
69+ columnSpacing: {
70+ // parent.width = columns * columnWidth + (columns-1) * spacing + spacing(margins)
71+ var expectedColumns = Math.max(1, Math.floor(parent.width / (columnWidth + minimumColumnSpacing)));
72+ Math.floor((parent.width - expectedColumns * columnWidth) / expectedColumns);
7073 }
71−
72− function spacingForColumns(columns) {
73− var spacingGU = px2gu((parent.width - columns * columnWidth) / columns)
74− return units.gu(spacingGU)
75− }
76−
77− readonly property int expectedColumns: columnsForSpacing(minimumColumnSpacing)
78− columnSpacing: spacingForColumns(expectedColumns)
7974 }
8075}