angularjs - Expanding tiles layout using Angular in responsive layout -
i'm developing angular single-page app responsive layout. current page i'm working on uses tile-based layout auto wraps tiles next row. html below and, in responsive layout, can show 1, 2, or 3 tiles per row depending on width of row (it positions them using floats).
<div class="tiled_panel"> <div class="tile_1">...</div> <div class="tile_2">...</div> <div class="tile_3">...</div> <div class="tile_4">...</div> <div class="tile_5">...</div> ... </div>
now each tile given "learn more" button. design calls block expand between row of selected tile , row below. block full width of row , closed when user closes or clicks on different learn more button.
my first thought arrange html below using ng-if hide or display expander divs can't figure out css needed have display between rows.
<div class="tiled_panel"> <div class="tile_1">...</div> <div class="expander_1">...</div> <div class="tile_2">...</div> <div class="expander_2">...</div> <div class="tile_3">...</div> <div class="expander_3">...</div> <div class="tile_4">...</div> <div class="expander_4">...</div> <div class="tile_5">...</div> <div class="expander_5">...</div> ... </div>
my second thought, since i'm using angular, somehow use transcluding or including insert relevant html appropriate spot. again, can't figure out how identify need insert html?
i've tried searching around other people's solutions similar problems since figured not unusual requirement haven't yet been able find else doing this.
can else suggest need identify insert html or how generate css? or suggest solution haven't considered yet?
although have 70% understand of mean, think ng-class can solve you've faced. solution code below. , setup jsfiddle.
html looks this.
<div ng-app="" ng-controller="myctrl"> <div class="tiled_panel"> <div>tile 1 <a href ng-click="change_tile(1)">more</a></div> <div class="expander" ng-class="{'close': opentile===1}">expander 1<a href ng-click="change_tile(-1)">close</a></div> <div>tile 2 <a href ng-click="change_tile(2)">more</a></div> <div class="expander" ng-class="{'close': opentile===2}">expander 2<a href ng-click="change_tile(-2)">close</a></div> </div> </div>
your controller code looks this.
$scope.change_tile = function(value){ $scope.opentile = value; } $scope.change_tile(0);
css looks this.
.expander{ visibility: hidden } .close{ visibility: visible }
Comments
Post a Comment