Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

feat(grid-list): ts conversion #4337

Merged
merged 7 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP: Review feedback
  • Loading branch information
acdvorak committed Feb 7, 2019
commit 7d4ae6080900e668abe10ecbe4175fcd14ec2e07
1 change: 1 addition & 0 deletions packages/mdc-grid-list/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

export const strings = {
TILES_SELECTOR: '.mdc-grid-list__tiles',
TILE_SELECTOR: '.mdc-grid-tile',
Expand Down
4 changes: 2 additions & 2 deletions packages/mdc-grid-list/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ class MDCGridListFoundation extends MDCFoundation<MDCGridListAdapter> {
};
}

private resizeHandler_: () => void;
private readonly resizeHandler_: EventListener;
private resizeFrame_ = 0;

constructor(adapter: MDCGridListAdapter) {
super(Object.assign(MDCGridListFoundation.defaultAdapter, adapter));
this.resizeHandler_ = () => this.alignCenter();
this.resizeHandler_ = this.alignCenter.bind(this);
}

init() {
Expand Down
11 changes: 6 additions & 5 deletions packages/mdc-grid-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/

import {MDCComponent} from '@material/base/component';

import {MDCGridListFoundation} from './foundation';

class MDCGridList extends MDCComponent<MDCGridListFoundation> {
Expand All @@ -38,16 +37,18 @@ class MDCGridList extends MDCComponent<MDCGridListFoundation> {
},
getOffsetWidth: () => (this.root_ as HTMLElement).offsetWidth,
getOffsetWidthForTileAtIndex: (index) => {
const tile = this.root_.querySelectorAll(MDCGridListFoundation.strings.TILE_SELECTOR)[index] as HTMLElement;
const tile = this.root_.querySelectorAll<HTMLElement>(MDCGridListFoundation.strings.TILE_SELECTOR)[index];
return tile.offsetWidth;
},
registerResizeHandler: (handler) => window.addEventListener('resize', handler),
setStyleForTilesElement: (property, value) => {
const tile = this.root_.querySelector(MDCGridListFoundation.strings.TILES_SELECTOR) as HTMLElement;
tile.style[property] = value;
const tile = this.root_.querySelector<HTMLElement>(MDCGridListFoundation.strings.TILES_SELECTOR);
tile!.style[property] = value;
},
});
}
}

export {MDCGridList, MDCGridListFoundation};
export {MDCGridList as default, MDCGridList};
export * from './adapter';
export * from './foundation';